-
September 22nd, 2007, 02:58 PM
#1
DialogBox App Bugs after adding SpinControl or ComboBox
I have Visual Studio.Net 2003, and created a Win32 based dialogbox application. I then used the resource editor to add controls. It worked fine, until I added a spin control. When that happened, the dialogbox returned a null handle, and did not display. If I remove the spin control, things work fine.
When I added a combobox, upon pressing the dropdown arrow for the box, the application freezes up. I didn't connect these controls up, I only placed them on the dialog box form.
Has anyone else encountered these problems? I’m not using MFC here, just Win32, and am wondering if this is the problem. Not sure.
Thanks for any feedback!
Last edited by jalway; September 23rd, 2007 at 12:46 AM.
-
September 22nd, 2007, 09:39 PM
#2
Re: DialogBox App Bugs after adding SpinControl or ComboBox
You might have made some changes to window / dialog procedure, that is I can guess without seeing the code. If you can paste the dialog procedure, we can see and try sorting out the problem may be. Becuase adding such simple controls to a dialog must never not freez the application in general.
regards
-
September 22nd, 2007, 10:12 PM
#3
Re: DialogBox App Bugs after adding SpinControl or ComboBox
There isn't much to it, since I just started the project. Here is both WinMain and the dialog box Procedure.
I have several controls on the dialog box, but as soon as I place the spin control on it returns a null handle, and the dialog box is not created.
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
HWND hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
MSG msg;
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, hwnd, 0, 0))
{
if (!IsDialogMessage(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
BOOL CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
g_bTheEnd = true;
DestroyWindow(hwnd);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
}
return FALSE;
}
Last edited by jalway; September 22nd, 2007 at 10:15 PM.
-
September 22nd, 2007, 10:25 PM
#4
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Code seems clear enough to me, once I faced such error when I was trying to embed tab control, I do not exactly remember how I did solve it.
In your dowlog procedure you are returning FALSE on every message other than the ones you processed. Try returning following from dialog procedure and please let me know the results.
Code:
return DefDlgProc(hwnd, message, wParam, lParam);
regards
-
September 22nd, 2007, 11:01 PM
#5
Re: DialogBox App Bugs after adding SpinControl or ComboBox
I tried it, and it pops up with an exception, a stack overflow.
-
September 22nd, 2007, 11:05 PM
#6
Re: DialogBox App Bugs after adding SpinControl or ComboBox
I think there is something else causing the problem, might be system (just guess), as far I see code is fine to compile and run.
Try this too
return DefWindowProc(hwnd, message, wParam, lParam);
Sorry, I could not be of much help.
-
September 22nd, 2007, 11:28 PM
#7
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Originally Posted by Ali Imran
I think there is something else causing the problem, might be system (just guess), as far I see code is fine to compile and run.
Try this too
return DefWindowProc(hwnd, message, wParam, lParam);
I get the null handle returned as in the first case.
Sorry, I could not be of much help.
I've given you a positive rating for your help. I appreciate the solid effort!
Still looking for a solution to the problem, though.
-
September 22nd, 2007, 11:31 PM
#8
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Thanks,
but I did not follow what you mean by:
I get the null handle returned as in the first case.
regards
-
September 23rd, 2007, 12:44 AM
#9
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Originally Posted by Ali Imran
Thanks,
but I did not follow what you mean by:
regards
The CreateDialog() function returns a null handle, presumably because a dialog box is not being created.
-
September 23rd, 2007, 01:02 AM
#10
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Well that definitely means idalog is not being created.
Can you please paste your resource file code (generated by the IDE) ?
regards
Last edited by Ali Imran; September 23rd, 2007 at 01:04 AM.
-
September 23rd, 2007, 10:58 AM
#11
Re: DialogBox App Bugs after adding SpinControl or ComboBox
You are missing a call to InitCommonControlsEx
Read up on this
-
September 23rd, 2007, 01:49 PM
#12
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Originally Posted by kirants
You are missing a call to InitCommonControlsEx
Read up on this
Yes, that works. I should have remembered that, since I knew about and have used Common Controls in Win32.
I added the following:
Code:
INITCOMMONCONTROLSEX cc;
cc.dwSize = sizeof(INITCOMMONCONTROLSEX);
cc.dwICC = ICC_BAR_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES;
InitCommonControlsEx(&cc);
HWND hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
Thanks, the dialog now launches.
However, I'm still having the problem with the dropdown combobox. When I press the drop down button the application freezes up. In MFC I've not had this problem, and I'm pretty sure I've used a drop down box in Win32 in the past. Anyway, I've been playing around with adding items, which I can do, and changing the size of the drop down's height, which I can do, but why is it freezing up? I've looked that the website FunctionX, this link and I can't see anything I'm doing wrong. I'm not creating the combo programmatically, that's the difference, but this should work with the resource editor.
-
September 23rd, 2007, 05:06 PM
#13
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Hard to say. Does your spin control have the autobuddy style ? If so, have you tried removing it ?
-
September 23rd, 2007, 07:15 PM
#14
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Originally Posted by kirants
Hard to say. Does your spin control have the autobuddy style ? If so, have you tried removing it ?
Keep in mind that this problem occured even when I had no spin control on the dialog box.
Interestingly, if I capture the CBN_DROPDOWN message, and launch a MessageBox() the problem goes away, but that's the only way I can make it go away presently.
-
January 27th, 2014, 11:14 AM
#15
Re: DialogBox App Bugs after adding SpinControl or ComboBox
Sorry for the necrobump! I had ran into the exact same issue to the OP's issue regarding the combobox and was able to resolve it. The message pump (wndproc()) was originally tied to my window thus there was conflict between the messages i was trying to process and the combobox was trying to process. Simply changing the code below fixed the issue.
GetMessage(&(msg), _hWnd, 0, 0);
to
GetMessage(&(msg), NULL, 0, 0);
Hope this helps anyone, i made an account just to post it
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
|