Click here to Skip to main content
15,900,482 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Change Window Color Pin
Mark Salsbery10-Aug-07 5:50
Mark Salsbery10-Aug-07 5:50 
GeneralRe: Change Window Color Pin
WayneK10010-Aug-07 6:19
WayneK10010-Aug-07 6:19 
GeneralRe: Change Window Color [modified] Pin
Mark Salsbery10-Aug-07 6:32
Mark Salsbery10-Aug-07 6:32 
GeneralRe: Change Window Color Pin
WayneK10010-Aug-07 8:44
WayneK10010-Aug-07 8:44 
GeneralRe: Change Window Color Pin
Mark Salsbery10-Aug-07 9:50
Mark Salsbery10-Aug-07 9:50 
AnswerRe: Change Window Color Pin
Nishad S8-Aug-07 18:40
Nishad S8-Aug-07 18:40 
AnswerRe: Change Window Color Pin
Hamid_RT8-Aug-07 19:19
Hamid_RT8-Aug-07 19:19 
QuestionWhy I can't bring focus to IE browser created thru createprocess Pin
sdittmer8-Aug-07 12:54
sdittmer8-Aug-07 12:54 
I created a IE browser process using the MFC createprocess function.
Later on in my main program, I want to set focus on and put the IE broswer process as the top window using SetWindowPos function. It tried this and it doesn't work when SetWindowPos is called. If I launch a MS paint program using the same functionality, the SetWindowPos function does bring the MS paint window to the top and with focus.

Here is some sample code.
Create the IE process and get the window handle to it.
HANDLE hProcess = NULL;
PROCESS_INFORMATION processInfo;
STARTUPINFO startupInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
if(::CreateProcess("C:\\Program files\\Internet Explorer\\iexplore.exe",
"",
NULL, // process security
NULL, // thread security
FALSE, // no inheritance
0, // no startup flags
NULL, // no special environment
NULL, // default startup directory
&startupInfo,
&processInfo))
{ /* success */
Sleep(1500);
::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);//Iterate all windows
hProcess = processInfo.hProcess;
} /* success */

int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
{
DWORD pID;
DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);//get process id
if (TpID == (DWORD)param)
{
apphwnd=hwnd;//hwnd is the window handle
return false;
}
return true;
}

// later on in the program I try to bring the window for the IE process on top and into focus
if(apphwnd!=NULL)//check for window handle
{ // window exists already
CString windowText ;
CWnd* window = CWnd::FromHandle(
apphwnd);
if (window != NULL )
{

BOOL res =::SetWindowPos(apphwnd, HWND_TOP, 0, 0, 0, 0,SWP_NOMOVE | SWP_SHOWWINDOW); window->SetFocus();

}
The result of this is the IE window does not get put on top.
I then trie the same code with the MS paint program process (at "C:\\WINDOWS\\system32\\mspaint.exe") and it does work. The window gets put on top. What do I need to do to get IE to respond to my call ?



Stephen Da-Terminator
SCI Solutions

AnswerRe: Why I can't bring focus to IE browser created thru createprocess Pin
Mark Salsbery8-Aug-07 13:05
Mark Salsbery8-Aug-07 13:05 
GeneralRe: Why I can't bring focus to IE browser created thru createprocess Pin
sdittmer8-Aug-07 14:37
sdittmer8-Aug-07 14:37 
QuestionThread function parameter Pin
alberthyc8-Aug-07 10:31
alberthyc8-Aug-07 10:31 
AnswerRe: Thread function parameter Pin
koumodaki8-Aug-07 10:41
koumodaki8-Aug-07 10:41 
GeneralRe: Thread function parameter Pin
alberthyc8-Aug-07 11:08
alberthyc8-Aug-07 11:08 
GeneralRe: Thread function parameter [modified] Pin
alberthyc8-Aug-07 11:21
alberthyc8-Aug-07 11:21 
GeneralRe: Thread function parameter Pin
Nishad S8-Aug-07 18:45
Nishad S8-Aug-07 18:45 
QuestionSetting multile line text in a document Pin
koumodaki8-Aug-07 10:23
koumodaki8-Aug-07 10:23 
AnswerRe: Setting multile line text in a document Pin
Reagan Conservative8-Aug-07 11:18
Reagan Conservative8-Aug-07 11:18 
AnswerRe: Setting multile line text in a document Pin
fefe.wyx8-Aug-07 14:58
fefe.wyx8-Aug-07 14:58 
QuestionWhy my MDI application closes when I close a dialog box inside? Pin
saravana0018-Aug-07 7:51
saravana0018-Aug-07 7:51 
AnswerRe: Why my MDI application closes when I close a dialog box inside? Pin
Russell'8-Aug-07 8:10
Russell'8-Aug-07 8:10 
AnswerRe: Why my MDI application closes when I close a dialog box inside? Pin
jk chan8-Aug-07 17:41
jk chan8-Aug-07 17:41 
QuestionHelp With Arrays Pin
simoncoul8-Aug-07 7:46
simoncoul8-Aug-07 7:46 
AnswerRe: Help With Arrays [modified] Pin
Russell'8-Aug-07 7:59
Russell'8-Aug-07 7:59 
GeneralRe: Help With Arrays Pin
simoncoul8-Aug-07 8:16
simoncoul8-Aug-07 8:16 
GeneralRe: Help With Arrays Pin
jhwurmbach8-Aug-07 8:28
jhwurmbach8-Aug-07 8:28 

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.