|
Can you post the sample code snippet.
Upto my understanding, set a flag before start the thread. Based on the flag start or stop your threads in the for loop.
Sreedhar DV
[Real success is having courage to meet failure without being defeated.]
|
|
|
|
|
See here for thread shutdown discussions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HI
How to create enter botton in mfc?
|
|
|
|
|
From the toolbar, pull a button onto your dialog.
Place it where you want it, change its caption o read 'Enter' etc.
Add a handler for that button.
What specifically is your problem?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
yadahav wrote: How to create enter botton in mfc?
You mean befault button?
If so right on a button take properties->Style->tick the Deafult button.
|
|
|
|
|
Do you want to make it with code you can use of CreateWindow("Butotn")... if you want to make a button for enetr you can set id of button to IDOK .
|
|
|
|
|
Hi,
I have a list control on my dialog box.Property is set to Report view & member name is m_Pressure.
CEdit* pEdit = m_Pressure.GetEditControl();
Above function is always returning NULL.
Please help me out
Thanks
|
|
|
|
|
shir_k wrote: CEdit* pEdit = m_Pressure.GetEditControl();
For this function to work, you have set the style LVS_EDITLABELS for list control. Also this function return a pointer only if you started editing the list control.
Either by clicking on list control or by sending the LVM_EDITLABEL( EditLabel()) to the list control.
|
|
|
|
|
In Property of Control list i checked edit labels.
I included NM_Click function as below.
ptrPressInPSI is a pointer to the control list
CListCtrl *ptrPressInPSI;
ptrPressInPSI = &m_Pressure;
void list::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CEdit* edit = ptrPressInPSI->GetEditControl();
if (edit)
{
int i;
i=0;
}
*pResult = 0;
}
Any thing wrong in above code.It is still returning NULL
thanks
|
|
|
|
|
shir_k wrote: I included NM_Click function as below.
Use LVN_BEGINLABELEDIT instead.
|
|
|
|
|
Thanks naveen. I got it.
But one question why am not able to use above code in other functions.I want to include copy & paste function for CListCtrl,Below is a code which i got from google
In the below code am facing two problems
1)As i told CEdit* edit = m_Pressure.GetEditControl(); is always NULL
2)when i include CListCtrl& m_list4 = GetListCtrl( ); am getting below errors
D:\JUNE\VC\test1\list.cpp(147) : error C2065: 'GetListCtrl' : undeclared identifier
D:\JUNE\VC\test1\list.cpp(147) : error C2440: 'initializing' : cannot convert from 'int' to 'class CListCtrl &'
BOOL list::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_KEYDOWN )
{
CListCtrl& m_list4 = GetListCtrl( );
CEdit* edit = m_Pressure.GetEditControl();
if (edit)
{
if( GetKeyState( VK_CONTROL ))
{
if( pMsg->wParam == VK_C )
{
edit->Copy();
return TRUE;
}
if( pMsg->wParam == VK_V )
{
edit->Paste();
return TRUE;
}
if( pMsg->wParam == VK_X )
{
edit->Cut();
return TRUE;
}
if( pMsg->wParam == VK_Z )
{
edit->Undo();
return TRUE;
}
}
if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ||
pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_INSERT ||
pMsg->wParam == VK_SHIFT )
{
edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Please help me out.
Thanks
|
|
|
|
|
GetEditControl() will return only a vaild pointer only if the edit control is visible to the user. in other cases, it will be null.
About the above code, they might have implemented there on edit control in the list control.
shir_k wrote: I want to include copy & paste function for CListCtrl,
Are you trying to paste when the edit control is visible?If so, there is no need of the above code na? You can directly do copy/paste on edit control.
|
|
|
|
|
Hi,
Am able to do copy & paste from the edit box directly but in Control list box it is not possible.
When i checked class definition of
CEdit --> it has clipboard operation
void Clear();
void Copy();
void Cut();
void Paste();
But i didn't find it in CListCtrl.So i thought of using
CEdit* GetEditControl() const;
so once i get handle then i may able to do copy & paste.
Is there any other way to do.
|
|
|
|
|
shir_k wrote: so once i get handle then i may able to do copy & paste.
Suppose you press ctrl+c on the list control. Then what do u expect?
1)The text in first column of selected row is copied?
2) The whole text in list control is copied?
Also what will be the case of ctrl+c?
|
|
|
|
|
i expect it to copy the selected data in the column.Am having only one column.
And i want that data to be pasted in a notepad.
|
|
|
|
|
shir_k wrote: i expect it to copy the selected data in the column
Then no need of the edit control and all.
Directly copy the data from the clipboard and set it as text to the column.
|
|
|
|
|
i don't know how to copy data from Control list to clipboard and from clipboard to notepad.
I tried this using API's(OpenClipBoard()....) of MFC but i was not sucessful. If u have any code plz share it or tell me the steps to do it.
Thanks
|
|
|
|
|
try this. this will copy the text in the selected row to clip board.
<br />
int nItem = m_list.GetNextItem( -1, LVNI_SELECTED );<br />
if( -1 == nItem )<br />
{<br />
return;<br />
}<br />
CString csPath;<br />
csPath = m_list.GetItemText( nItem,0 );<br />
OpenClipboard();<br />
EmptyClipboard(); <br />
int nSize = (csPath.GetLength() + 1) * sizeof(TCHAR);<br />
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, nSize ); <br />
if (hglbCopy == NULL) <br />
{ <br />
CloseClipboard(); <br />
return; <br />
} <br />
LPTSTR lpData = (LPTSTR)GlobalLock(hglbCopy); <br />
memcpy(lpData, csPath, nSize ); <br />
lpData[nSize-1] = (TCHAR) 0;<br />
GlobalUnlock(hglbCopy);<br />
SetClipboardData( CF_UNICODETEXT, hglbCopy ); <br />
CloseClipboard();
where m_list is the control variable for the list control
|
|
|
|
|
Thanks a lot Naveen.
Am able to copy the data.I was trying this from past 3 days.Thank you very much.
|
|
|
|
|
Hello everyone,
I have used unmanaged C++ developed a native COM DLL. Then I use OLE Viewer (from command line oleview) to open (Bind To File function) the DLL. Then there is an error message.
IMoniker:BindToObject failed on the file moniker created from (c:\temp\foo.dll) Bad extension for file
(MK_E_INVALIDEXTENSION) ($800401E6)
Anything wrong?
thanks in advance,
George
|
|
|
|
|
Hello everyone,
I find that we can use tlbexp command like *tlbexp <dll name="">* to export tlb file for a C# COM assembly, but can not use it to export tlb file for an unmanaged C++ COM DLL. Is that correct?
I am wondering how to export tlb file of an unmanaged C++ COM DLL?
thanks in advance,
George
|
|
|
|
|
I have a service, i need to do some task when its been killed from task manager/abruptly stopped. How can i do it ? does SCM sends some message so that i can handle it in Service Control handler function ??
|
|
|
|
|
I just began learning socket programming and use
http://www.codeproject.com/internet/JavaCSocket.asp[^]
this article as my reference.
I tried the attached example project, and found that it was easy to use.
But when I add the files ( sock.cpp, sock.h ) to my other project, there was many errors when I build it, such as
LINK : fatal error LNK1152: cannot resolve one or more undecorated symbols
Can anybody tell me what should I do?
Thanks in advance
----------
C++ Learner
|
|
|
|
|
You need to include WS2_32.lib into you project.
Add this library simply to your project (like adding an existing .cpp or .h )
Good luck
|
|
|
|
|
I have coded a loop to find all files and folders on a certain drive. The loop works flawlessly but it takes too much time. On my machine, scanning drive C with close to 100000 files, it takes a good 7 seconds. The loop works in a way that it does a recursive search of each directory, copies the filename and path and adds this to a linked list for later processing.
I'm looking for a way to speed this process up. The use of threads may well do this, but it would be more than complicated to code. How would you decide when a thread is required, how would you manage the handles and synchronisation problems?
I would be interested to know how others would approach this problem.
Waldermort
|
|
|
|