|
I dont want to use the dropdownlist because in my application based on the combobox selection another combo box has to be populated with the first combobox seleted item.
EX: if i click "alphabets"
i have to set the other combobox to this value,
and i am not able to use the m_combobox2.setwindowtext() and also
SetDlgItemText(idc_combobox2,"string");
|
|
|
|
|
Try using SelectString instead of trying to set the text area directly.
Judy
|
|
|
|
|
tried but thats not working properly...
|
|
|
|
|
Possible you've to try better.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As CPallini implies, the function does work correctly. You've done something wrong.
What does "it doesn't work" mean - with no code, we can't guess. Does the string you're trying to set exist in the second combo box?
Judy
|
|
|
|
|
I dont want to use the dropdownlist because in my application based on the combobox selection another combo box has to be populated with the first combobox seleted item.
EX: if i click "alphabets"
i have to set the other combobox to this value,
and i am not able to use the m_combobox2.setwindowtext() and also
SetDlgItemText(idc_combobox2,"string"); if i use the dropdownlist
|
|
|
|
|
Hi i am new to the concepts of mfc..
in my application i want to change the backgroung color of the button through ctlcolor for that i am ticking the option owner draw for the button.when i try to run the application i am getting abort error..
can anybody please suggest me the reason for this???
Thanks in advance...
|
|
|
|
|
hariakuthota wrote: can anybody please suggest me the reason for this???
The debugger can (for free!).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: The debugger can (for free!)
Who is that guy? Does he make house calls?
|
|
|
|
|
Luc Pattyn wrote: Who is that guy?
Girl my friend, girl. And it's lovely to have a break with her (or simply a watch).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Aha. That could be the reason why people tend to spend so much time debugging...
But then I wonder why they ask for help on sites like this one
|
|
|
|
|
Possibly because girls drive you crazy, after a while...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can any one help me to truncate the string based on the buffer size, for the below show scenario.
main()
{
int size = 50;
char errmsg [size];
get_last_error( errmsg, size );
cout<<errmsg;
}
get_last_error( char *errmsg, int bufsize )
{
string sErrMsg;
if ( sErrMsg.capacity() > bufsize )
{
// here i want to truncate the string, so that the size of string will fit into "bufsize". Then copy the string to errmsg
// strcpy( errmsg, sErrMsg.c_str() );
// how to truncate the string based on given buffersize
// so that we can atlest copy the possible string to errmsg if not the whole string
}
else
{
strcpy( errmsg, sErrMsg.c_str() );
*errcode = nErrCode;
}
}
|
|
|
|
|
Nandu_77b wrote: // how to truncate the string based on given buffersize
How about the substr() method?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Nandu_77b wrote:
// how to truncate the string based on given buffersize
How about the substr() method?
substr() this fun will not take buffer size, it takes length of characters. I need to truncate based on buffer size. Please see my code which will give you clear idea.
-Nandu
|
|
|
|
|
If the size of your buffer is 50, then you would extract characters 0-49.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What about strncpy [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
strncpy() will also take char length not the buffersize.
- Nandu
|
|
|
|
|
--strncpy() will also take char length not the buffersize.
- Nandu
|
|
|
|
|
Are you aware that, for ANSI strings, the char length and the buffer size (bytes) are basically the same?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes you are correct,
Thanks
Nandu
|
|
|
|
|
lstrcpynA(errmsg, bufsize);
If using TCHAR, do:
<br />
lstrcpyn(errmsg, bufsize / sizeof(TCHAR));
(lstrcpyn is a tiny bit more efficient than strncpy since it doesn't fill the rest of the buffer with zeros after completing the copy. With large buffers, this is generally a waste of cycles.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
I have created an SDI application with tabbed view. I have used view class derived from CTabView (class from MFC Feature Pack). I want to show different toolbars on the MainFrame for each tab and alternately change the toolbars when the tab selection is changed. But i have problems with swithching the toolbars. Is there any way to switch the toolbars or associate a custom toolbar for each tab of the view?
Thanks
|
|
|
|
|
Dear All,
I have two classes Test and Test1. I have a static variable in the class Test and I have to access it in another class Test1 from a funtion. When I access it, I got linker error. The error is :
1>Test1.obj : error LNK2001: unresolved external symbol "public: static int Test::cnt" (?cnt@Test@@2HA)
1>Test.obj : error LNK2001: unresolved external symbol "public: static int Test::cnt" (?cnt@Test@@2HA)
Code snippet :
class Test : public CDialog,public CDemux
{
DECLARE_DYNAMIC(DecodeTS)
Public
static int cnt;
.......
void Test1::GetData()
{
int cnt =Test::cnt;
}
|
|
|
|
|
This is a known quirk in C++: For static variables in a class, you need to repeat the declaration in the .cpp file.
So add this:
int Test1::cnt;
to your .cpp file and it will stop this linker error.
|
|
|
|