Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dialog Item Text Problem

Posted on 2000-03-20
11
Medium Priority
?
280 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 200 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

705 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