|
What about The Documentation?
And other resources?
.
|
|
|
|
|
I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this.
Thanks in advance.
|
|
|
|
|
To display some existing (in the combo listbox) item use CComboBox::SetCurSel.
To display some arbitrary text you could use SetWindowText method.
|
|
|
|
|
Thanks for replying.
Yes, I've tried using SetWindowText method. It's not showing in the combo box.
What I wanted was when I start my application it shows something like "please select something" before I select anything.
For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this.
Thanks again.
|
|
|
|
|
Member 14575556 wrote:
What I wanted was when I start my application it shows something like "please select something" before I select anything. Are you doing something like:
m_list.AddString(_T("Item 1"));
m_list.AddString(_T("Item 2"));
m_list.AddString(_T("Item 3"));
m_list.AddString(_T("Item 4"));
m_list.InsertItem(0, _T("please select something"));
...
m_list.SetCurSel(0);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Member 14575556 wrote: Yes, I've tried using SetWindowText method. It's not showing in the combo box.
It does work for me.
Perhaps, you used DropdownList combo?
|
|
|
|
|
Victor Nijegorodov wrote:
Perhaps, you used DropdownList combo? Is that an MFC control?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes. I meant the MFC combobox with CBS_DROPDOWNLIST style.
|
|
|
|
|
Yes, I used MFC combobox with CBS_DROPDOWNLIST style.
|
|
|
|
|
Member 14575556 wrote: Yes, I used MFC combobox with CBS_DROPDOWNLIST style.
Then you will only able to display a string already inserted in the combo listbox. Use either CComboBox::SelectString or CComboBox::SetCurSel.
|
|
|
|
|
|
Thank you. This really match with what I wanted to do.
|
|
|
|
|
You are welcome. It always pays to check the documentation first.
|
|
|
|
|
I come back for another strange error (for me is strange ):
error C2143: syntax error : missing ')' before '{'
And the lin with error is:
TestAndClearDirty(ni);
and TestAndClearDirty is declared as:
#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)
where test_and_clear(ni, Name) is defined as:
#define test_and_clear(ni, flag) \
test_and_clear_bit(NI_##flag, (ni)->state)
and clear_bit is declared as:
#define test_and_clear_bit(bit, var) \
({ \
const BOOL old_state = test_bit(bit, var); \
clear_bit(bit, var); \
old_state; \
})
How to get rid of this error ?
modified 10-Oct-19 12:11pm.
|
|
|
|
|
Once again there is information missing. I have tried putting those definitions in the correct order and compiling but it produces too many errors and unknown names.
|
|
|
|
|
You might try to get rid of those ugly macros (you are using C++, right?).
|
|
|
|
|
In fact is a C code which I try to convert to C++. I will try to call directly these functions ... I guess that you said, I am right ?
|
|
|
|
|
Yes, but I don't know if I can, because from step TestAndClearDirty(ni); to test_and_clear(ni, Name) , the second paramter is missing (see the first post).
Moreover, at step test_and_clear_bit(NI_##flag, (ni)->state) what is the first parameter ?
modified 11-Oct-19 6:44am.
|
|
|
|
|
That is exactly the problem. We do not have that information and you are not providing it.
|
|
|
|
|
Believe me, I haven't extra information, for instance, at step test_and_clear(ni, Name) , when I try to go to definition of Name , VS editor goes nowhere, searched globally in the whole project, found nothing, and searched in the entire project folder with the external file seeker, found no defintion of this Name parameter ...
|
|
|
|
|
In the following macro Name refers to something outside of the definition:
#define TestAndClearDirty(ni) \
test_and_clear(ni, Name)
But if Name does not exist in that source module, or is not externalised in a linked module it will never work. My suspicion is that this macro is wrong and Name should be one of the formal parameters, and refer to one of the flags in the ni struct. Something like:
#define TestAndClearDirty(ni, Name) \
test_and_clear(ni, Name)
And it would be called by
TestAndClearDirty(ni, some_falg_name);
But I am working completely in the dark and making (probably wild) guesses.
I can only suggest that you go back to the place or person that this code comes from for assistance.
|
|
|
|
|
I have discovered something: if I write:
TestAndClearDirty(ni);
everything is ok. But if I write:
BOOL b = TestAndClearDirty(ni);
I get errors:
error C2552: 'b' : non-aggregates cannot be initialized with initializer list
error C2143: syntax error : missing '}' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2143: syntax error : missing ';' before 'const'
error C2065: 'old_state' : undeclared identifier
See first post for original definition ... I hope I can make it ...
P.S. Why I written BOOL b = ... ? Because that function, TestAndClearDirty , is used inside some if condition ...
|
|
|
|
|
Once again there is considerable context missing. And it seems you have also removed all the macro definitions from your earlier post.
|
|
|
|
|
test_and_clear is a macro you can't use it as a function, macros don't return things without hijinx
GCC has a thing called a statement expression
Using the GNU Compiler Collection (GCC): Statement Exprs[^]
However I strong suggestly you don't do it just create a proper function (that is after all what you are trying to write) and inline it if speed is an issue.
In vino veritas
|
|
|
|
|
_Flaviu wrote:
How to get rid of this error ? Anytime you are having preprocessor troubles, the only solution is to send the output of the preprocessor to a text file using the /P compiler switch. Only then will you be able to see what exactly is being sent through the compiler.
See here for more.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|