|
harsha_1234 wrote: m_wndCombo.SetWindowText("Default");
Drop is not only for the user. Its for you too. If it is drop list, then you could only select what is available. Therefore you need to add a string before you could display it.
Try this:
<br />
m_wndCombo.AddString("Default Value");<br />
harsha_1234 wrote: m_wndCombo.SetWindowText("Default");
Use the CComboBox::SetCurSel() function to set the selection.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
harsha_1234 wrote: i tried with changing it's type to drop list by that way it becomes only selectable but i can not set the default values in that combo box
Use SetCurSel to set currently selected item. You cannot use SetWindowText for this purpose. You can set the initial index of the combo box in OnInitDialog .
|
|
|
|
|
Nibu babu thomas wrote: Maybe in OnInitDialog.
Not even there. SetWindowText refers to the window as a whole. I haven't tried this but in my opinion, it will not set the display value of the combobox.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Not even there. SetWindowText refers to the window as a whole.
When did I say that? You should read carefully before commenting.
|
|
|
|
|
I did not tell you said anything. I said, setwindowtext refers to the window as a whole. It is more abstract and won't set the text value of the current selected item. Your opinion was that it may work in initdialog. I said an am saying it won't even work there!
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Your opinion was that it may work in initdialog.
Wrong! What I meant was that he should use SetCurSel in OnInitDialog .
|
|
|
|
|
Nibu babu thomas wrote: Wrong! What I meant was that he should use SetCurSel in OnInitDialog.
Okay.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
Use
int SetCurSel(
int nSelect
);
or if you already have to selecting by text from list
SelectString(
int nStartAfter,
LPCTSTR lpszString
);
-----------
Mila
|
|
|
|
|
oh thanks
but how can i do this way like if i have a dropdown combo and i want to make the edit control non editable is it possible??
actually i have used CComboBox with dropdown property every where
and till now i was checking the selected text on OnOk but if
now if i want that combo to be dropdown and with non editable edit control !!
is it possible??
Thanks and regards
Harshal
|
|
|
|
|
harsha_1234 wrote: if i have a dropdown combo and i want to make the edit control non editable is it possible??
Why on earth would you need it? Use the drop list style straight away. Handle the CBN_SELCHANGE and that will help you realise selection change in the combo box.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
I don't know why you insist on dropdown style - I think in your case drop list is more proper.
You can try to override CBN_EDITUPDATE message:
"The CBN_EDITUPDATE notification message is sent when the edit control portion of a combo box is about to display altered text. This notification message is sent after the control has formatted the text, but before it displays the text."
-----------
Mila
|
|
|
|
|
harsha_1234 wrote: i have a combo box whose type is dropdown and i want that it should be only
selectable i mean user should not be able to edit in that combo box.
You can't. By using the CBS_DROPDOWN or CBS_SIMPLE style, there will be an edit control as part of the combobox. If you do not want this, you must use the CBS_DROPDOWNLIST style instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I am new to C++ and MFC.I am creating a zoom application(dialog based application) using VC++ in VS2005. While invoking this application, it will zoom whatever screen appears in the screen. I have a problem now. I am opening a modal dialog created in another application, When I tried to invoke the zoom application(which is also a dialog), it closes the previously opened dialog(opened by the another application).
Please clarify how to resolve this issue. I understand that the dialog
opened by the other application receives some message and got closed,
while invoking the zoom application. Please help me to retain that
dialog also while opening the zoom application.
Thanks in advance.
Sri
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
How can we give shaded background color to our GUI.
Means form upperside some dark color and when we moved to bottom
the darkness of the color to be reduced and turned to as light color.
How can i do it?
|
|
|
|
|
kiranin wrote: GUI.
How vague. GUI means a dialog? Read This article[^]
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Thank you Brahmma, Now i want change the same color to caption bar and border also....
Is it possible?
-- modified at 6:22 Tuesday 28th November, 2006
|
|
|
|
|
they are all classes inheriting from CWnd.
so your own class for each, inheriting from the class you want to modify, overload the right function, and that's it...
|
|
|
|
|
The SetProcessDefaultLayout function changes the default layout when windows are created with no parent or owner only for the currently running process. -by MSDN-
In my case, i already used SetProcessDefaultLayout to change the default layout of my windows, the problems is that child windows ( for example a dialog wich shows the Police ) don't respect the layout of it's parent.
Is there an idea ?
|
|
|
|
|
I want to invert bitmap thro 180 degree and want to display it into dialog box.
please suggest me something.
Thank you.
There Is Nothing Right & Wrong
|
|
|
|
|
abhijit bhopale wrote: I want to invert bitmap thro 180 degree
Invert or rotate?
abhijit bhopale wrote: There Is Nothing Right & Wrong
Actually, there is.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Thank u..
Rotate.
There Is Nothing Right & Wrong
|
|
|
|
|
I'm coding in C++, but just using basic C++ libraries (ie. not MFC or WTL etc.).
I would like to know if there is a more elegant/better way to do what I have coded below, just to learn something.
Basically, given a "code" I want to verify that each "digit" is Octal (ie. 0-7), and that the "code" is exactly 4 characters.
I'm using this as an opportunity for a "code review" by you peers to see if I can learn something.
bool Xpdr::IsValidCode(const wchar_t* code)
{
// Has 4 numeric digits
if (wcslen(code) != 4)
{
return false; // Code MUST be 4 digits
}
for (int i=0; i<4; i++)
{
// Check each digit is octal
if (code[i] < 0x30 || code[i] > 0x37)
{
return false; // Code digits must be 0 - 7
}
}
return true;
}
Thanks for your thoughts on how to make this better / more efficient.
|
|
|
|
|
I think a possible alternative solution is:
bool Xpdr::IsValidCode(const wchar_t * code) const
{
for( int i = 0; i < 4; ++i, ++code)
{
if( *code < '0' || *code > '7')
{
return false;
}
}
return *code == 0;
}
I hope this works. In addition you can "unroll" this short loop and replace it with a series of "if"-s and autoincremented code pointer.
-- modified at 5:47 Tuesday 28th November, 2006
|
|
|
|
|
Ah, very interesting. Nice touch verifying that there is a terminating NULL.
By unroll are you meaning something like this:
bool Xpdr::IsValidCode(const wchar_t * code) const
{
if( *code < '0' || *code > '7') { return false; }
code++;
if( *code < '0' || *code > '7') { return false; }
code++;
if( *code < '0' || *code > '7') { return false; }
code++;
if( *code < '0' || *code > '7') { return false; }
return *code == 0;
}
|
|
|
|