|
|
It really a excellent solution of terminating a thread.
But if we do not use MFC,how should do such thing?
|
|
|
|
|
The solution explained there has nothing to do with MFC: you just use a flag that you set from another thread. In your thread loop, check for this flag end stop looping once it is set.
|
|
|
|
|
Use the technique described in Newcomer's article: wait for some handles to synchronization objects with a call to ::WaitForMultipleObjects() where one of them (preferably the first one for priority reasons) is signaled when the thread should terminate.
After you have set this event you should wait on the thread handle with ::WaitForSingleObject() to know when the thread has finished completely to be able to clean up the trhead object and other resources you have claimed for the thread.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
From which thread you called PostThreadMessage()?
AJay
|
|
|
|
|
In the main process like a dialog,I create the thread and post the message
|
|
|
|
|
Perhaps the worker thread doesn't even have a message pump!
Steve
|
|
|
|
|
Using the ReadFile() api, how would one determine if the bytes being read are ASCII, MBCS, UNICODE or even UTF8?
|
|
|
|
|
Actually the first few bytes of files is used to identify the type of encoding. For example for plain ascill there will not be any speciall bytes.
For UNICODE - FF FE
For UTF-8 - EF BB BF
|
|
|
|
|
It is only for .txt files only. Am I right?
- NS -
|
|
|
|
|
May be. But all other file formats( having text data ) are applications specific such as doc or xls. So its there own implementation.
|
|
|
|
|
This won't work in my situation since I'm not actually reading a file but a pipe. I'm diverting the putput of a console, so the bytes being read could either be ascii or unicode, but I have yet to find an easy way to determine which.
|
|
|
|
|
I have a owner-draw dialog,I change its default color to blue.But when the dialog was minimized,there would be a thin rectange left on the screen.
Someone would like to tell me why and how to resolve it?
Thanks.
GOOD LUCK
|
|
|
|
|
What do you mean by "owner-draw dialog"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What I mean is that,the rect of the dialog based window is not the nomal rectange but round rectange or other shape.I also paint its color no longer than gray.
Then,when the dialog is minimized,there would be a thin frame on the screen!
|
|
|
|
|
Are you setting a proper window region for the shape of the window?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes,I am sorry.I find the fault of my program now.
When I paint the window,I used GetClientRect() function.
I neglected the fram width!
Thanks very much.
GOOD LUCK.
|
|
|
|
|
In an Visual C++ 6.0 application, I want to get Serial Number of Motherboard, but I don't know how to do. I'm in dark!!! Please help me!!!
Thank you very much!!!
|
|
|
|
|
even i tried for the same but in vain , allternatly i could find serial no: of HDD. will it work for you
|
|
|
|
|
Ok, thank you for your support.
If maybe, you can find Serial Number of HDD for me, please.
Thank you very much!!!
|
|
|
|
|
|
nps_ltv wrote: I want to get Serial Number of Motherboard
I think its possible to get the serial number using the WMI. There is a class called Win32_BaseBoard by which u will get the serial number. There are some samples in the code project itself demostrating how to use WMI. Have a search
|
|
|
|
|
See Win32_MotherboardDevice and
Win32_BaseBoard::SerialNumber;<br /> if helpfuls.
|
|
|
|
|
Hi Guyz.
I am using a code snippet but something seems to be wrong with it. It is supposed to create a pop up menu from drop down menus which have already created but though it compiles successfully with the warnings:
C:\Program Files\Microsoft Visual Studio\MyProjects\Menus\MenusDlg.cpp(212) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
C:\Program Files\Microsoft Visual Studio\MyProjects\Menus\MenusDlg.cpp(214) : warning C4700: local variable 'm_lMenu' used without having been initialized
i keep on getting an application error about memory referencing as if im having a memory overflow.
Below is the code snippet
void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
// Declare local variables
CMenu *m_lMenu; // A pointer to the menu
CPoint m_pPoint; // A copy of the mouse position
// Copy the mouse position to a local variable
m_pPoint = point;
// Convert the position to a screen position
ClientToScreen(&m_pPoint);
// Get a pointer to the window menu
m_lMenu - GetMenu(); //(Most likely the cause of Problems)
// Get a pointer to the first submenu
m_lMenu = m_lMenu->GetSubMenu(0);
// Show the Popup Menu
m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON,
m_pPoint.x, m_pPoint.y, this, NULL);
}
Please Help. Thanks.
Man can be an Island but Islands to need water around them to be islands (Own).
|
|
|
|
|
Wamuti wrote: m_lMenu - GetMenu(); //(Most likely the cause of Problems)
a minus symbol( - ) in between??? change it to '='
m_lMenu = GetMenu();
|
|
|
|