|
mpallavi wrote:
I want to delete the current selection in the combo box. DeleteString deletes item at specified index.
How do i go about this?
int nCurrent = combo.GetCurSel();
if (nCurrent != CB_ERR)
combo.DeleteString(nCurrent);
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
If you want to delete the item from the drop list:
<br />
int nCurSel = m_myComboBox.GetCurSel();<br />
if (nCurSel != CB_ERR)<br />
m_myComboBox.DeleteString(nCurSel);<br />
If you just want to clear the text (if combo is not a drop list):
<br />
m_myComboBox.SetWindowText(_T(""));<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Thank you all..
Can anyone tell me how do i get the data associated with the current selection .. i mean the value of the current selection.
thanx
pallavi
|
|
|
|
|
mpallavi wrote:
Can anyone tell me how do i get the data associated with the current selection ..
See it this Help CComboBox::GetLBText
Here is small code to help :-
int nIndex=m_combo.GetCurSel();
if(nIndex==LB_ERR)
{
CString str;
m_combo.GetLBText(nIndex,str);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
if(nIndex==LB_ERR)
I think you mean if(nIndex!=LB_ERR)
Technically, in this case CB_ERR should be used instead of LB_ERR , but in practice both are defined as -1
Hey, this peer programming thing does work!
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
I think you mean if(nIndex!=LB_ERR)
Yeap, Sorry for Silly Mistake
Jose Lamas Rios wrote:
Hey, this peer programming thing does work!
Yeap, thats why we are here
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thanx.. its working. I have still more problems with ComboBox..
I am saving all these telephone numbers in a text file.. If you remember, few days back i was coding for persistent combo box. Its working perfactly fine but the problem is when i delete a number.
I am creating a temp file .. i want to write all the values in this file except for the current selection..
how do i go about this?
pallavi
|
|
|
|
|
mpallavi wrote:
I am creating a temp file .. i want to write all the values in this file except for the current selection..
how do i go about this?
Let this variable m_arr of type CStringArray contain all the phone number present in combo box.
<font color=#008000>
CString szPhoneNo;
int nIndex=m_combo.GetCurSel();
if(nIndex!=CB_ERR) <font color=#008000>
{
m_combo.GetLBText(nIndex,szPhoneNo);
}
else
<font color=#008000>
return;
<font color=#008000>
CString szTempPath;
GetTempPath(szTempPath.GetBuffer(MAX_PATH),MAX_PATH);
<font color=#008000>
szTempPath.ReleaseBuffer();
<font color=#008000>
szTempPath+=CString("temp.txt");
<font color=#008000>
CStdioFile m_File;
if(m_File.Open(szTempPath,CFile::modeCreate|CFile:modeWrite))
{
for(int i=0;i<m_arr.GetUpperBound();i++)
{
<font color=#008000>
if(m_arr.GetAt(i)!=szPhoneNo)
m_File.WriteString(m_arr.GetAt(i));
}
m_File.Close();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
GetTempPath(szTempPath.GetBuffer(MAX_PATH),MAX_PATH);
I am getting the following error at above line:
'GetTempPathA' : cannot convert parameter 1 from 'char *' to 'unsigned long'
Please help.
|
|
|
|
|
mpallavi wrote:
GetTempPath(szTempPath.GetBuffer(MAX_PATH),MAX_PATH);
Sorry, Just Exchange Argument
i.e.
GetTempPath(MAX_PATH,szTempPath.GetBuffer(MAX_PATH));
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Alok..
temp file is getting created but its empty.. i am trying to find what went wrong..
regards
pallavi
|
|
|
|
|
oops..
My array of strings is empty.. I used
m_arr.Add(m_strPhoneNum);
to add phone numbers in the array.
I think the syntax is wrong..
pallavi.
|
|
|
|
|
mpallavi wrote:
m_arr.Add(m_strPhoneNum);
what is m_arr , and how are you iterating throught it when writing to the file?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
mpallavi wrote:
to add phone numbers in the array.
I think the syntax is wrong..
Hi Pal,
First Add all the member of ComboBox to CStringArray or directly Enumerate them, When you are entering data in temporary File.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi all
can anybody help me out with a sample,that can store some GDI calls and later play it back, i came to know that metafile device context can be used for this purpose
thanks for your help
regads
pradish
|
|
|
|
|
|
2 Jose Lamas Rios
thanks for ansering my mail,but i need a sample that makes use of Win32 GDI API's only. no MFC.
regards
pradish
|
|
|
|
|
pradish wrote:
thanks for ansering my mail,but i need a sample that makes use of Win32 GDI API's only. no MFC.
That was the first link. It's about using metafiles with Win32 APIs (No MFC) and includes a downloadable sample...
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi does anyone know how to insert commas in array?
example: 2,3
3,3
4,2
I need to show these commas when I execute the program.
Pls advice.
|
|
|
|
|
for (int i = 0; i < arraySize-1; ++i)
{
cout << array[i] << ", ";
}
cout << array[arraySize-1];
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
for (int i = 0; i < arraySize-1; ++i)
{
cout << array[i] << ", ";
}
cout << array[arraySize-1];
Right, but don't forget to test for the empty array condition. The for loop checks it itself, but the last sentence may attempt to access array[-1] .
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Okay, I have a dialog, made with the resource editor, im using it as my main window, and im using Pure Win32, no MFC!, and i want this dialog to be positioned by the system like a normal window would be if you had created the window with CreateWindow() and specified CW_USEDEFUALT for the X paramater, but i dont know how to get my window to do this.
and please, if you dont know exactly what i am asking then dont bother trying to answer
|
|
|
|
|
Position the dialog to your liking in response to the WM_INITDIALOG message. Use:
SetWindowPos(..., CW_USEDEFAULT, CW_USEDEFAULT, ...); for the x and y parameters.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
tried this, it positions the window off screen
|
|
|
|