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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open a dialog window resource when a user clicks a button?

Status
Not open for further replies.

ddeham

Programmer
Sep 30, 2005
11
I have an application with one window and a Compass button. I also created a dialog resource, with the ID "IDD_COMPASS". How do I open a dialog window with this resource when the user clicks the Compass button? Here is my command handler routine. This code does get executed when the user clicks the button. I just need some help fixing the code. Nothing happens when I click the button now. I'm using Microsoft eMbedded Visual C++ 4.0. Thanks.

Code:
//----------------------------------------------------------------------
// DoMainCommandCompass - Process DoMainCommandCompass command.
//
LPARAM DoMainCommandCompass (HWND hWnd, WORD idItem, HWND hwndCtl, WORD wNotifyCode) 
{
     HWND hwndChild;
     
     if (wNotifyCode == BN_CLICKED)
     {
          
          hwndChild = CreateWindowEx (0, TEXT ("compassbox"),
               TEXT (""), WS_EX_TOPMOST , 0,
               0, CW_USEDEFAULT, CW_USEDEFAULT,
               hWnd, (HMENU)IDD_COMPASS, hInst, NULL);

          DialogBox(hInst,MAKEINTRESOURCE(IDD_COMPASS),hwndChild,CompassDlgProc);
     }
    return 0;
}
 
Try to show parent window (hwndChild) with ShowWindow() before create the dialog. I hope, You use right CompassDlgProc().
 
I got it to work. I just created a new dialog resource again, and I deleted the CreateWindowEx statement, and it works. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top