CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    219

    [RESOLVED] Win32 Combobox

    Hello,

    I'm creating a combobox, im not sure why but the dropdownlist is not shown, I can use the keys to navigate between the items, but not see them. This is the code:

    Code:
    HWND CreateComboBox(bool bVisisble,const int iX, const int iY, const int iWidth, const int iHeight, HWND hWndParent,HMENU hmID)
    {
    	HWND hComboBox = CreateWindowEx(0,"Combobox", 0, WS_CHILD | (bVisisble ? WS_VISIBLE : NULL) | CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | 0x00002000, iX, iY, iWidth, iHeight, hWndParent, hmID, GetModuleHandle(0),NULL);
    	ApplyCalibri(hComboBox);
    	return hComboBox;
    }
    
    const char *cScanTypes[] = { "Byte", "2 Bytes", "4 Bytes",
    	"Float", "Double", "AoB",
    	};
    
    {
            HWND hTest = CreateComboBox(true,10,100,150,25,hWnd,0);
    	HWND hTest2 = CreateComboBox(true,180,100,150,25,hWnd,0);
    
    	for(int Count = 0; Count < 6; Count++)
    	{
    		SendMessage(hTest ,CB_ADDSTRING,0,(LPARAM)cScanTypes[Count]);
    		SendMessage(hTest2,CB_ADDSTRING,0,(LPARAM)cScanOptions[Count]);
    		int x = GetLastError();
    	}
    }

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Win32 Combobox

    A long since I used pure win32...
    Works ok for me however if I use your CreateWindowEx with fixed values instead of params. Setting iHeight to 0 give the behaviour you describe so what values do you use?
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Aug 2009
    Posts
    219

    Re: Win32 Combobox

    Quote Originally Posted by S_M_A View Post
    A long since I used pure win32...
    Works ok for me however if I use your CreateWindowEx with fixed values instead of params. Setting iHeight to 0 give the behaviour you describe so what values do you use?
    I do not understand what values you mean? I guess I posted them in the code snippet?

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Win32 Combobox

    Yes you did... guess I'm more tired than I thought I was...
    I tried your values and if you change ,,,25 to for instance ,,,250 the dropdown part shows up.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Aug 2009
    Posts
    219

    Re: Win32 Combobox

    Quote Originally Posted by S_M_A View Post
    Yes you did... guess I'm more tired than I thought I was...
    I tried your values and if you change ,,,25 to for instance ,,,250 the dropdown part shows up.
    Thanks a lot man

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