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
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.
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 .
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.
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.
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
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.
|
|
|
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.
|