Size of the drowpdow list of a combo box

Below is my attempt at creating a combo box. The item is correctly
displayed, but the dropdown list has a size of zero. How can I change this
so I can see the options?
Thanks for your help.

Miguel


 HWND hWnd = GetSafeHwnd();
  CWnd *dialog = CWnd::FromHandle(hWnd);
  RECT ctlRect;
  ctlRect.left = 130;
  ctlRect.top = 50;
  ctlRect.right = 220;
  ctlRect.bottom = 80;
  outputVolumeCB = new CComboBox();
  ret =
outputVolumeCB->Create(WS_VSCROLL|CBS_DROPDOWN|CBS_DISABLENOSCROLL|CBS_HASST
RINGS,ctlRect,dialog,102);
  outputVolumeCB->ShowWindow(SW_SHOW);
  outputVolumeCB->AddString("Y - Brief");
  outputVolumeCB->AddString("N - Full");
  outputVolumeCB->AddString("L - Medium");
  outputVolumeCB->SetCurSel(1);




0
mcorazao (18)
8/13/2004 4:20:04 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
802 Views

Similar Articles

[PageSpeed] 40

Miguel Corazao wrote:
> Below is my attempt at creating a combo box. The item is correctly
> displayed, but the dropdown list has a size of zero. How can I change this
> so I can see the options?
> Thanks for your help.
> 
> Miguel
> 
> 
>  HWND hWnd = GetSafeHwnd();
>   CWnd *dialog = CWnd::FromHandle(hWnd);
>   RECT ctlRect;
>   ctlRect.left = 130;
>   ctlRect.top = 50;
>   ctlRect.right = 220;
>   ctlRect.bottom = 80;
>   outputVolumeCB = new CComboBox();
>   ret =
> outputVolumeCB->Create(WS_VSCROLL|CBS_DROPDOWN|CBS_DISABLENOSCROLL|CBS_HASST
> RINGS,ctlRect,dialog,102);
>   outputVolumeCB->ShowWindow(SW_SHOW);
>   outputVolumeCB->AddString("Y - Brief");
>   outputVolumeCB->AddString("N - Full");
>   outputVolumeCB->AddString("L - Medium");
>   outputVolumeCB->SetCurSel(1);
> 
> 
> 
> 

It's been a while since I've done it that way, but I think Windows uses 
the height you pass in to the combobox to determine the dropdown height. 
  You passed in a height of 30 (80-50).  The "average" height of a 
control on a default Windows setup is ~25.  So, that leaves you with 
about 5 pixels to display your dropdown.  Change your height and it will 
work.

ctlRect.left = 130;
ctlRect.top = 50;
ctlRect.right = 220;
ctlRect.bottom = 100; // for starters..recompile and see how it affects 
the height.
0
trevor8686 (35)
8/13/2004 9:03:28 PM
First, there is always a question as to why it is necessary to create a control at
runtime. THere are lots and lots of very good reasons, and a near-infinite number of
really bad reasons. 

Assuming you have a good reason, then you should eliminate every one of those numbers.
What does "130" mean? Nothing. It means 130 pixels from the left edge, in some resolution,
for some display driver. It is a completely meaningless number. Likewise, 50, 220, and 80
are all nonsense numbers. If they happen to work this week, on your machine, with the
current video driver and display, you win. For every other machine in the known Universe,
you can assume they are wrong. 

The 102 is a meaningless number. Why do you think 102 is available as a control ID? Given
that you know the coordinates and the control ID, it looks like this is one of those
places where the only reasons for creating the control at runtime are bad reasons, so
perhaps you should reconsider why you are doing this at runtime.

Given you have done this, you have no way to couple the control to any handler functions.
There is even a serious question as to why you need to do a 'new' to create a combo box at
a fixed place; simply declaring a member variable would do the job.

You are also hardwiring constant strings into the program, which is another bad idea.

You might want to check out my dynamically-resizing combo box from my MVP Tips site, or my
CIDCombo box class, which dynamically adjusts the size of the combo box.

Why are you doing GetSafeHwnd() and CWnd::FromHandle when 'this' would have sufficed for
the same purpose? 

What I see here are ten lines of code that probably don't need to exist, and three which
are not well-structured, and one which is almost certainly incorrect (why SetCurSel(1)?
What makes you assume that 1 is the right value?)

Read my essays on combo boxes, and most of my "Dialog Box" series, so you can avoid doing
things like this. The code should take two lines. One to load all the values, and one to
select a specific value NOT by its position. I would do this as

in the class definition for what I'm going to call CMyDialog:
	CIDCombo outputVolumeCB; // from the CComboBox outputVolumeCB declaration
                                                                            // added by
ClassWizard

	typedef enum {Brief, Full} outputVolume;

static const IDData values[] = {
    { IDS_BRIEF, CMyDialog::Brief }.
    { IDS_FULL, CMyDialog::Full}
    {0, NULL }
};

BOOL CMyDialog::OnInitDialog()
    {
      ...
      outputVolume.LoadValues(values);
      outputVolume.Select(Full);
     ....
    }

(I may have misremembered the exact method names of my class, but you get the idea)

This will resize the combo box each time, and it is independent of knowing the control
IDs, dimensions, etc.
					joe



On Fri, 13 Aug 2004 16:20:04 GMT, "Miguel Corazao" <mcorazao@cwbeilfuss.com> wrote:

>Below is my attempt at creating a combo box. The item is correctly
>displayed, but the dropdown list has a size of zero. How can I change this
>so I can see the options?
>Thanks for your help.
>
>Miguel
>
>
> HWND hWnd = GetSafeHwnd();
>  CWnd *dialog = CWnd::FromHandle(hWnd);
>  RECT ctlRect;
>  ctlRect.left = 130;
>  ctlRect.top = 50;
>  ctlRect.right = 220;
>  ctlRect.bottom = 80;
>  outputVolumeCB = new CComboBox();
>  ret =
>outputVolumeCB->Create(WS_VSCROLL|CBS_DROPDOWN|CBS_DISABLENOSCROLL|CBS_HASST
>RINGS,ctlRect,dialog,102);
>  outputVolumeCB->ShowWindow(SW_SHOW);
>  outputVolumeCB->AddString("Y - Brief");
>  outputVolumeCB->AddString("N - Full");
>  outputVolumeCB->AddString("L - Medium");
>  outputVolumeCB->SetCurSel(1);
>
>
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15973)
8/15/2004 12:07:53 AM
Reply:

Similar Artilces:

Distribution List #26
I created a distrubtion list called user group. I then changed the smtp address to something else so user's outside the company will be able to send email as ugab@company.com. The other addresses X400, MS, and CCMail addresses are stil referencing the group name. Should I changed these as well to reflect the actual address. The information in CCMAIL is as follws: Mailbox=usergroup Post Office=domain The information in MS Network Name: Messaging Postoffice Name: Domain Mailbox name: usergroup The information in X400 surname(s): usergroup organization(o) Domain PRMDC(p)= Messa...

Page Size Sheet Size Not The Same
Hi - I'm having trouble with printing in Publisher 2007. I have a 5.5x8.5 page size and I want to print that size paper. I've tried to set the sheet to custom size in the printer setup, but Publisher still want a 5.5x8.5 Publisher size printing on a full 8.5x11 sheet. I don't get it. I never had this problem with the Publisher 2003 or anyother MS product including the other Office 2007 programs. Can anyone help clue me in? Even if I create a document as 5.5x8.5 size it will publish a 8.5x11 .pdf file. Please Help! Jerry The new Publisher page setup is not user friendly. ...

Drop down box with country list #2
Thanks Bob, however what I want is a dropdown which we can find in the web site applications (e.g. airways ticketing) where we can use choose a country using the drop down with a complete list of world's countries. In Data Validation method, I have to re-type all the possible country's names. John. Bob Phillips Wrote: > Enter the countries in a range (say column M) and then add a Data > Validation > (DataValidation) and select the List option with a formula of say > =M1:M100 > or however many countries > > -- > HTH > > Bob Phillips > > "jo...

Drop Down Boxes #3
Ignore my last post go the answer "data validation" thx. ...

Need example on Virtual List Control
I need an excellent example on a virtual list control that utilizes sorting and retrieving item(s). Refer VListVw sample (under platform sdk samples) in MSDN "Precioso Vinzon" <anonymous@discussions.microsoft.com> wrote in message news:085f01c3a125$2fdb9f10$a601280a@phx.gbl... > I need an excellent example on a virtual list control > that utilizes sorting and retrieving item(s). > ...

can not see all entries in Global Address list
I have a user who can not see all the items in the Global Address list. Why would that be? Could be a few things. What do they see? Are they missing one or two new entries? If so, are they using Outlook 2003? By default, this uses an offline address book which means the OAB will need to be rebuilt and downloaded to see the new entries. The rebuild happens once a day by default, but it can be forced via ESM. -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.msexchangeblog.com "Pearl" <Pearl@discussions.microsoft.com> wrote in message ...

Screen Size
Dear All, I don't know if anyone can help but when I compose a message, the view of the message is huge! The font looks as though it's size 20 and it's driving me absoultely mad...... However, the emails in my sent / deleted files are normal size. Does anyone know why the view is so huge on my composing view and how I can get it back to normal? I've tried everything to no avail..... Many thanks! Sarah Grange, you wrote on Tue, 7 Oct 2008 02:05:00 -0700: > I don't know if anyone can help but when I compose a message, the view of > the message is huge! ...

text box to contain formulae results that recalculate
As I said before: this is an off day. Sorry for posting 15 minutes ago without subject. ------------------------------------------------------------------------------------------------------------------------ Hi all, I want a text box on my worksheet to contain the results of the formulae that are in DW42 to DW47 and have them (I mean those in the text box) recalculated with the worksheet. What code do I have to use? Jack Sons The Netherlands Try this ... In a "helper cell" do a formula to collect the desired contents of the Text Box, e.g. =DW42&CHAR(10)&"A bit ...

Mailbox size
Hi, for some time i noticde that my live mail doesn't receive new messages unless i delete some old messages. i would leik to know if ther eis a maximum mailbox size in Live Mail. thank you. The mail box capacity is controlled by your isp. Check your account in the web interface to ensure you have not maxed out = your isp limit for your account If your account in WLM and a prior email client is/was configured to = never delete from the server, you may have over an extended=20 period of time reached your limit -- ....winston ms-mvp mail "Mirogzy" wrote...

Global Address List per Mail Domain
Hi! I host multiple domains on my Exchange 2003 server. I created new Global Address Lists in ESM for each mail domain: for example GAL for abc.com, and GAL for xyz.com. I want that the users who belong to domain abc.com should see ONLY and ONLY their own GAL, NOT the GAL for xyz.com. And users who belong to domain xyz.com should see only and only their own GAL. How can I realize it? Where should I restrict the permissions? Which permissions for whom? Best Regards Mustafa Have a look at this KB article How to Manage Address Lists When You Host Virtual Organizations http://support.micr...

Deactivated Leads and Marketing Lists
It seems like CRM should remove deactivated Leads from any Marketing Lists on which the Lead is a member. Likewise with Accounts that are deactivated. Or am I missing something? - Steve Yates - ITS, Inc. - Old Virus Detected, Contact Hacker For Update (Y/N) ~ Taglines by Taglinator - www.srtware.com ~ The record remains in the list when it is deactivated unless you remove it or update the list memebers using 'Active' as a query criteria. However if you conduct a marketing activity to the list members any inactive records will be ignored and you will see them on the ...

Exporting Supplier List
Hi, I am using Microsoft Money 2002 personal and business edition. Is it possible to export the supplier list to excel. In addition, is is possible to export the sale items to excel. If this is not possible, is the export feature available in later version of MS money? Cheers Hani ...

Need to eliminate a Password change dialog box that appears when u
When a user goes to login to the exchange server VIA the web. When Entering in user/pass a message box appears stating that the password they are using is about to expire. You have 0 day's to change. Then it tell the user to go to Options to change the current password. How I do I eliminate this message? Also what caused this message to be displayed all of a sudden. Thanks for you time. Marcus On Wed, 13 Oct 2004 06:47:05 -0700, Marcus Feldmore <MarcusFeldmore@discussions.microsoft.com> wrote: >When a user goes to login to the exchange server VIA the web. When Entering &g...

excel 2007_need to add spacing between fields for mailing list
Subject describes the concern. 2007 Word displays labels ok, but the spacing between the fields needs to be increased. Still a newbie at using this suite. Thanks for replies. Increase row height?? -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "GGG_SD" <GGG_SD@discussions.microsoft.com> wrote in message news:11A574DE-F7D2-4B6E-9F26-11415A627950@microsoft.com... > Subject describes the concern. 2007 Word displays labels ok, but the > spacing > between the fields needs to be increased. Still a newbie at using this > suite. ...

speed up mailbox size increases
we have an AD structure with a NLB EXCH 2003 FE and a clustered 2003 BE. We have a developed application that manages mailboxes, assigns the mailbox quota, and manages the email addresses. If a user asks for a larger mailbox quota, we change it within the application, and the application immediately changes it in AD. Unfortunately it seems like quite a lengthy process between when AD knows about the change and the Exchange server starts to act on the new quota amount. Is there a way I can tweak either AD or Exchange so that the changes occur on a more regular basis. Typically it tak...

How do I increase font size in the reading pane in Outlook 2007?
Previous versions had a command button to cycle through font sizes tiny > small > normal > big > tiny > ... The nearest I can get in Outlook 2007 is to open the received email in edit mode and then select all and then choose a font size via a font dialog. Silicon.Com sends a weekly newsletter out in HTML using a very small font, which I need to enlarge for comfortable reading. Surely I've missed a very simple command button, but searching local and on-line help for "increase font size" etc. brings no help. ...

Backup file size
I run a script to backup my databases. The critical lines of code are: OSQL -U sa -P password -S ServerName -Q "BACKUP DATABASE StoreOps TO DISK = 'C:\RMS Backup\DailyBackup1.bck' WITH FORMAT, STATS And a second line just like the first for database HQ and filename DailyHQBackup.bck The files generated are 107MB (Store Ops) and 196MB (HQ). Recently I executed a 'no going back' query so I manually backed up my database. I don't normally check the file size when I do this sort ofthing, but last night my backup media (DVD-RW) ran out of space... The HQ Admin-ge...

not on list
I have a form "frmEntry" based off of a table that has several relationships. 4 combo boxes based off of queries so that I can select a product, dock code ect. if a product is not on the list in the drop down box I have a button on the form to open up frmProductEntry so I can add a new product to my tblProducts. Problem, how do I get my combo box to update without having to close my frmEntry form. I tried to add a refresh button but I have a VB on the TicketNo field for when a duplicate TicketNo is entered and it won't work properly. Here is that VB Private Sub TicketNo_...

Excel file very large in size?
I have made excel workbook with 10 sheets. It is simple and has one sheet with graph, and also 4 pictures of size 300Kb. Why excel file is over 3100 Kb in size, or this is ok? Thanks in advance Marc Excel is noted for over-estimating the actual used range on a sheet. See Debra Dalgleish's site for info and instructions for resetting. http://www.contextures.on.ca/xlfaqApp.html#Unused Gord Dibben Excel MVP On Mon, 25 Apr 2005 22:37:45 +0200, "Marc" <marc5@hotmail.com> wrote: >I have made excel workbook with 10 sheets. It is simple and has one sheet >with gra...

Refresh problem for the size grip with Windows XP style
Hi, We have an dialog application with a scrollbar size grip. On Windows XP with visual style, there is a refresh problem for the size grip region. Without the XP style, everything is OK. I have noticed the same behavior with Notepad. Any ideas will be appreciated, Thanks ...

priv1.edb still has large size even no mailbox on it
Dear all, I have an Exchange 2000 mailbox store on W2K SP4 which has priv1.edb file size is 27 GB. Last month I create new mailbox store with the database name is priv2.edb and move the mailbox on the old mailbox store to the new one. But after there is no mailbox anymore on the old mailbox store, I wonder because priv1.edb file size still have the same size. Please help. Thanks. regards, Nita A priv.edb file will not dynamically shrink when you delete or move mailboxes from it. If you want to recover the saved space immediately you will need to run eseutil in defrag mode to compact...

Exchange 5.5 import/export of mailbox size limits
I need to do an import/export of an Ex5.5 directory that would change the mailboxes size limits. Basically, I need to replace whatever is in the Issue Warning Prohibit Send Prohibit send and Receive .... account fields, and change these "manually" via a spreadsheet. I have several 100's of these to do and would like to do it via a CSV file in the Exchange admin export/import. What should the header of csv file be ? obj-class,directory name,Issue Warning?,Prohibit Send? Prohibit Send Receive? Thank You, SRP 2 of the column headers will be: Issue warning storage limit...

Text box default value
I wish to establish a new default value for a text box - based on what the user entered. How I do that in VBA? <identification of default default value entry> = <whatever the user entered> I can handle the second part, but.... "news2@rgcle.com" <news2@rgcle.com> wrote in message <L62dnWMjTYBXj7zbnZ2dnUVZ_s2vnZ2d@comcast.com>: > I wish to establish a new default value for a text box - based on > what the user entered. How I do that in VBA? > > <identification of default default value entry> = <whatever the user > entered> > &g...

ToolTip problem in a child dialog box
Hi I am using MS VC 6.0 and Vista. I have a dialog box containing a CTabCtrl control. I put a child dialog box for each tab. In each child dialog box, I put a number of controls (CEdit...). For each control, I specify a tooltip. So far, so good. Here is my problem: In Debug mode (not in Release mode), after the tooltip appears, if I move the mouse so that the cursor enters the tooltip area (before the tooltip disappears), I get ASSERT(::IsWindow(m_hWnd)); in wincore.cpp. It is my understanding that the program is looking for a tooltip for the tooltip, and that the tooltip is not recognized ...

Remove Message Size Limiter
Dear All, im getting bounces to my exchanger server due to attachment size. Mail in question is a 5Mb message (Becomes 6.8 when in message format) commining from a hotmail account. I Know it isnt a Hotmail limitation, as ive sent the message to another organisations EX server. I need there to be absoloutly NO limitations within exchange AT ALL for the sending receiving or delivery of mail. I have been through exchange with a fine tooth comb and cannot find any such restrictors but im obviously missing somthing ive also checked the AD account in question to see if a limit has been plac...