|
ok i remouve spaces !... works ! but my same problem remain how to find in the other columns FindItem column 1,2 how ? when i find this ,my problems , i thing ... will be solved !
My code find only in first column (0) and give me the text from others all i wanth is to search in others columns 1,2 ...
???????
Bravoone
|
|
|
|
|
Maybe you should try this:
CString sName, sCity, sCountry;
m_name.GetWindowText(sName);
m_city.GetWindowText(sCity);
sCountry.Empty();
for(int nItem = 0; nItem < m_list2.GetItemCount(); ++nItem)
{
CString const sFirstColumnText = m_list2.GetItemText( nItem, 0 );
CString const sSecondColumnText = m_list2.GetItemText( nItem, 1 );
if( sName == sFirstColumnText && sCity == sSecondColumnText)
{
sCountry = m_list2.GetItemText( nItem, 2 );
break;
}
}
m_result.SetWindowText(sCountry);
I hope this will give you some ideas.
|
|
|
|
|
Thanks but nothing is working i have tried everyting ! my code remaine the same !
Please someone help me !
void CMyList::OnOK()
{
UpdateData();
CWaitCursor wait; // Display a wait cursor
int x = m_list.GetItemCount();
for (int j = 0; j < x; j++) // For each item in the list
{
CString strWord;
strWord = m_list.GetItemText(j, 0); // Get the word
strWord.TrimLeft(); // Remove leading spaces
strWord.TrimRight(); // Remove trailing spaces
// Overwrite the old word with the new trimmed word
m_list.SetItemText(j, 0, strWord);
}
CString sName = _T("Name");
m_name.GetWindowText(sName);
LVFINDINFO stInfo = {0};
stInfo.flags = LVFI_STRING;
stInfo.psz = sName;
int nItem = m_list.FindItem( &stInfo );
if( nItem != -1 )
{
// the item is in the list control
CString sSecondColumnText = m_list.GetItemText( nItem, 1 );
// set the text to the second edit box
m_rezult.SetWindowText( sSecondColumnText );
}
}
----------------------------------
| Name | City | Country |
----------------------------------
| George| London| England |
-----------------------------------
|George |NewYork | USA |
-----------------------------------
for ex :
all i whant is to find if george - London - England exist !
or
all i whant is to find if george - NewYork - USA exist !
m_name , m_city , m_rezult ! m_rezult <----- Country!!!!
Bravoone
|
|
|
|
|
There's nothing wrong with the code you've shown. This works fine:
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_list.InsertColumn(0, "Name", LVCFMT_LEFT, 100);
m_list.InsertColumn(1, "City", LVCFMT_LEFT, 100);
m_list.InsertColumn(2, "Country", LVCFMT_LEFT, 100);
int nItem = m_list.InsertItem(0, "George");
m_list.SetItemText(nItem, 1, "London");
m_list.SetItemText(nItem, 2, "England");
nItem = m_list.InsertItem(1, "George");
m_list.SetItemText(nItem, 1, "New York");
m_list.SetItemText(nItem, 2, "USA");
return TRUE;
}
void CMyDlg::OnOK()
{
CString strName;
LVFINDINFO stInfo = {0};
m_edit.GetWindowText(strName);
stInfo.flags = LVFI_STRING;
stInfo.psz = strName;
int nItem = m_list.FindItem(&stInfo);
if (nItem != -1 )
AfxMessageBox("Found It!");
} You must have something else wrong.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes but this code works only in the first column and i want to search in column 1 and 2 ! (this is my problem)
This code search only in the first column !
How can i search in other column ? (1,2) ???????
Please help !
Bravoone
|
|
|
|
|
Flaviu_2006 wrote: Yes but this code works only in the first column...
Of course! You've not ever specified that you wanted to search subitems, which FindItem() does not do.
Flaviu_2006 wrote: How can i search in other column ? (1,2) ???????
This has already been shown to you. What part did you not understand?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and how can i search subitems in column 1,2 because in column 0 my code works to finditem !?
and previous examples that has been given to me don t work !( in my code ) ( is not good for my code i try to search in column 1 and getitemtext from column 2!
Please help me ! i remind you :
m_name , m_country , m_relatia !( if m_name (is found it in column 0) and m_country (is found it in column 1 ) then getitemtext from column 2 - > in m_relatia)! This is what i want and i don t no how to do it !
Please help me!
Bravoone
|
|
|
|
|
Hi,
I am saving recorded file in a folder, but am hardcoding the name in the code itself.I want the recorded .wav file to get the name as current date and time for e.g. 08/09/0611:55:39.wav.I get the name of the file in a string variable but it does not gets saved coz it does not recognise the slash(/).I want a way in which i can convert the slash(/) in the date string to hyphen(-).
For e.g 08/09/0611:55:39.wav has to be converted to 08-09-0611:55:39.wav.
I am using VC++, please suggest me how can i solve this problem.
Thanks
Riz
|
|
|
|
|
CString cstrFileName;// File name to be save
..
..
// Use following functions on file name variable
cstrFileName.Replace(':','-');
cstrFileName.Replace('/','-');
Regards
Amar
|
|
|
|
|
Like this
<br />
CTime time = CTime::GetCurrentTime();<br />
CString str;<br />
str.Format("%d-%d-%d%d:%d:%d%s",<br />
time.GetDay(),<br />
time.GetMonth(),<br />
time.GetYear(),<br />
time.GetHour(),<br />
time.GetMinute(),<br />
time.GetSecond(),".wav");<br />
<br />
|
|
|
|
|
Hello everyone,
I found the log file size is becoming larger and larger. Any ideas to reduce the file size or make log file size managed, for example, keep the log file be fixed size or some other policies? Any reference tutorials or open source samples to recommend?
thanks in advance,
George
|
|
|
|
|
|
Look cool, thank you WhiteSky!
regards,
George
|
|
|
|
|
Dear All,
I am a newbie to XML. I'd like to know XML programming by VC++.net.
Kindly let me know the right path to learn this.
Thanks in advance,
Sarvan AL
|
|
|
|
|
|
Dear WhiteSky,
Thanks a lot for your immediate reply and suggestion.
Sarvan AL
|
|
|
|
|
Hi
I have created XLL Plugin for Excel Worksheet.
I know how to take the CXlOper as an argument or Return this type of Argument to Excel Sheet.
Currently i need to know how can i Perform Row Addition with in XLL Code.
I am writing XLL in C++ using MFC.
Can any one please show me a sample for what i want to achieve ?
Thanks
Sheraz
|
|
|
|
|
|
Hello,
I'm finding some "smart" GDI obj(e.g. CPen, CBrush, etc.) wrapper class that implements the RAII idiom, to make the GDI coding somewhat easier. Is such stuff available?
Thanks.
|
|
|
|
|
|
i have a dialog with a manifest the tabctrl looks right but i have check boxes on it and the backcolor of the text is tan like the dialog and the tab is white how do i fix it?
|
|
|
|
|
I'd like to write a function that tells me how many documents I have open of a particular document type. I want to call this function whenever someone tries to open a new document and if that would exceed the predefined number allowed, notify them with a message box.
Any ideas?????
Thanks,
The secret to creativity is knowing how to hide your sources. (Albert Einstein)
-- modified at 22:44 Tuesday 8th August, 2006
|
|
|
|
|
If you are dealing with MDI application in MFC using CMultiDocTemplate class, then I think you should use its members in this manner:
CMutiDocTemplate * t = ...;
int total_documents = 0;
POSITION pos = t->GetFirstDocPosition();
while(pos != NULL)
{
++total_documents;
pos = t->GetNextDoc(pos);
}
I hope this helps.
|
|
|
|
|
Hey All
I am wondering how to add new menu to other application, meaning I want to add a menu to another application that is not mine
let's say I want to add menu to Windows Live Messenger or Yahoo!
any idea how?
thanks in advance!
|
|
|
|
|
When you run this code you have two "test" in File last option and another after help
<br />
PROCESS_INFORMATION l_ProcessInfo;<br />
STARTUPINFO l_StartupInfo;<br />
<br />
ZeroMemory(&l_StartupInfo, sizeof(STARTUPINFO));<br />
<br />
l_StartupInfo.cb = sizeof(STARTUPINFO);<br />
l_StartupInfo.dwFlags = STARTF_USESHOWWINDOW;<br />
l_StartupInfo.wShowWindow = SW_SHOWMAXIMIZED;<br />
<br />
CreateProcess(NULL, <br />
"Notepad.exe", <br />
NULL, <br />
NULL, <br />
FALSE,<br />
DETACHED_PROCESS,<br />
NULL,<br />
NULL,<br />
&l_StartupInfo,<br />
&l_ProcessInfo);<br />
<br />
MessageBox("Wait");<br />
HWND hWnd = ::FindWindow("Notepad", NULL);
HMENU h=::GetMenu(hWnd);<br />
HMENU h2=GetSubMenu(h,0);<br />
<br />
AppendMenu(h2,MF_STRING,22,"test");<br />
AppendMenu(h,MF_STRING,22,"test");<br />
|
|
|
|