CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    1

    Help with Creating a Custom Class for a modeless dialog popup

    Hello all,

    I desire to create a modeless dialog with a custom class. The dialog
    is created as a form. The code below shows what I'm doing. Yet
    CreateDialog always returns NULL. I guess I don't know what I'm doing
    wrong...

    Code:
    IDRESULTS DIALOGEX 0, 0, 412, 232
    STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX |
    WS_POPUP | WS_CAPTION | WS_SYSMENU
    EXSTYLE WS_EX_CONTROLPARENT
    CAPTION "Results"
    CLASS "MyClass"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
    
    END
    Code:
    HWND RegisterResultsDlg(HINSTANCE hInst, HWND hwnd)
    {
       HWND hwndDlg;
       WNDCLASS wc;
    
       GetClassInfo(hInst,"#32770",&wc);
       wc.lpfnWndProc = DlgResultsProc;
       wc.lpszClassName = "MyClass";
       if(!RegisterClass(&wc))
       {
          MessageBox(NULL, "Failed to Register Custom Dialog Class!", "Error!",
             MB_ICONEXCLAMATION | MB_OK);
          return NULL;
    
       }
    
       hwndDlg = (HWND)CreateDialog(hInst, "MyClass",
          hwnd, DlgResultsProc);
    
       if(hwndDlg == NULL)
       {
          MessageBox(NULL, "Failed to Create Results Dialog Box!", "Error!",
             MB_ICONEXCLAMATION | MB_OK);
          return NULL;
       }
    
       ShowWindow(hwndDlg,SW_SHOW);
       return hwndDlg;
    }
    Last edited by ovidiucucu; February 3rd, 2010 at 03:41 AM. Reason: CODE tags added

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured