Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateProcess and EnumChildWindows()

Status
Not open for further replies.

Baral

Technical User
Apr 5, 2001
2
JP
Hi,
I want to place the cursor(text) in a specific line of a file in the Notepad, when i will click on a button from some other application.
For that i am using CreateProcess();
Then I am getting the window using FindWindow();
Then i am proceesing the child of the Notepad which is of CEdit type...
The problem that i am facing is if i am running as an executable then the cursor is staying at line 1...But if i am executing step wise (F5 key) then the cursor is going to the desired line...
Pls help me...I am in great problem....
Below i am also giving the code....
void CButtonWindow::HandleButton()
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_FORCEONFEEDBACK;
BOOL bSuccess = CreateProcess(NULL,"Notepad c:\\a.txt",NULL,NULL,FALSE, NORMAL_PRIORITY_CLASS, NULL,"C:\\", &si,
&pi ); if(bSuccess){
HWND hWnd = ::FindWindow("Notepad","a - Notepad");
if(hWnd)
EnumChildWindows(hWnd, EnumProc, (LPARAM)&pi);
CloseHandle(pi.hThread);
}

BOOL CALLBACK EnumProc(HWND hChild, LPARAM lParam){
PROCESS_INFORMATION* pi = (PROCESS_INFORMATION*)lParam;
int index=SendMessage(hChild,EM_LINEINDEX,5,0); // put the cursor on line 6
SendMessage(hChild,EM_SETSEL,index,index);
return FALSE;
}






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top