|
No, there's more to it than that. Typically, a program using an auxiliary thread will probably have one of two patterns:
A thread that does one thing then exits its thread function
The auxiliary thread exits of its own volition. The main thread can then check that the thread has exitted using the GetExitCodeThread[^] function (the functions shows a thread exit code of STILL_ACTIVE if the thread hasn't terminated), or can wait for the thread to exit using the WaitForSingleObject[^] function, using the thread handle as the handle to wait for (a thread's handle is set when the thread exits).A thread that does many things in a loop
In this case, you need some way of telling the thread that it's time to exit. In general, you could use a boolean flag that the thread can check each time round the loop (use InterlockedExchange[^] to set the flag from the main thread) or you could use an event[^] - the main thread would set the event to indicate that the other thread should exit, the other thread use WaitForSingleObject to see if the event's been set). In either case, the main thread would notify the other thread that it's time to exit, then wait for the thread to exit using WaitForSingleObject.
Use the appropriate pattern (I suspect it's the second from what you've said) when the thing that created the thread (your cmainwnd?) is destroyed.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hi to all,
i have the following problem, when the SDI-Application starts, the window is disabled i can not write anything in it, any help to solve this problem will be appriciated.
I am using Visual Studio 2005
Thanks
|
|
|
|
|
You will have to choose CEditView instead of CView for the Application to support editing by default. Either create a new project and from "Generated Class" option, choose CEditView or CRichEditView instead of CView or manually rename CView References in your project to CEditView then it should work fine.
If your question is something else, please mention it clearly.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks a lot it i did as you said and it works fine.
|
|
|
|
|
hey again i have a main frame divided to 2 parts in the upper part i should be able to give a sql request to the databse like , select and updte for example
in the lower part i shoul be able to display the reults from the sql request.
where should i implement the neccessary code for that?
and how i could get the input from the upper part? i need 2 objects from CEditView one for the input from the upper part and the second for the output and then with something like GetWindowText i read the input is this correct?
any help to solve this will be appricated,
I am using visual studio 2005 / MFC
thanks
|
|
|
|
|
Check this sample[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
hey is this the answer for my second question? i downloaded the zip file and tried to bulid it but it did not rebuild??
|
|
|
|
|
I Down Loaded the PopUpdemo project/Solution from the site after resolving a few compile errors re: the ON_COMMAND macro
(by pointing VS to the MFC includes )
I got the following Linker errors for MFC objects
I there any Special .lib I have to point to
Thankx
>Linking...
1>PopupDemo.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CWinApp::messageMap" (?messageMap@CWinApp@@1UAFX_MSGMAP@@B)
1>PopupDemoDlg.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CDialog::messageMap" (?messageMap@CDialog@@1UAFX_MSGMAP@@B)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: __thiscall CString::~CString(void)" (??1CString@@QAE@XZ) referenced in function "protected: virtual int __thiscall CPopupDemoDlg::OnInitDialog(void)" (?OnInitDialog@CPopupDemoDlg@@MAEHXZ)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: __thiscall CString::operator char const *(void)const " (??BCString@@QBEPBDXZ) referenced in function "protected: virtual int __thiscall CPopupDemoDlg::OnInitDialog(void)" (?OnInitDialog@CPopupDemoDlg@@MAEHXZ)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: int __thiscall CString::IsEmpty(void)const " (?IsEmpty@CString@@QBEHXZ) referenced in function "protected: virtual int __thiscall CPopupDemoDlg::OnInitDialog(void)" (?OnInitDialog@CPopupDemoDlg@@MAEHXZ)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: int __thiscall CString::LoadStringA(unsigned int)" (?LoadStringA@CString@@QAEHI@Z) referenced in function "protected: virtual int __thiscall CPopupDemoDlg::OnInitDialog(void)" (?OnInitDialog@CPopupDemoDlg@@MAEHXZ)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: __thiscall CString::CString(void)" (??0CString@@QAE@XZ) referenced in function "protected: virtual int __thiscall CPopupDemoDlg::OnInitDialog(void)" (?OnInitDialog@CPopupDemoDlg@@MAEHXZ)
1>PopupDemoDlg.obj : error LNK2019: unresolved external symbol "public: long __thiscall CWnd::SendMessageA(unsigned int,unsigned int,long)" (?SendMessageA@CWnd@@QAEJIIJ@Z) referenced in function "protected: void __thiscall CPopupDemoDlg::OnPaint(void)" (?OnPaint@CPopupDemoDlg@@IAEXXZ)
1>.\Debug/PopupDemo.exe : fatal error LNK1120: 8 unresolved externals
1>Build log was saved at "file://j:\PopupDemo\PopupDemo\Debug\BuildLog.htm"
|
|
|
|
|
If the application has to support MFC choose either "MFC in a Shared DLL" or "Use MFC in a static library" from project properties.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
I thin I did but I'll check when I back home
|
|
|
|
|
I'm doing a project. It's working fine until it tries to open a file with a Chinese character in its path.
CFileDialog ImportDlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,_T("text Files (*.txt)|*.txt||"));
int iResult=ImportDlg.DoModal();
CString str=ImportDlg.GetPathName();
I think it works if I set the character set to Unicode set. I'm just wondering why it gives me question mark for the Chinese when I switch to MBCS set?
|
|
|
|
|
I guess you a haven't installed support for Asian languages in your OS.
Switching to Unicode should show you the same question marks.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Actually I do installed support for Asian languages, and it does show this Chinese in Unicode set. That's why I'm wondering.
|
|
|
|
|
Ok. In that case you could try to dump the data into a text file and open the text file.
It could be that the characters are not showable by the viewer.
Make sure you write these 3 hex. characters at the begining of the file.
EF BB BF
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Check the thread addressing the similar problem [^]
Since this is a non-Unicode application, you need to make sure that your "Language for non-Unicode programs" is set to Chinese (Simplified) and reboot. It then should work. (If you are on an English os and running a language pack, changing to the language pack does not automatically change the "Language for non-Unicode programs". This is done manually).
To make this change on Vista, see:
http:
IMO, it's better to stick with UNICODE for this kind of complex languages like Japanese and Chinese.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
I have an 3 rd party API that will a fill a buffer of type LPSTR,
This buffer is actually in picture format, i have to convert make this appear in a CStatic control.
what i have:
BYTE pBuffer;
HDC hDC; //HDC handle for the CSttaic Control
API will fill this pBuffer
(LPSTR)pBuffer
I have to make this pBuffer to appear in picture format in CStatic control.
Would apprecaite any help.
|
|
|
|
|
What do you mean with 'in picture format ' ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This "pBuffer" i can save it as a Bitmap format like this.....
But i want to draw this pBuffer into a CStatic without converting to Bitmap...
CFile file;
CString strTemp;
char szTemp[MAX_PATH];
char *pDot;
GetModuleFileName(AfxGetInstanceHandle(),szTemp,sizeof(szTemp));
pDot = strrchr(szTemp,'.');
*(pDot+1) = 'B';
*(pDot+2) = 'M';
*(pDot+3) = 'P';
strTemp.Format(szTemp,GetTickCount());
file.Open(strTemp,CFile::modeCreate | CFile::modeWrite);
file.Write(pBuffer,dwSize);
file.Close();
|
|
|
|
|
According to your answer to CPallini, your buffer contains a BMP file. So, wiki[^] should contain all the information you need to access the pixel data. Also look for BITMAPFILEHEADER, BITMAPINFO and such structures in MSDN, these should help too. You could for example use CreateDIBSection[^] to get a HBITMAP from your data and use it to feed it to a picture (static) control or draw it yourself.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hello,
Please any one tell me where i can get message IDs for registered activex controls?
I want to automate MSFlexgrid control or MSdatagrid control using Perl. This requires sending message to those controls. But I could not find any document containing grid control messages. I could get Message ID s of most of the controls (commonly used) in winuser.h and commctrl.h. Thank you in advance.
|
|
|
|
|
ActiveX (i.e. COM ) controls have their own way (i.e. interface methods) to interact with.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm Grateful for your concern.How to invoke interfaces externally using Perl?
|
|
|
|
|
I'm not an expert but this page [^] looks promising.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am working on Vista with VS 2005.
In my application, I am handling the WM_POWERBROADCAST message and in the message handlig function, execution some code which i must execute when the system goes to hibernate or standby(sleep) mode.
I find that on Vista, windows doesnot wait for the WM_POWERBROADCAST message handling function to return a value(true or false) before proceeding to entering into sleep mode.
On Vista, the system goes to sleep mode even before the WM_POWERBROADCAST message handling function returns a value. And because of this, my application does not have enough time to execute code in the handler function and results in a crash.
Should Windows go/not go to hibernate/sleep mode depending on the return value of the WM_POWERBROADCAST handling function?[MSDN Link]
|
|
|
|
|
The following is from the documentation -
To prevent the system from transitioning to a low-power state in Windows Vista, an application must call SetThreadExecutionState to inform the system that it is in use.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|