|
Debug and trace through to see what index is on the Last Item. GetCurSel() will return LB_ERR (usually -1) if nothing is selected.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
HI
My problem is my combobox contains nitems. Iam deleting each item using below code, Comobo List also getting updated according to that,means that item is getting deleted. Last item also iam able delete from Combobox List using below code.
int index = m_CtrlCmb.GetCurSel();
m_CtrlCmb.DeleteString(index);
But my problem is Last item in the combobox getting deleted from Combo List but displaying in the combobox,means that item i need to delete manually.
I couldnt trace By Debugging, Plz Help.
|
|
|
|
|
Are you trying to delete all items in the combobox? Are you using MFC?
If so, call:
m_CtrlCmb.ResetContent();
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
HI Steve,
Thanks for your help
Iam able to fix this issue
using this code
int Count1 = m_CtrlCmb.GetCount();
if(Count1 == 0)
{
m_CtrlCmb.ResetContent();
}
Thanks,
Preeti
|
|
|
|
|
Preethi_123 wrote: int Count1 = m_CtrlCmb.GetCount();
if(Count1 == 0)
{
m_CtrlCmb.ResetContent();
}
How does it work??
I mean you are deleting when count is 0? does n't it mean that there are no contents?? Or is it a typo??
Regards,
Sandip.
|
|
|
|
|
Or m_CtrlCmb.SetCurSel(-1);
Lookup documentation on CComboBox on MSDN.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Why would you want to delete an empty combobox?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Does ResetContent delete all the pointers added with SetItemData?
|
|
|
|
|
The ItemData is just a DWORD associated with each item. The combo box doesn't use it in anyway, so it's up to you to clean up any memory you allocate.
You could loop through all your items and delete the pointers, then call ResetContent.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
|
Hi all,
I'm trying convert "D:\Documents\delay.txt" to "D:\\Documents\\delay.txt". Anybody can help me?
Thank so much!
|
|
|
|
|
Why? Escaping is handled at compile time, not runtime.
But, depending on your platform, most of the string classes have a replace function.
MFC:
CString string1("D:\\Documents\\delay.txt");
string1.Replace("\\", "\\\\");
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
char *strFilePath = new char[1024];
strFilePath = "D:\Documents\delay.txt";
So, how to replay('\','\\'). I'm used C language.
|
|
|
|
|
Try:
strcpy(strFilePath, "D:\\Documents\\delay.txt");
You need the double backslashes \\ in your string literal, because \ is the escape character, so the compiler is translating what you wrote as \D and \d. Lookup "C escape sequences" on google.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Hi you can use strchr method in recursive order which will give u the "\" location. you have to just replace it as "\\"
I think this is what looking for.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
the good question is "why do you need to do this ?"...
I suspect a dark reason which is in fact because you're trying to hack something because you don't actually understand that string escaping is useful only in your source code...
if you're getting the string from an external source (input, textbox, open file dialog), the string you get is already good.
you need to escape \ into \\ only in your source code, because if you don't, the \ character will try to escape the character next to it, and that's not what you want. you want a single \ in the string, because it is the folder separator character, which must be typed '\\'...
|
|
|
|
|
Hi all,
i got question here need some information. i'm new in in programming.
could anyone help.
#include <stdio.h> <br />
int main()<br />
{<br />
int a,b,c:<br />
a=5;<br />
b=7;<br />
c=a+b;<br />
printf("%d+%d=%d\n",c,a,b);<br />
return 0;<br />
}</stdio.h>
Can, anyone help me go through with this. Thanks. in my mind, the answer display on the screen should be "12+5=17". i'm not sure is that correct. if not correct, can you please explain. Thanks all.
|
|
|
|
|
int a, b, c; <-- not ":", but ";"
the result is : 12+5=7
|
|
|
|
|
How about this? Do i do it correctly,
unsigned int a,b,c;
void main()
{
a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
I know >> is greater than. * is square and ^ xor.
The command like "|" and "~" i really not familiar with. Can anyone explain or go through with it. What it will be the final value for a, b and c? I really confused
|
|
|
|
|
Member 4099222 wrote: I know >> is greater than.
No, that's for shifting bits.
Member 4099222 wrote: * is square...
No, that's for multiplying.
Member 4099222 wrote: The command like "|"...
That is logical OR.
Member 4099222 wrote: and "~" i really not familiar with.
That is one's complement.
Member 4099222 wrote: What it will be the final value for a, b and c?
Why don't you try it and see?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Refer to your replied,
unsigned int a,b,c;
void main()
{
a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
The result i got for c=a>>5 is 0.3125 (because 10 divide with 32). So how do i proceed with b for 'or' operation and how to calculate the value of a? thanks
|
|
|
|
|
Member 4099222 wrote: So how do i proceed with b for 'or' operation...
The variable b will be assigned a value of 1 because either c or a will have a non-zero value.
Member 4099222 wrote: ...how to calculate the value of a?
I guess that would depend on what value you want it to have.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
unsigned int a,b,c;
void main()
{ a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
this is how is work on,
c=a>>5 ; //so c=10/32=0.3125
b=c|a; // so b=0.3125|10 = 1 (this one i'm not sure it right)
a=~c&~b; // so ~c= -0.3125 and ~b= 0. so ~c&~b=0 (& is AND operator)
c=b*a^5; // so b=1 and a^5=5 (^ is XOR operator)
so the final value for a,b and c
a=0 b=1 and c=5.
Please confirm that my work is right. Thanks for your help.
cheers
|
|
|
|
|
Member 4099222 wrote: Please confirm that my work is right.
Why? Can't you just print those values out to confirm?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
printf("%d+%d=%d\n",c,a,b);
c is your total and is in the wrong position.
b = 7 not 12 and is in the wrong position.
a is okay.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|