Solved

Dialog Item Text Problem

Posted on 2000-03-20
11
277 Views
Last Modified: 2013-12-03
Hello experts:

I'm having problems with a edit text control in a dialog box.

This is the code of the Dialog procedure.

BOOL CALLBACK CircDescrWorkDlgProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)

{

  switch (message)
  {
    case WM_CLOSE:
      EndDialog (hWnd, LOWOR(wParam));
return true;
     
    case WM_COMMAND:
      {
      int wmId = LOWORD(wParam);
      switch (wmId)
      {
        case IDC_OK:
          GetDlgItemText (hWnd,
             IDC_EDITDESCRIPT,                     Circt->CirctDescrip,
             MAXSTRLEN);
        EndDialog (hWnd, LOWORD
             (wParam));
          return true;

      case IDC_CANCEL:
        EndDialog (hWnd, LOWORD
          (wParam));
      return true;
      }
     }
    case WM_INITDIALOG:
//Here is the problem

HWND hTextWnd = GetDlgItem (hWnd, IDC_EDITDESCRIPT);
SetWindowText (hTextWnd,
Circt->CirctDescrip);

return true;

}

      return false;
}

//Circt->CirctDescrip is a pointer to char
Well... As you can see... In the WM_INITDIALOG message I set a text
Thats Ok... I see the text I want to see, but I'm not able to type, just to select... If I don't set any text, I can type without any problem. But I need to set a text in order to the user can change it...

What am I doing wrong...

Thank you very much.

 
0
Comment
Question by:Marsc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
11 Comments
 
LVL 1

Author Comment

by:Marsc
ID: 2638984
Using VC++.
0
 
LVL 1

Expert Comment

by:PC-Alex
ID: 2639040
I guess this has to do with the return value of the "case WM_INITDIALOG" part: I guess, if you comment your code part out, you return true instead of false, is that right ?

BTW ... is this a WIN16 program ? The code reminds me to the very beginning of windows programming ...
0
 
LVL 1

Author Comment

by:Marsc
ID: 2639085
I'm sorry...
In the code there is a "return true"
after I set the text...
I forgot to put it in the question...

The return false is only when I Ignore the message.


I'm programming for win 32.
It is just a dialog procedure.
I don't know... I'm using the apis as it says in the documentation.

Thanks...
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:Marsc
ID: 2639087
Edited text of question.
0
 
LVL 1

Author Comment

by:Marsc
ID: 2639092
I'm started trying the SetDlgItemText ()
api call in WM_INITDIALOG message.
but I had the same problem.
0
 
LVL 1

Expert Comment

by:PC-Alex
ID: 2639116
OK, your target is WIN32, and I just suppose you use Visual Studio. So why not getting the easiest way out of it ? I'll tell you a few steps to update your project to the year 2000:

1. comment that function out ("CircDescrWorkDlgProc"), or just leave one line: return false;
2. Press CTRL-W to start the ClassWizard
3. Select your dialogue ("Class name")
4. Select the "Member variables" tab
5. Select your EDIT control and click "Add variable", then give it a name (e.g. m_strMyEdit), and as type "CString"
6. Click OK

Now you have a CString variable that always holds the current value of the edit field after calling "UpdateData(FALSE);"

If you want to initialize the value: In the Class Wizard, select the tab "Message Maps", select your dialog ("Class name"), and under "Messages", doubleclick the entry "WM_SHOWWINDOW", and click two times "OK".

Now you have a function "OnShowWindow", where you just add two lines:
m_strMyEdit = Circt->CirctDescrip;
UpdateData(TRUE);

Thats it !
0
 
LVL 1

Author Comment

by:Marsc
ID: 2639213
Yes...

The problem now is that It looks like using MFC... And my project doesn't use it...

I mean... when I created the project I created it as Win32 App (I didn't started as a MFC project).

So... I have to process all that messages...

Off course the project is closer to the end than the begining... So I can't think to move this to an MFC project.

Thanks.
0
 
LVL 1

Author Comment

by:Marsc
ID: 2639216
I'm getting crazy... I just want the edit control to allow the user to type text after I set the text to this control.
0
 
LVL 15

Accepted Solution

by:
NickRepin earned 50 total points
ID: 2639305
Place 'break' before 'case WM_INITDIALOG' for WM_COMMAND.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2639308
case WM_COMMAND:
 {
     switch() {
     }
 }

///VVVVVVVVVVVV

  break;

case WM_INITDIALOG
0
 
LVL 1

Author Comment

by:Marsc
ID: 2640263
I don't know what to say...
The answer was obvious... But I didn't realise...
Well... Actually, I guess that it happened because when typing the Dlg receives Command msg... I really didn't know it...

Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question