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

C / C++ / MFC

 
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.
QuestionSDI with an MDI style close button? Pin
kumaichi6-Jul-00 13:50
kumaichi6-Jul-00 13:50 
GeneralChanging the background color of a read-only CEdit Pin
Joan Murt6-Jul-00 10:11
sussJoan Murt6-Jul-00 10:11 
GeneralRe: Changing the background color of a read-only CEdit Pin
Sam Hobbs7-Jul-00 6:07
Sam Hobbs7-Jul-00 6:07 
GeneralRe: Changing the background color of a read-only CEdit Pin
Philip Nicoletti7-Jul-00 6:46
Philip Nicoletti7-Jul-00 6:46 
GeneralThank you for your help, but there is still a little problem Pin
Joan Murt11-Jul-00 9:27
sussJoan Murt11-Jul-00 9:27 
GeneralRe: Changing the background color of a read-only CEdit Pin
Joan Murt12-Jul-00 8:02
sussJoan Murt12-Jul-00 8:02 
GeneralCMonthCalCtrl -> Need help on getting Date... Pin
MaverickTC6-Jul-00 9:55
MaverickTC6-Jul-00 9:55 
GeneralGet active view from modeless dialog Pin
Christoph Rupp6-Jul-00 8:33
sussChristoph Rupp6-Jul-00 8:33 
GeneralRe: Get active view from modeless dialog Pin
Mike Dunn6-Jul-00 8:50
Mike Dunn6-Jul-00 8:50 
GeneralRe: Get active view from modeless dialog Pin
Christoph Rupp6-Jul-00 21:45
sussChristoph Rupp6-Jul-00 21:45 
GeneralRe: Get active view from modeless dialog Pin
Paolo Messina6-Jul-00 23:07
professionalPaolo Messina6-Jul-00 23:07 
GeneralWriting VxDs in VC Pin
Sajid Siraj6-Jul-00 7:25
Sajid Siraj6-Jul-00 7:25 
QuestionHow to scroll to a row in a CListCtrl Pin
Tony10-Jul-00 3:43
Tony10-Jul-00 3:43 
AnswerRe: How to scroll to a row in a CListCtrl Pin
Mike Dunn10-Jul-00 6:26
Mike Dunn10-Jul-00 6:26 
Generalneed help with PJNaughter's CSerialPort class Pin
acidmarco9-Jul-00 23:13
acidmarco9-Jul-00 23:13 
GeneralRe: need help with PJNaughter's CSerialPort class Pin
Remus Lazar10-Jul-00 22:23
Remus Lazar10-Jul-00 22:23 
GeneralWindows Address Book Pin
Cirmu Nicolae9-Jul-00 22:53
sussCirmu Nicolae9-Jul-00 22:53 

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.