Results 1 to 2 of 2

Thread: Help with ComboBoxEx

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I'm learning how to use the windows common controls in VC++.

    I'm starting with the ComboBoxEx control.

    The main window work fine and I just put in the code to create the combo box from MSDN. However, I'm getting the following error when compiling:

    error C2664: 'CreateWindowExA' : cannot convert parameter 9 from 'void *' to 'struct HWND__ *'
    Conversion from 'void*' to pointer to non-'void' requires an explicit cast

    Parameter 9 is the handle to the main window. I declared a global variable as: HANDLE ghWndMain and after I call the ShowWindow function, I set the variable as: ghWndMain = hWnd which should set it to the Main window's handle, right?

    But for some reason, the CreateWindowEx function inside the ComboBoxEx function doesn't like that handle. Here is the code for the ComboBox:

    Code:
    HWND WINAPI CreateComboEx(void)
    {
    
    	HWND hWnd;
    	INITCOMMONCONTROLSEX icex;
    
    	icex.dwSize =	sizeof(INITCOMMONCONTROLSEX);
    	icex.dwICC =	ICC_USEREX_CLASSES;
    
    	InitCommonControlsEx(&icex);
    
    	hWnd = CreateWindowEx(0,WC_COMBOBOXEX,NULL,
    						WS_BORDER|WS_VISIBLE|WS_CHILD|CBS_DROPDOWN,
    						// No size yet -- resize after setting image list
    						0,	// Vertical position of Combobox
    						0,	// Horizontal position of Combobox
    						0,	// Sets the width of Combobox
    						100,	// Sets the height of Combobox
    						ghWndMain,
    						NULL,
    						ghInstance,
    						NULL);
    	return(hWnd);
    }
    Any help would be appreciated..

    Dan

    Visual Studio 2010

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    You can't use a HANDLE in that function. You need to use a HWND. So change:
    HANDLE ghWndMain; to
    HWND ghWndMain;
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


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