Solved

Dialog Item Text Problem

Posted on 2000-03-20
11
271 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now