Creating a dialog from a dll
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Creating a dialog from a dll

  1. #1
    Join Date
    Aug 2007
    Posts
    9

    Creating a dialog from a dll

    Hello,

    I have a dll I built to be loaded as a pluging. As part of the dll I have a dialog I'm trying to create and display.
    The dialog is created and displayed using CreateDialog, however once the dialog is shown it doesn't respond, as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.

    bool CDialogs::displaySafetyDialog(HWND wnd)
    {
    HWND retValue = CreateDialog(m_instance, MAKEINTRESOURCE(IDD_SAFETY), NULL, dialogProc);


    return true;
    }

    INT_PTR CALLBACK CDialogs::dialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    static int num;
    BOOL translated = false;

    switch (uMsg)
    {
    case WM_INITDIALOG:
    return TRUE;
    case WM_COMMAND:
    switch (LOWORD(wParam))
    {
    case IDOK:
    if (num == GetDlgItemInt(hwnd, IDC_INPUT, &translated, false))
    {
    DestroyWindow(hwnd);
    }
    return TRUE;
    case IDCANCEL:
    DestroyWindow(hwnd);
    return TRUE;
    default:
    break;
    }
    break;
    default:
    break;
    }

    return FALSE;

    }

    Any help will be appreciated,
    Best regards,
    Alex

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,848

    Re: Creating a dialog from a dll

    Please format your code properly before posting and use code tags. Your code as shown is not easy to understand. Go Advanced, select the code and click '#'.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Aug 2007
    Posts
    9

    Re: Creating a dialog from a dll

    Quote Originally Posted by khalameizer View Post
    Hello,

    I have a dll I built to be loaded as a pluging. As part of the dll I have a dialog I'm trying to create and display.
    The dialog is created and displayed using CreateDialog, however once the dialog is shown it doesn't respond, as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.
    Code:
    bool CDialogs::displaySafetyDialog(HWND wnd)
    {
    	HWND retValue = CreateDialog(m_instance, MAKEINTRESOURCE(IDD_SAFETY), NULL, dialogProc);
    	
    
    	return true;
    }
    
    INT_PTR CALLBACK CDialogs::dialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	static int num;
    	BOOL translated = false;
    
    	switch (uMsg)
    	{
    		case WM_INITDIALOG:
    			return TRUE;
    		case WM_COMMAND:
    			switch (LOWORD(wParam))
    			{
    			case IDOK:
    				if (num == GetDlgItemInt(hwnd, IDC_INPUT, &translated, false))
    				{
    					DestroyWindow(hwnd);
    				}
    				return TRUE;
    			case IDCANCEL:
    				DestroyWindow(hwnd);
    				return TRUE;
    			default:
    				break;
    			}
    			break;
    		default:
    			break;
    	}
    
    	return FALSE;
    		
    }
    Any help will be appreciated,
    Best regards,
    Alex
    Attached above the formatted code.
    Thank you,
    Alex

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: Creating a dialog from a dll

    maybe a silly question, but in that kind of setup... Who'll be doing the "pumping" of the messages of your dialog ?

    also. The thread that creates the window, needs to be the SAME thread that processes the messages. Does your plugin guarantee this is always going to be the case ?

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

    Re: Creating a dialog from a dll

    Quote Originally Posted by khalameizer View Post
    as soon as I pass the mouse over the dialog the mouse pointer changes to busy, and the dialog isn't responding while the rest of the module keeps running.
    You need to learn about modal and modeless dialogs. CreateDialog just creates modeless dialog which requires a proper message pump be present in the thread. DialogBox function creates a modal dialog and internally takes care about dialog messages proper pumping.
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center