|
That’s the basic idea. A word of warning: don’t use the TerminateThread function! See here[^] for details. A professional implementation would use the WaitForMultipleObjects function instead of WaitForSingleObject ; one of the objects is the parent's HANDLE and the other an event (see CreateEvent ) that you use to tell the thread to exit gracefully. Your main thread uses the event to signal the other thread to close down and then waits for it to do so using WaitForSingleObject on the thread's HANDLE .
Steve
|
|
|
|
|
Hello
It seems if you create a process in your application using createprocess or any other API and if the parent application gets terminated forcibly (as in your case) the child process will not get terminated. For referenc refer the "Terminating a Process" section of the MSDN. To go to this topic, look into the Remarks section of "CreateProcess" API.
In the "Terminating a Process" it is clearly mentioned as "When the system is terminating a process, it does not terminate any child processes that the process has created."
However in that section they have mentioned a possibility of achieving ur requirement of terminating a child process when the parent application gets terminated.
Thanx
|
|
|
|
|
Thanks for your help
The possibility offered by MSDN won't fix this kind of problem
So i think there is no possibility to work around my problem
|
|
|
|
|
baerten wrote: So i think there is no possibility to work around my problem
I wouldn't go that far. See here[^].
Steve
|
|
|
|
|
i am using dialog ,in that i have an edit control,when ever my dialog displays cursor must be in the edit control,plz help me............
|
|
|
|
|
You can call GotoDlgCtrl() API for that edit to set the focus. If it is in OnInitDialog, you should return FALSE.
- NS -
|
|
|
|
|
ok fine,if it in another function ,wts the processs............
|
|
|
|
|
GotoDlgCtrl itself...
- NS -
|
|
|
|
|
tried setting it to a member of CEdit(The edit box itself ) but GoToDlgCtrl is not a member of CEdit.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Wamuti wrote: tried setting it to a member of CEdit(The edit box itself )
No... You have to call like, GotoDlgCtrl( &m_edit );
- NS -
|
|
|
|
|
Set the "Tab stop" for the edit control as 1. For doing this click Ctrl+D on the resource view of the dialog. Set the edit control tab stop as 1. It is the simplest way to solve your problem.
Sreedhar DV
|
|
|
|
|
add a member variable for that edit box e.g. "m_deEditBox" using the class wizard and set the category as a control and the variable type should change to be automaticaly CEdit.
Wherever you want to receive focus use the SetFocus() and that should do the trick
e.g. :
m_deEditBox.SetFocus();
Only make sure m_deEditBox is visible within the class you are using!
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Calling SetFocus to set the focus to a control on a dialog box is wrong! See here[^] for details.
Steve
|
|
|
|
|
First, Thanks for the correction.
Second, sorry this is long but here goes;
When i tested SetFocus(), i placed it in two buttons as:
void CSetfocusDlg::OnBfirst() //first button
{
// TODO: Add your control notification handler code here
m_deOne.SetFocus();
}
void CSetfocusDlg::OnBsecond() //second button
{
// TODO: Add your control notification handler code here
m_deTwo.SetFocus();
}
and it worked just fine.
But if i am getting it right, if there is a button in a dialog, SetFocus() is reserved for the default push button, right?
This means that even if i put m_editControl.SetFocus() in OnInitDialog(), i would still not get the desired effect of setting the cursor to the Edit control(what i understand from the site you directed me and practically i have tried, so i was very wrong indeed).
Ofcourse it makes sense to use the WM_NEXTDLGCTL but i cant get the message in the class wizard. Then how do i code the handler? Please help!
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Oops sorry, using SetFocus() won't work. But i am learning. Thanks for understanding.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
I'm somewhat confused about this api. My local copy of MSDN aswell as the online version state that this api requires win2k and upwards. But many code samples I have found, including several here on CP, state that it can be used on win98.
What's the deal?
|
|
|
|
|
In my MSDN (Visual studio 2005) it is as
Requires: Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
- NS -
|
|
|
|
|
Thanks for confirming that. I wonder why they changed the documentation? I don't suppose you could copy and paste the paramaters, just in case it has changed. Though I doubt it very much.
|
|
|
|
|
Just for confirmation...
Platform SDK: Device I/O
DeviceIoControl
The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped
);
Descriptions goes........
Requirements
Client Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Winbase.h; include Windows.h.
Library Link to Kernel32.lib.
DLL Requires Kernel32.dll.
Hope now OK...
- NS -
|
|
|
|
|
Exactly as my copy states, with the exception of win95 through winME. Strange eh...
Thanks
|
|
|
|
|
I have added new classes to my project and
I do not have a browse data to show me the classes hirearchy.
The project setting has "Generate browse info" checked.
Rebuilding all does not help.
Is there a way to rebuild the browse data manually?
Thanks for your help.
Vaclav
-- modified at 2:33 Monday 10th September, 2007
|
|
|
|
|
Vaclav_Sal wrote: Is there a way to rebuild the browse data manually?
delete the *.ncb,*.clw and *.aps file and delete release and Debug folder. you will get everything you require!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Alok, thanks a million for your help.
Scary, talking about "major surgery" here.
Somehow all my intermediate directories went out of my “ working folder”.
I am used to .clw to get out of synch, but this was different.
Thanks again
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Scary, talking about "major surgery" here.
he he he.. continue your good work
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi all,
I am developing a snippet for extraction of msg propeties, I am using
outlook 2003. Now my problem is the current mapi_utils does not
extract the PR_HTML body which I need to show the embedded files in
the body and the right format of the body as well.
What I exactly need is the HTML format of the .msg file.
The current mapi_utils are only applicable upto outlook 2000.
Please help me
Thank you,
Jj
the code:
HRESULT hResult;
WORD wKey = 0;
LARGE_INTEGER liZero = { 0 };
LPSTREAM pTNEFStream = NULL;
LPITNEF pTNEFObj = NULL;
MAPIINIT_0 MInit;
MInit.ulVersion = MAPI_INIT_VERSION;
MInit.ulFlags = 0;
hResult = MAPIInitialize(NULL);
if (hResult !=S_OK){
throw(HResultException("MapiInit ResolveMsg",0));
}
IMalloc *m_pMalloc;
hResult = CoGetMalloc(1, &m_pMalloc);
if (hResult !=S_OK){
throw(HResultException("CoMalloc ResolveMsg",0));
}
IStorage *pStorage = NULL;
LPMSGSESS pMsgSession = NULL;
LPMESSAGE pIMsg = NULL;
hResult = ::StgOpenStorageEx(_bstr_t(msgName.c_str()),STGM_READWRITE |STGM_TRANSACTED ,STGFMT_DOCFILE ,0,
NULL, NULL, IID_IStorage,(void**)&pStorage);
if (hResult !=S_OK){
throw(HResultException("stgStorage ResolveMsg",0));
}
if (pStorage==NULL)
throw(HResultException("stgStorageNull ResolveMsg",0));
hResult = ::OpenIMsgSession(m_pMalloc, 0, &pMsgSession);
if (hResult !=S_OK){
throw(HResultException("OpenImsgSession ResolveMsg",0));
}
hResult = ::OpenIMsgOnIStg(pMsgSession,MAPIAllocateBuffer,MAPIAllocateMore,MAPIFreeBuffer,m_pMalloc,0,
pStorage,0, 0, 0, &pIMsg);
if (hResult !=S_OK){
throw(HResultException("OpenIMsgOnIStg ResolveMsg",0));
}
hResult = WriteClassStg(pStorage, CLSID_MailMessage);
if (hResult !=S_OK){
throw(HResultException("WriteClassStg ResolveMsg",0));
}
HRESULT hrProperty;
LPSPropValue lpPropValue = NULL;
hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg,PR_MESSAGE_CLASS ,&lpPropValue);
if (hrProperty != S_OK){
loopMsg(pIMsg,pStorage);
hResult = pIMsg->SaveChanges (KEEP_OPEN_READWRITE);
if (hResult !=S_OK){
throw(HResultException("pIMsg->SaveChanges ResolveMsg",hResult));
}
hResult = pStorage->Commit(STGC_DEFAULT);
if (hResult !=S_OK){
throw(HResultException("Commit of HTML failed in redmap::MailFile::decodeTnef", hResult));
}
}
hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_BODY_HTML, &lpPropValue);
hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_HTML, &lpPropValue);
CBase64* baseconvert = new CBase64;
if (hrProperty != S_OK)
{
hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_BODY_HTML_B, &lpPropValue);
if (hrProperty == S_OK){
CString text;
text.GetBufferSetLength(lpPropValue[0].Value.bin.cb + 1);
text.SetString((LPCSTR)lpPropValue[0].Value.bin.lpb,lpPropValue[0].Value.bin.cb);
enum {BODY, MSG_ADDPROPS };
SPropValue lpPropValueArray2[MSG_ADDPROPS];
lpPropValueArray2[BODY].ulPropTag = PR_BODY_HTML;
lpPropValueArray2[BODY].Value.lpszA = (LPSTR)text.GetString();
hResult = pIMsg->SetProps(MSG_ADDPROPS, lpPropValueArray2,NULL);
if (hResult !=S_OK){
throw(HResultException("SetProps of HTML failed in redmap::MailFile::decodeTnef", hResult));
}
hResult = pIMsg->SaveChanges (KEEP_OPEN_READWRITE);
if (hResult !=S_OK){
throw(HResultException("SaveChanges of HTML failed in redmap::MailFile::decodeTnef", hResult));
}
hResult = pStorage->Commit(STGC_DEFAULT);
if (hResult !=S_OK){
throw(HResultException("Commit of HTML failed in redmap::MailFile::decodeTnef", hResult));
}
if (lpPropValue) MAPIFreeBuffer(lpPropValue);
}
}
pIMsg->Release();
pIMsg = NULL;
CloseIMsgSession ( pMsgSession );
pMsgSession = NULL;
pStorage->Release();
pStorage=NULL;
::MAPIUninitialize();
return 1;
|
|
|
|
|