CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  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,654

    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
    https://visualstudio.microsoft.com/vs

  3. #3
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,397

    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
  •  





Click Here to Expand Forum to Full Width

Featured