Solved

Dialog Item Text Problem

Posted on 2000-03-20
11
276 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…

734 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