|
-
February 11th, 2010, 06:01 AM
#1
Combo Box Styles
Hi,
I am creating a combo box via C++ code in order to abtain the third combobox on the right shown in the picture below:

The following is the code:
Code:
HWND hvComboBox = CreateWindowEx(0,WC_COMBOBOX,NULL,
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | 0x00002000,
60, 62, 250, 100,
hwnd,(HMENU)IDC_COMBO1,hInst,NULL);
where I guess the 0x00002000 should give the combobox that special style (the control was originally created with ResEdit)
Unfortunately, I am still getting a normal style like the combo in the middle shown in the picture...what am I doing wrong?
thanks
-
February 11th, 2010, 06:41 AM
#2
-
February 11th, 2010, 12:36 PM
#3
Re: Combo Box Styles
I checked them out, still I can't find the style ResEdit created
-
February 11th, 2010, 02:24 PM
#4
Re: Combo Box Styles
Code:
/*
* Combo Box styles
*/
#define CBS_SIMPLE 0x0001L
#define CBS_DROPDOWN 0x0002L
#define CBS_DROPDOWNLIST 0x0003L
#define CBS_OWNERDRAWFIXED 0x0010L
#define CBS_OWNERDRAWVARIABLE 0x0020L
#define CBS_AUTOHSCROLL 0x0040L
#define CBS_OEMCONVERT 0x0080L
#define CBS_SORT 0x0100L
#define CBS_HASSTRINGS 0x0200L
#define CBS_NOINTEGRALHEIGHT 0x0400L
#define CBS_DISABLENOSCROLL 0x0800L
#if(WINVER >= 0x0400)
#define CBS_UPPERCASE 0x2000L
#define CBS_LOWERCASE 0x4000L
#endif /* WINVER >= 0x0400 */
#endif /* !NOWINSTYLES */
-
February 11th, 2010, 04:02 PM
#5
Re: Combo Box Styles
ok, thanks. Yet, it seems there's no way to make it look like that
-
February 11th, 2010, 04:40 PM
#6
Re: Combo Box Styles
CBS_DROPDOWNLIST should do that. Maybe I didn't understand your question. What is the problem?
-
February 11th, 2010, 04:52 PM
#7
Re: Combo Box Styles
I get a regular combobox, I dont get the third on the left shown in teh picture I posted
-
February 11th, 2010, 05:22 PM
#8
Re: Combo Box Styles
Here's an (almost) cut-n-past of your code:
Code:
HWND hvComboBox1,hvComboBox2,hvComboBox3;
HINSTANCE hInst=AfxGetInstanceHandle();
hvComboBox1 = CreateWindowEx(0,WC_COMBOBOX,L"CBS_DROPDOWNLIST",
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | 0x00002000,
60, 62, 250, 100,
m_hWnd,NULL,hInst,NULL);
hvComboBox2 = CreateWindowEx(0,WC_COMBOBOX,L"CBS_DROPDOWN",
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | 0x00002000,
60, 92, 250, 100,
m_hWnd,NULL,hInst,NULL);
hvComboBox3 = CreateWindowEx(0,WC_COMBOBOX,L"CBS_SIMPLE",
WS_CHILD | WS_VISIBLE | CBS_SIMPLE | CBS_HASSTRINGS | WS_VSCROLL | 0x00002000,
60, 122, 250, 100,
m_hWnd,NULL,hInst,NULL);
Gives me this:
-
February 11th, 2010, 05:41 PM
#9
Re: Combo Box Styles
 Originally Posted by THEARTOFWEB
I get a regular combobox, I dont get the third on the left shown in teh picture I posted
Are you talking about its look or its behavior?
The “regular” combobox allows you to edit your entry, while the CBS_DROPDOWNLIST – only to pick from the list.
If you are concerned about the look – this is most likely controlled by your theme and depends on the version of Windows.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
February 13th, 2010, 02:33 PM
#10
Re: Combo Box Styles
 Originally Posted by hoxsiew
Here's an (almost) cut-n-past of your code:
Gives me this:

that is not working for me :-( I am on windows vista...by the way, do you think I should use SetWindowTheme() to force a stlye?
I guess I should turn to different gui libraries like QT or GTK+
-
February 13th, 2010, 03:28 PM
#11
Re: Combo Box Styles
Only if you want to P*ss off your users. They chose the style; the program shouldn't second-guess them.
My capture was from Windows 7 BTW, so it got me thinking that maybe you're not using the right manifest for common controls or something and are stuck with the old windows95 look.
What exactly do you mean by "not working for me"? I assumed you meant that you were getting the wrong behavior from the control, but do you really mean the style doesn't look right?
-
February 13th, 2010, 03:43 PM
#12
Re: Combo Box Styles
 Originally Posted by hoxsiew
My capture was from Windows 7 BTW, so it got me thinking that maybe you're not using the right manifest for common controls or something and are stuck with the old windows95 look.
What exactly do you mean by "not working for me"? I assumed you meant that you were getting the wrong behavior from the control, but do you really mean the style doesn't look right?
Yeah, I am stuck with teh old win95 look. I tried your code and the style looks bad. Here's is an example (shown from ResEdit)

while this is the same create via C++ code using CreateWindowEx for the main window and its single child controls:

How come thru ResEdit I get that style whereas in pure code I don't?
thanks
-
February 13th, 2010, 04:26 PM
#13
Re: Combo Box Styles
Add a manifest dependency for Common controls 6.0 to your stdafx.h file:
Code:
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
-
February 13th, 2010, 05:25 PM
#14
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
|