CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Jun 2001
    Posts
    104

    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.

  2. #2
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  3. #3
    Join Date
    Jun 2001
    Posts
    104

    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.

  4. #4
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  5. #5
    Join Date
    Jun 2001
    Posts
    104

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    I tried it, and it pops up with an exception, a stack overflow.

  6. #6
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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.
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  7. #7
    Join Date
    Jun 2001
    Posts
    104

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    Quote 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.

  8. #8
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  9. #9
    Join Date
    Jun 2001
    Posts
    104

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    Quote 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.

  10. #10
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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.
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  11. #11
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    You are missing a call to InitCommonControlsEx

    Read up on this

  12. #12
    Join Date
    Jun 2001
    Posts
    104

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    Quote 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.

  13. #13
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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 ?

  14. #14
    Join Date
    Jun 2001
    Posts
    104

    Re: DialogBox App Bugs after adding SpinControl or ComboBox

    Quote 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.

  15. #15
    Join Date
    Jan 2014
    Posts
    1

    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
  •  





Click Here to Expand Forum to Full Width

Featured