Hi,
I am trying to launch winword from my java application.Word application is getting launched successfully. But word application window is going in background on Vista (losing focus).But same code works well on XP.
In Xp word application window gets focus.
I tried below to bring Word Application in Front ..but not getting correct results
WINWAKEUP_API int WakeUp(TCHAR WndTitle[])
{
TCHAR String[255]= {0};
_tcscpy(String,WndTitle);
EnumWindows(XEnumProc,(LPARAM)String);
return 0;
}
BOOL CALLBACK XEnumProc(HWND hWnd, LPARAM lParam)
{
HWND hTest = NULL;
TCHAR title[280];
if (!hWnd)
return TRUE; // Not a window
if (!::IsWindowVisible(hWnd))
return TRUE; // Not visible
GetWindowText(hTest, "Test1", 6);
GetWindowText(hWnd, title, sizeof(title));
if(_tcsstr(title, (TCHAR *)lParam)) {
SwitchToThisWindow(hWnd,TRUE);
//SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
SetWindowPos(HWND_TOPMOST,hTest,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
HWND hActiveWnd = ::SetActiveWindow(hTest);
::SetForegroundWindow(hTest);
SetFocus(hActiveWnd);
return FALSE;
}
return TRUE;
}
Can anybody pls help in fixing this issue ?
Thanks,
Sanjay