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

Thread: DialogBox show nothing

  1. #1
    Join Date
    Sep 2012
    Posts
    2

    DialogBox show nothing

    I've got this slice code inside a DLL:

    Code:
    DWORD processId;
    HWND hwndParent;
    BOOL CALLBACK enumWindowsProc(HWND hwnd, LPARAM lParam)
    {
    	DWORD procid;
    	GetWindowThreadProcessId(hwnd, &procid);
    	if (procid == processId)
    	{
    		hwndParent = hwnd;
    		return FALSE;
    	}
    	return TRUE;
    }
    
    const char* InputBox(LPCSTR title, const char* message, const char* def_value)
    {
    	HWND hwnd;
    	MSG msg;
    	processId = GetCurrentProcessId();
    	EnumWindows(enumWindowsProc, 0);
    	int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_IB), hwndParent, InputBox_WndProc);
    
    	return "0";
    }
    Why id doesn't show any Dialog?

    Thanks a lot.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: DialogBox show nothing

    The best way is to do as they say here http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx i.e. call GetLastError.
    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
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,610

    Re: DialogBox show nothing

    Quote Originally Posted by anrapas View Post
    I've got this slice code inside a DLL:

    Code:
    ...
    	EnumWindows(enumWindowsProc, 0);
    	int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_IB), hwndParent, InputBox_WndProc);
    Why id doesn't show any Dialog?
    Why should it show anything?
    1. Does IDD_IB template exist?
    2. What is hwndParent? Is it a valid handle?
    3. What is InputBox_WndProc?

    You have to debug your code to be sure all the parameters passed in the DialogBox(...) are valid!
    And of course you have to use GetLastError (as S_M_A already mentioned) to obtain the extended error information if some error happened.
    Victor Nijegorodov

  4. #4
    Join Date
    Sep 2012
    Posts
    2

    Re: DialogBox show nothing

    I've found the error.

    I use to call the DialogBox function with GetModuleHandle(NULL) instead of DLL HINSTANCE value (provided as first parameter at APIENTRY DllMain function).

    Thanks a lot.

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