Windows Mobile Developer Network Forum

Windows Mobile Developer Network Forum
It is currently Fri Jul 30, 2010 2:48 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 

Rate this article
1 0%  0%  [ 0 ]
2 0%  0%  [ 0 ]
3 0%  0%  [ 0 ]
4 0%  0%  [ 0 ]
5 0%  0%  [ 0 ]
Total votes : 0
Author Message
 Post subject: QA: How to create a flat combo box?
PostPosted: Thu Oct 28, 2004 3:12 pm 
Offline
PPCDN Team

Joined: Tue Apr 01, 2003 6:28 pm
Posts: 229
Location: Saint-Petersburg, Russia
<h2>Question</h2> How to create a flat combo box (same as in Pocket Word above the file list and used for selecting sorting order)?
<h2>Answer</h2> Really, the control that Pocket Word uses is not combo box. I.e. there is no style that you can set to combo box and get the same looking control.
One of possible solutions is to create a custom control with similar look and feel. The <a href="samples/DocListComboBox.zip">CDocListComboBox</a> class was developed for such purpose. It is derived from CWnd class and has a custom redefined paint method. This control can be in two states: the normal state when popup menu is not showed and the popup state when the assigned menu is showed.
I will provide some notes about this control using. You can familiarize with this code in a <a href="samples/TestDocListCombo.zip">sample project</a>.
At first you should create the a combo by <i>Create</i> method. In the sample project the following chunk of code responsible for this action:
Code:
m_ctrlDocListCombo.Create(
   TEXT("FlatComboBox"),
   WS_CHILD | WS_VISIBLE,
   CRect(rect.left, rect.top, rect.right, rect.top + 22),
   this,
   1 /*ID*/ );

You should create a menu with items that will be showed when the combo box pops up and set the menu id by invoking SetDropDownMenu() method:
Code:
m_ctrlDocListCombo.SetDropDownMenu(IDR_MYMENUBAR);

Also you should provide two strings that will be displayed in this control. The first one is displayed when the control is in the popup state and the second one when it is not:
Code:
m_ctrlDocListCombo.SetTitleText(TEXT("Show"));
m_ctrlDocListCombo.SetSelectedText(TEXT("Digits"));

Finally you can create the usual message handlers for menu commands.
By using this simple control you will get standard look and feel and you the users of your program will be familiar with this type of control because of similar control widespread in Microsoft products.

_________________
Andrey Yatsyk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group