-
September 17th, 2012, 09:01 AM
#1
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.
-
September 17th, 2012, 10:10 AM
#2
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.
-
September 18th, 2012, 04:10 AM
#3
Re: DialogBox show nothing
Originally Posted by anrapas
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?
- Does IDD_IB template exist?
- What is hwndParent? Is it a valid handle?
- 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
-
September 18th, 2012, 04:38 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|