CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2012
    Posts
    181

    [RESOLVED] Why this dialog isn't caused?

    Code:
    INT_PTR CALLBACK MyInputDlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
    {
        switch(iMsg)
        {
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                    case IDOK:
                     WCHAR Temp[256];
                     GetDlgItemText(hDlg, IDC_EDIT1, Temp, 50);
    				 CharToOem(Temp, TempName);
                     EndDialog(hDlg, FALSE);
    				 break;
    				case IDCLOSE:
                     EndDialog(hDlg, FALSE);
                     break;
                }
            case WM_DESTROY:
                DestroyWindow(hDlg);
                break;
            default:
                return FALSE;
        }
        return TRUE;
    }
    ....
    CreateDialog(hInst, MAKEINTRESOURCE(IDD_INPUTBOX), hWnd, MyInputDlgProc); // this is simplisity passed

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Why this dialog isn't caused?

    Define "isn't caused".
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2012
    Posts
    181

    Re: Why this dialog isn't caused?

    VictorN, isn't invoked, correctly...

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Why this dialog isn't caused?

    See http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    If CreateDialog returns NULL call GetLastError to find out why
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Feb 2012
    Posts
    181

    Re: Why this dialog isn't caused?

    DialogBox is needed. Solved.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Why this dialog isn't caused?

    Quote Originally Posted by AKE View Post
    DialogBox is needed. Solved.
    It actually depends on what the purpose was. DialogBox creates modal dialog when CreateDialog creates modeless one.

    Code:
    HWND hDlg = CreateDialog(...);  // this just creates dialog window
    ShowWindow(hDlg, SW_SHOW); // unless WS_VISIBLE was specified at creation
    UpdateWindow(hDlg);
    
    // message pump is also needed running on this thread
    Best regards,
    Igor

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