Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginner Win32 Programmer: Dialog Box Problem. Pls Help

Status
Not open for further replies.

cdgios

Technical User
Jul 17, 2002
40
0
0
US
Hello, I have a dialog box with a list box control and a bunch of edit box controls. When i excute the application, the dialog box shows up. But when the i try selecting an item from a list box and just happen to click any of the edit controls, the dialog box disappers. I have several other similar dialog boxes in my application which work just fine. Could you help me debug this problem.

Thanks a bunch
Best Regards
Chandra
 
I want to add, I have situation where, in the dialog procedure, I am writing to an edit control on the dialog box as follows,

1. wsprintf (szBuffer, TEXT ("%d"), 0) ;
2. SendDlgItemMessage (hdlg, IDC_EDIT_00, WM_SETTEXT, 0,
(LPARAM) (LPSTR) szBuffer) ;
Now for some reason, The presence of "2" causes the dialog box to not appear when i execute the program. When i comment out "2", the dialog box appears. Now i am pretty sure that i have used the function SendDlgItemMessage () correctly (I have used it several other places and it works fine).

Could you help me understand what the problem is.

Thanks
Best Regards
Chandra
 
I want to add that, I have modified the resource script (.RC) and the resource.h files outside the VC++ editor (i.e. through note pad). Esentially i changed the sizes and positions of some controls on the dialog box. I also removed some unused ID's from the resource.h.
Can this cause any problem. I can't think of a logical reason why it should. More over i have done such changes before without a problem.

Thanks
Best Regards
Chandra
 
Doesn't your program fall through in a switch statement because of a forgotten break statement??

If you have something in your dialog box procedure like:
Code:
   CASE WM_COMMAND :
        switch ( LOWORD(wParam))
           { case IDC_EDIT_00 : ...
                  // and forget break; or return ( ... ); here
             case IDOK :
                  // code here to end dialog
        ...

This code matches your description of the problem: When the edit box sends a notification to the dialog box procedure, after the notification has been processed the code for IDOK is also processed.

Marcel
 
Hello Kupier, thanks for your reply. I found out the problem. It was a default case statement in the
switch (LOWORD (wParam)) for WM_COMMAND message that i had which was closing the dialog box and returning TRUE.

Best Regards
Chandra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top