Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralC++ "friend" related Pin
pba_7-Jul-00 7:12
pba_7-Jul-00 7:12 
GeneralRe: C++ Pin
Kirill Sherman7-Jul-00 7:35
sussKirill Sherman7-Jul-00 7:35 
Questionstop MFC re-arranging toolbars when main window re-sized ? Pin
Steve Kearon7-Jul-00 6:12
Steve Kearon7-Jul-00 6:12 
Questionhow i use a wheel message of mouse? Pin
Member 20497-Jul-00 6:03
Member 20497-Jul-00 6:03 
GeneralPassing a CRecordset Pointer to another application through Clipboard Pin
Arvind Wadhawan7-Jul-00 2:55
sussArvind Wadhawan7-Jul-00 2:55 
GeneralRe: Passing a CRecordset Pointer to another application through Clipboard Pin
Pere Mitjavila15-Jul-00 0:07
Pere Mitjavila15-Jul-00 0:07 
GeneralRe: Passing a CRecordset Pointer to another application through Clipboard Pin
Blake Miller15-Jul-00 5:55
Blake Miller15-Jul-00 5:55 
GeneralDevice disabling Pin
cesco7-Jul-00 1:26
cesco7-Jul-00 1:26 
GeneralDoes anyone know how to start with DDK in VC6. Pin
Sajid Siraj6-Jul-00 23:52
Sajid Siraj6-Jul-00 23:52 
QuestionHow can i create an image list independent of the color supported by the system? Pin
Jiju George T6-Jul-00 23:47
Jiju George T6-Jul-00 23:47 
Generalaccess violations Pin
Member 43216-Jul-00 20:08
Member 43216-Jul-00 20:08 
GeneralRe: access violations Pin
Paolo Messina6-Jul-00 22:40
professionalPaolo Messina6-Jul-00 22:40 
GeneralRe: access violations Pin
Sam Hobbs7-Jul-00 18:01
Sam Hobbs7-Jul-00 18:01 
GeneralRe: access violations Pin
sspcmp18-Jul-00 4:51
susssspcmp18-Jul-00 4:51 
GeneralRe: access violations Pin
Sam Hobbs18-Jul-00 6:35
Sam Hobbs18-Jul-00 6:35 
QuestionAnyoune knows differences with custom controls in NT and W98??? Pin
M.Vo.6-Jul-00 20:00
M.Vo.6-Jul-00 20:00 
AnswerRe: Anyoune knows differences with custom controls in NT and W98??? Pin
pba_6-Jul-00 23:02
pba_6-Jul-00 23:02 
GeneralRe: Anyoune knows differences with custom controls in NT and W98??? Pin
M.Vo.7-Jul-00 3:24
M.Vo.7-Jul-00 3:24 
AnswerSolved: Anyoune knows differences with custom controls in NT and W98??? Pin
M.Vo.10-Jul-00 9:51
M.Vo.10-Jul-00 9:51 
QuestionAnyoune knows differences with custom controls in NT and W98??? Pin
M.Vo.6-Jul-00 20:00
M.Vo.6-Jul-00 20:00 
AnswerRe: Anyoune knows differences with custom controls in NT and W98??? Pin
Alfadhly7-Jul-00 3:47
sussAlfadhly7-Jul-00 3:47 
GeneralRe: Anyone knows differences with custom controls in NT and W98??? Pin
M.Vo.7-Jul-00 4:01
M.Vo.7-Jul-00 4:01 
QuestionAnyoune knows differences with custom controls in NT and W98??? Pin
M.Vo.6-Jul-00 19:59
M.Vo.6-Jul-00 19:59 
QuestionHow do we window associated with a process using the process id Pin
Member 7325226-Jul-00 16:55
Member 7325226-Jul-00 16:55 
AnswerRe: How do we window associated with a process using the process id Pin
Paolo Messina6-Jul-00 22:31
professionalPaolo Messina6-Jul-00 22:31 
You can enumerate all the top level windows, then call GetWindowThreadProcessId on each one until you find the same process id. However you can't say if it's the only top level window created by that process.
Try code like this:
<br />
#define TIMEOUT 20*1000<br />
<br />
struct ProcessWindow<br />
{<br />
	DWORD processID;<br />
	DWORD threadID;<br />
	HWND hwnd;<br />
};<br />
<br />
static BOOL CALLBACK EnumWindowsProc(<br />
  HWND hwnd,					// handle to the window<br />
  ProcessWindow *lParam   // application-defined value<br />
)<br />
{<br />
	DWORD processID = NULL;<br />
	DWORD threadID = GetWindowThreadProcessId(hwnd, &processID);<br />
<br />
	if (processID == lParam->processID && threadID == lParam->threadID)<br />
	{<br />
		lParam->hwnd = hwnd;<br />
		return FALSE;	// stop enum<br />
	}<br />
<br />
	return TRUE;<br />
}<br />
<br />
HWND StartApp(LPCTSTR path)<br />
{<br />
	STARTUPINFO si;<br />
	ZeroMemory(&si, sizeof(STARTUPINFO));<br />
<br />
	si.cb = sizeof(STARTUPINFO);<br />
	si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;<br />
	si.wShowWindow = SW_HIDE;<br />
<br />
	PROCESS_INFORMATION pi;<br />
<br />
	TCHAR buf[MAX_PATH];<br />
	lstrcpyn(buf, path, MAX_PATH);<br />
<br />
	if (!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE |<br />
		/*CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP | CREATE_SEPARATE_WOW_VDM<br />
		| DETACHED_PROCESS |*/ NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))<br />
		return NULL;<br />
<br />
	if(WaitForInputIdle(pi.hProcess, TIMEOUT) != 0)<br />
		return NULL;<br />
<br />
	// get the main window<br />
<br />
	ProcessWindow pw;<br />
	pw.hwnd = NULL;<br />
	pw.processID = pi.dwProcessId;<br />
	pw.threadID = pi.dwThreadId;<br />
<br />
	if (EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)(LPVOID)&pw))<br />
		return NULL;<br />
<br />
	return pw.hwnd;<br />
}<br />


I've used it with success. I hope it will work also for you.
Cheers,
Paolo.

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.