Solved

Dialog Item Text Problem

Posted on 2000-03-20
11
273 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
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

820 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