sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
sachin30's Avatar

combobox property in MFC


Question posted by: sachin30 (Newbie) on August 21st, 2008 09:21 AM
A combobox having property DropDown .

i want change this property to Droplist and back to Dropdown depending upon

a situation .

i use the function modifyStyle() but it not working.

can any body help me ?
thanks in advance
Sachin
6 Answers Posted
Banfa's Avatar
Banfa August 21st, 2008 10:57 AM
AdministratorVoR - 5,253 Posts
#2: Re: combobox property in MFC

I do not believe you can make this style change once the combo box has been created because I think that the box actually has to be created in the correct manor.

There are a number of styles that are fixed at the time the control is created and I think this is one of them.

To get the functionality you want rather than changing the style try destroying the combo box and re-creating it with the new list style.
sachin30's Avatar
sachin30 August 21st, 2008 01:49 PM
Newbie - 14 Posts
#3: Re: combobox property in MFC

yeah ..

i try for that ...


my code is

void save::OnBnClickedButton1()

{
RECT windowExtents;
combobox.GetWindowRect(&windowExtents);
combobox.DestroyWindow();
combobox.Create(WS_EX_NOPARENTNOTIFY|WS_CHILD|WS_V ISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST,windowExtents,t his,1);
combobox.ShowWindow(SW_SHOW|SW_SHOWNORMAL);
}

if i do this way then my combobox is gone .
Banfa's Avatar
Banfa August 21st, 2008 02:18 PM
AdministratorVoR - 5,253 Posts
#4: Re: combobox property in MFC

This is because combobox.GetWindowRect returns the combo boxes top left and bottom right corner co-ordinates in screen coordinates but combobox.Create expects the top left of the combo box plus is size and width defined in client co-ordinates of the parent dialogue.

You will have to process the co-ordinates returned by combobox.GetWindowRect before passing them to combobox.Create probably using DialogBox.ScreenToClient.
sachin30's Avatar
sachin30 August 21st, 2008 02:47 PM
Newbie - 14 Posts
#5: Re: combobox property in MFC

ok i will try fir that one more thing is that

i am passing "this" pointer to combobox.Create() function.

before that i am calling combobox.DestroyWindow(); method

and this change my "this" pointer content .

this is might be one reason that ?

is any way to preserve "this" pointer.
sachin30's Avatar
sachin30 August 22nd, 2008 09:23 AM
Newbie - 14 Posts
#6: Re: combobox property in MFC

Quote:
Originally Posted by Banfa
This is because combobox.GetWindowRect returns the combo boxes top left and bottom right corner co-ordinates in screen coordinates but combobox.Create expects the top left of the combo box plus is size and width defined in client co-ordinates of the parent dialogue.

You will have to process the co-ordinates returned by combobox.GetWindowRect before passing them to combobox.Create probably using DialogBox.ScreenToClient.


yeah ..

its working properly

but only problem is that after we convert combobox style from droplist to dropdown and try to insert any text inside it text is BOLD form and font size is also big

is any way to reduce this problem
Banfa's Avatar
Banfa August 22nd, 2008 10:25 AM
AdministratorVoR - 5,253 Posts
#7: Re: combobox property in MFC

Quote:
Originally Posted by sachin30
but only problem is that after we convert combobox style from droplist to dropdown and try to insert any text inside it text is BOLD form and font size is also big
Erm, now that is just wierd. If you look there should be a way to set the font for a control you could try that.
Reply
Not the answer you were looking for? Post your question . . .
197,049 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,049 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top C / C++ Contributors