질문하신 내용들은 원래 모두 그렇습니다.
1. ShowWindow에서 다른 프로그램이 TopMost로 나올수 없습니다.
- 해당 process가 메세지를 받아줘야하구..
- 프로그램을 데스크탑 최상위로 보내는 API는
SetForgroundWindow라는 함수인데..
현재 Input Focus가 가 있는 Process에서 호출해줘야 가능합니다.
2. DestoryWindow는
msdn을 살표보시구요
http://msdn.microsoft.com/ko-kr/library/windows/desktop/ms632682(v=vs.85).aspx
Remarks부분을 보시면
"A thread cannot use DestroyWindow to destroy a window created by a different thread"
위와같은 구문이 있습니다.
window를 생성한 thread에서는 DestroyWindow가 동작한다는 뜻이죠
다른 Process의 window-handle르 FindWindow로 찾아서
DestroyWindow를 호출한다고 window가 destory되지 않습니다.
일반적으로 다른 프로그램을 종료할때..
메인WINDOW에대가 WM_CLOSE 메세지나 WM_QUIT 를 던지거나
확실하게는 TerminateProcess로 process를 죽여버리는 방법을 씁니다.
이상입니다.
축구 님이 쓰신 글 :
:
: HWND wnd = ::FindWindow( "TfrmStatMain", NULL );
:
: if( wnd )
: {
: ::ShowWindow( wnd, SW_SHOW );
: return;
: }
:
: AnsiString strParameter;
: AnsiString strRunFile;
:
: strParameter.sprintf( "%s\r\n%s\r\n%s\r\n2", strname, strID,strPWD );
: strRunFile.sprintf( "%sOper_Hist.exe", ExtractFilePath( Application->ExeName ).c_str() );
: ShellExecute( NULL, NULL, strRunFile.c_str(), strParameter.c_str(), NULL, 0);
:
:
: 위처럼 별도프로세스를 실행을 시키는데 저기에서 ShowWindow하면 2번째 실행시켰을때 그창이 메인창 위에 나와야 정상인거 같으느데 안나오는게 이상하고요
:
: 메인을 종료할때
:
: HWND wnd = ::FindWindow( "TfrmStatMain", NULL );
:
: if( wnd )
: {
: ::CloseWindow( wnd );
: return;
: }
:
:
:
: 메인 FormClose할때 위에 처럼 해주는데 저 외부 프로그램은 종료가 안되는데 왜그러는건가요??
:
: DestroyWindow(wnd); 이것도 마찬가지로 안되네요 어떻게해야 메인 종료되면 외부 프로그램도 같이 종료 시킬수 있을까요?