Click here to Skip to main content
15,906,624 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 25-Nov-11 14:24
professional Randor 25-Nov-11 14:24 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 15:19
professionaljkirkerx25-Nov-11 15:19 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Chuck O'Toole25-Nov-11 15:05
Chuck O'Toole25-Nov-11 15:05 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 15:20
professionaljkirkerx25-Nov-11 15:20 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Erudite_Eric26-Nov-11 9:15
Erudite_Eric26-Nov-11 9:15 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx26-Nov-11 12:37
professionaljkirkerx26-Nov-11 12:37 
QuestionRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 26-Nov-11 13:35
professional Randor 26-Nov-11 13:35 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx26-Nov-11 16:39
professionaljkirkerx26-Nov-11 16:39 
That was last night after hours of coding. I will try and recreate what I had the first time.

The first time, I ran the WaitForSingleObject Loop. I was in new territory as to not knowing what to expect. The CreateProcess fired off the program, the do loop started and ran my cosmetics 1 time, then it read the while statement and paused, waiting for the CreateProcess to finish. So I played around with infinite, and determined that I don't know how to get multiple things to occur at once.

Verbatim Code: hand typed
if (CreateProcess( parameters ) 
{
do {   
   SendMessage(ProgressBar, (WPARAM)idx, NULL);
   if (idx == 100)
     idx = 0;
   idx++;

} while (WaitForSingleObject(pi.hProcess, INFINITE) == WAITOBJECT_0);


So then I just modified the code a bit to add the flavors of Chuck to it. Instead of working on the loop more, I created the SendMessage to let the parent window know that the gig was up.

//Build the Anwser File if it doesn't exist
CA_Windows *caWin = new CA_Windows;
bAreWeX64 = caWin->_getProcessorArchitecture();
lp_Parameters = caWin->_create_SQL_Installation_Parameters( bAreWeX64 );
caWin = NULL;

lp_File = sz_SQLServer_Install_FileName;
lp_Directory = sz_SQLServer_Install_FolderPath;		
	
STARTUPINFO si;
PROCESS_INFORMATION  pi;
int exit_status = 0;

memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);
	
if ( CreateProcess(lp_File, lp_Parameters, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, 0, lp_Directory, &si, &pi) )
	{
	WaitForSingleObject(pi.hProcess, INFINITE);
	GetExitCodeProcess(pi.hProcess, (unsigned long *)&exit_status);
		
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
		
	SendMessage(g_SQLServer_Install_MDIWindow, WM_COMMAND, (WPARAM)g_SQLServer_Install_IDC, (LPARAM)g_SQLServer_Install_IDM );
		Sleep(2000);
	}


Keep in mind that the program takes 30 minutes to run, so I ran the program like 12 times, while adjusting the unattended startup parameters. Then I had to modify the other programs to create the correct parameters for CreateProcess.

I did leave last night with everything working, and I converted all my ShellExecutes to CP today and tested. I was tired when I left, but will pursue the cosmetics again.
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 27-Nov-11 6:33
professional Randor 27-Nov-11 6:33 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx27-Nov-11 9:07
professionaljkirkerx27-Nov-11 9:07 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 27-Nov-11 9:16
professional Randor 27-Nov-11 9:16 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx27-Nov-11 10:16
professionaljkirkerx27-Nov-11 10:16 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 27-Nov-11 10:41
professional Randor 27-Nov-11 10:41 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx27-Nov-11 10:50
professionaljkirkerx27-Nov-11 10:50 
GeneralModulus Operator % Pin
Randor 27-Nov-11 11:23
professional Randor 27-Nov-11 11:23 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx27-Nov-11 10:44
professionaljkirkerx27-Nov-11 10:44 
QuestionSetFocus problem Pin
_Flaviu25-Nov-11 3:05
_Flaviu25-Nov-11 3:05 
QuestionRe: SetFocus problem Pin
Chris Meech25-Nov-11 3:23
Chris Meech25-Nov-11 3:23 
AnswerRe: SetFocus problem Pin
_Flaviu25-Nov-11 9:07
_Flaviu25-Nov-11 9:07 
GeneralRe: SetFocus problem Pin
Chris Meech25-Nov-11 9:18
Chris Meech25-Nov-11 9:18 
GeneralRe: SetFocus problem Pin
_Flaviu25-Nov-11 9:46
_Flaviu25-Nov-11 9:46 
GeneralRe: SetFocus problem Pin
Goto_Label_26-Nov-11 11:59
Goto_Label_26-Nov-11 11:59 
AnswerRe: SetFocus problem Pin
Jonathan Davies25-Nov-11 6:44
Jonathan Davies25-Nov-11 6:44 
QuestionCapture mouse over event on trayicon aplication Pin
lucio8124-Nov-11 2:58
lucio8124-Nov-11 2:58 
AnswerRe: Capture mouse over event on trayicon aplication Pin
Software_Developer24-Nov-11 4:56
Software_Developer24-Nov-11 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.