Thread: ComboBox: text in list not visible

  1. #1
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34

    Question ComboBox: text in list not visible

    The combobox is the only child window on the main window. And what happens is to it when I use CBS_DROPDOWN style is the text in list that drops down doesn't show up and it freezes the whole application, but my CPU usage on that process says it is zero.

    If I press enter when the combobox is selected, it "un-freezes" the application. I also tried making the cy very larege, but it didn't make any difference.

    Here is how the window is created:
    Code:
    void cCHILDWINDOW::Create(const char *pszType, HWND hParent, int cx, int cy, int x, int y,
    DWORD dwStyle, DWORD dwExStyle)
    {
    	this->hParent=hParent;
    	if ( (hwnd=CreateWindowEx(dwExStyle, pszType, NULL, dwStyle | WS_CHILD | WS_VISIBLE, 
    						x, y, cx, cy, hParent, 0, cCOMPONENT::AppInstance, NULL))==0 )
    		return;
    
    	OldChildProc=(WNDPROC)(LRESULT)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)ChildProc);
    	SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
    }
    StepNext goes to the next node in a linkedlist
    GetNode gets the current item on the node
    StepReset resets the stepper variable to the head of the linked-list

    The code in the WndProc:
    Code:
    LRESULT CALLBACK cWINDEX::WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	cLINKEDLIST<cCHILDWINDOW*> *ChildWindow=&cWINDOW::Objects->ChildWindow;
    	if ( ChildWindow->Count()> 0 )
    	{
    		ChildWindow->StepReset();
    		do
    		{
    			if ( (ChildWindow->GetNode())->ProcessParent(hwnd, message, wParam, lParam) )
    				return DefWindowProc(hwnd, message, wParam, lParam);
    		
    		}while ( ChildWindow->StepNext() );
    	}
    	.
    	.
    	.
    	return DefWindowProc(hwnd, message, wParam, lParam);
    }
    Code in sub-classed window (the 'return 0' will never be reached. It is only there to remove a warning):
    Code:
    LRESULT CALLBACK cCHILDWINDOW::ChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	cCHILDWINDOW *TempChild;
    	cLINKEDLIST<cCHILDWINDOW*> *ChildWindow=&cWINDOW::Objects->ChildWindow;
    
    	if ( ChildWindow->Count()>0 )
    	{
    		ChildWindow->StepReset();
    		do
    		{
    			TempChild=ChildWindow->GetNode();
    			if ( hwnd==*TempChild )
    			{
    				TempChild->ProcessEvents(hwnd, message, wParam, lParam);
    				return CallWindowProc(TempChild->OldChildProc, hwnd, message, wParam, lParam);
    			}
    		}while ( ChildWindow->StepNext() );
    	}
    
    	return 0;
    }
    Thanks in advance,
    Joe

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    What does

    TempChild->ProcessEvents(hwnd, message, wParam, lParam);

    do?
    Does it call the default msg proc?
    Looks like you may be creating an infinite loop. The ChildProc does not filter msg's it processes (returns false for) or processes (returns true for).
    It just passes both to the parent wndproc for further processing.


    With child windows the HMENU should be cast to an int ID number.
    ie
    #define IDC_MY_COMBO_1 40001

    CreateWindow(.....,(HMENU)IDC_MY_COMBO_1,..);

    This can then be used as a switch under the WM_COMMAND handler in the parents callback.
    ie
    idControl = GET_WM_COMMAND_ID(wParam,lParam) ;//from windowsx.h
    switch(idControl)
    {
    case IDC_MY_COMBO_1:
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34

    Smile

    The error in the code has nothing to do with the WndProc, but the message loop. My GetMessage look liks this:
    Code:
    GetMessage(&msg, hwnd, 0, 0)
    but when I changed it to:
    Code:
    GetMessage(&msg, NULL, 0, 0)
    everything worked!

    Thanks for your help,
    Joe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Anyone good with linked list.....I am not....
    By chadsxe in forum C++ Programming
    Replies: 11
    Last Post: 11-10-2005, 02:48 PM
  3. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 09:01 AM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM