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

C / C++ / MFC

 
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 
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 
I noticed that, but didn't question it, was focused on the message pump.

Well it works like a rolex now. I can cancel the installation, and it exits clean. I put my cosmetics in, but changed it to a more simple format. I put a flipflop in, but can't remember how to flipflop with a simple command. bFlipFlop++ or something.

The progress bar updates clean, and I can grab the main window, and mdi child and move it around while running now. Overall, the end results is a much cleaner operation, and all the gears seem to be turning right now.

I need to go back and load you up with some 5's for the help. And then update the rest of my code after further testing to confirm I got it right. The upgrade was well worth the effort, and I learned more about the messaging system today.

I'm not sure if I'm done, but wish to thank you for helping me to get a better understanding of win32 api.

The sample should give you a good idea of what I'm up to, perhaps there's something in the message that can tell me if the user canceled the operation, versus the operation exiting clean.

//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);

int ndx = 0;
BOOL bFlipFlop = FALSE;

if ( CreateProcess(lp_File, lp_Parameters, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, 0, lp_Directory, &si, &pi) ) {
		
while(WAIT_TIMEOUT == WaitForSingleObject(pi.hProcess, 10))	{			
     MSG oMSG;
     while(::PeekMessage(&oMSG, NULL, 0,0, PM_NOREMOVE)) {			
	if(::GetMessage(&oMSG, NULL, 0,0) ) {
	     ::TranslateMessage(&oMSG);
	     ::DispatchMessage(&oMSG);
	}
	else {					
	     break;
	}
	// Run the Cosmetics on the MDI Window
	if (bFlipFlop == TRUE) {					
		SetWindowText(g_SQLServer_Install_Progress_Bar, L"Installing SQL Server Express 2008 Advanced");
	}
	else {				
		SetWindowText(g_SQLServer_Install_Progress_Bar, L"Installation may take up to 30 minutes");					
	}
				
	SendMessage(g_SQLServer_Install_Progress_Bar, PBM_SETPOS, (WPARAM)ndx, 0);
	UpdateWindow(g_SQLServer_Install_MDIWindow);

	if (ndx != 99) { 
	ndx++;					
	} 
	else { 
	ndx = 0; 
	}			
     }
   }		
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);

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 
AnswerRe: Capture mouse over event on trayicon aplication Pin
Satheesh154624-Nov-11 17:18
Satheesh154624-Nov-11 17:18 
GeneralRe: Capture mouse over event on trayicon aplication Pin
Richard MacCutchan24-Nov-11 21:39
mveRichard MacCutchan24-Nov-11 21:39 
QuestionHow to get close event of form view in MFC Pin
Amrit Agr24-Nov-11 1:53
Amrit Agr24-Nov-11 1:53 
AnswerRe: How to get close event of form view in MFC Pin
Schehaider_Aymen24-Nov-11 2:46
Schehaider_Aymen24-Nov-11 2:46 

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.