|
Is there any way that I can take ownership of the thread - I saw 2 functions,
SetParent() and SetOwner(). Would this work?
I've also had another idea - could I modify the style of the window to WS_EX_TOPMOST using ModifyStyleEx()?
Thankyou for your help,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
I am writing an application to do some batch processing. Basically it uses CreateProcess() to create a processes (with the desired command line arguments) over and over a number of times. Each run produces a text file which i will compile together.
My problem however is that the process i am executing will perform its job and NOT close. If i call CreateProcess() while the application is still opened it ignores my arguments and does nothing, so i need to close between each execution.
Can anybody offer any suggestions as to how to detect when the process has completed the work. I am confident that i can tell it to close, im just not sure how to determine when.
The processing time is unpredictable. The cpu is used intensively during the operation. I attempted using the ForegroundIdleProc() hook function to flag me when the foreground thread went idle, however this does not seem to work (the function is hooked ok, as it is called when i close the app as well as scroll around in the app, it just doesnt call it when i want it to!).
Any suggestions would be greatly appreciated.
Alex Deem
|
|
|
|
|
Call WaitForSingleObject() on the process handle:
STARTUPINFO si = {sizeof(STARTUPINFO)};
PROCESS_INFORMATION pi;
if ( CreateProcess(..., &si, &pi) )
{
WaitForSingleObject ( pi.hProcess, INFINITE );
CloseHandle ( pi.hProcess );
CloseHandle ( pi.hThread );
} Your thread will block in the Wait call until the child process exits.
--Mike--
http://home.inreach.com/mdunn/
You are the weakest link, GOODBYE!
|
|
|
|
|
I believe u misunderstood me.
The child process does NOT exit. After doing the processing it sits there displaying the results in its UI. (The child app is a 3rd party app, so i have no control over this).
I wish to determine how to detect when the app is sitting there idle, so i can then kill it.
Alex Deem
|
|
|
|
|
|
Can anybody solve (do a litle magic) the following problem?
I want to make a CComCompositeControl to be a Drop Target,
I know that only CView can be a dropTarget.
I try to register the control as a COleDropTarget, but
call to Register allways fail.
Sergiu.
|
|
|
|
|
If app1 wanted to read the values of app2, it could do so with the following code.
This code will show me the value of labels and buttons, but not data controls
like edit boxes.
Can 1 app read the values of data controls of a second app, or is it some kind of windows
protection mechanism???
thanks
CWnd* pParent = FindWindow(NULL, pcszAppName);
if(pParent && IsWindow(pParent->m_hWnd))
{
CWnd* pChild = pParent->GetWindow(GW_CHILD);
while(pChild)
{
pChild->GetWindowText(strControlText);
TRACE("%s\n", strControlText);
m_ctlReadList.AddString(strControlText);
pChild = pChild->GetWindow(GW_HWNDNEXT);
}
}
|
|
|
|
|
GetWindowText and SetWindowText do not work with Windows in a different process.
You need to use SendMessage instead. Tis is te way you need to use it:
For GetWindowText
TCHAR wndText[512];
::SendMessage(hwnd,WM_GETTEXT,sizeof(wndText)/sizeof(TCHAR),(LPARAM)(void*)wndText);
For SetWindowText
char text[512];
...
::SendMessage(wndEdit,WM_SETTEXT,0,(LPARAM)text);
regards
|
|
|
|
|
Thank you.
That was excellent information.
|
|
|
|
|
I want to make a full screen application that makes window as full screen.
e.g pin ball
Can any one help.
|
|
|
|
|
you can use ChangeDisplaySettings .
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
Try this in MSDN
Adding a Full Screen Feature to an MFC Application ID: Q164162
Regards
Norm
|
|
|
|
|
|
I want to create an add-in and I don't know where start.
What do I need to know in order to create an add-in for the DevStuio ?
thanks.
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called #CodeProject .
|
|
|
|
|
|
What is the format of the FAT of a file and a disk?
How to access the FAT using Visual C++?
Thanks.
Maer
|
|
|
|
|
I want to know why the results of debug version and release version are not
identical when using VC++? (My program has no memory leak.)
who can give me some advice,thanks a lot!;P
|
|
|
|
|
There are LOTS of differences between release and debug versions. You need to give more information if you want help fixing a problem. Also there are articles here on release vs debug versions.
|
|
|
|
|
I set 4 level-warning in project settings,and I am sure that all
the variables are initialized,but some results aren't the same
slightly,for instance:"Waist=75.620499,Knee=36.650490 "in release version and "Waist=75.630901,Knee=37.181105" in debug version.I suspect if the problems consist in float type,thanks for any further help.
|
|
|
|
|
you might want to try a tool like BoundsChecker or Purify. the compiler, even at level 4, doesn't catch everything.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I have recently been asked to code a function to reverse a single linked list. The code that I provided is the next:
void Reverse(Link *pList) {
Link *pH = NULL;
Link *pT = pList;
while (pList) {
pList = pList->Next;
pT->Next = pH; pH = pT; pT = pList;
}
pList = pH;
}
I didn't use any data structure (like a stack) to reverse the list because I been said that it should save memory and be very efficient.
Well, after showing my code and being reviewed I have been notified that the code works well but it shows a pretty basic skills in C++
I would like to know your opinion about it. Is there a more efficient code to reverse a single linked list? Do you agree in the fact that it shows very basic level of C++?
I have been coding in C++ for 7 years and I have been evaluated before in C++ coding with a very high scores. I am just wondering if am I missing something?
Thank you guys
|
|
|
|
|
I would say that it's true, in the sense that it's probably not using any techniques that are *not* basic, but I would say it's unfair to make such a review. The question is, does it do what it is supposed to do, and can the reviewer suggest a better way of doing things ? I can think of no better way of reversing a singly linked list than to iterate through it as you have done. In fact, by definition, there is no other was TO iterate through it.
If you're really upset about it, why not look at how STL impliments a reverse algorithm for a list ? If the review means something then it could be worthwhile presenting examples, assuming the STL doesn't do it in a cunning way that escapes me and results in a better reverse ? I don't see what else they could do though.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I would say that it's the most efficient code for reversing a linked list that I have ever seen.
|
|
|
|
|
Looks like the MS's interview question =) If you have said that this is very basic code for such a skilled C++'er you should give them something like this (it's a recursive approach)
void RecursiveReverse(List **pList)
{
if( (*pList) == NULL || (*pList)->Next == NULL )
return;
List *pOldNext = (*pList)->Next;
RecursiveReverse(&pOldNext);
(*pList)->Next->Next = *pList;
(*pList)->Next = NULL;
(*pList)= pOldNext;
}
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
Given today's definition of "efficient" (i.e. fast), recursive implementations are by nature inefficient, since each recursive call requires the creation and destruction of a stack frame. However, a recursive solution may be still be valid if it's easier to understand and maintain.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|