BOOL CALLBACK enum_windows_impl (HWND current_window, LPARAM lParam) { TCHAR window_name[8]; TCHAR module_path[1024]; ZeroMemory (&window_name, sizeof (window_name)); if (!current_window) { return TRUE; } GetWindowText (current_window, window_name, 8); /* name length + 1 */ if (strcmp (window_name, "HexChat") == 0) { /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ ZeroMemory (&module_path, sizeof (module_path)); GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); if (strstr (module_path, "hexchat.exe")) /* We've found it, stop */ { xchat_restore_window (current_window); return FALSE; } } return TRUE; /* Keep searching */ }
void PrintWindowSettings( FILE * fp ) { int ret ; RECT r ; char buffer[MAX_VALUE_NAME] ; GetOSInfo( buffer ) ; fprintf( fp, "OSVersion=%s\n", buffer ) ; ret = GetWindowText( MainHwnd, buffer, MAX_VALUE_NAME ) ; buffer[ret]='\0'; ret = GetWindowTextLength( MainHwnd ) ; fprintf( fp, "Title (length)=%s (%d)\n", buffer, ret ) ; if( GetWindowRect( MainHwnd, &r ) ) { fprintf( fp, "WindowRect.left=%ld\n", r.left ) ; fprintf( fp, "WindowRect.right=%ld\n", r.right ) ; fprintf( fp, "WindowRect.top=%ld\n", r.top ) ; fprintf( fp, "WindowRect.bottom=%ld\n", r.bottom ) ; } if( GetClientRect( MainHwnd, &r ) ) { fprintf( fp, "ClientRect.left=%ld\n", r.left ) ; fprintf( fp, "ClientRect.right=%ld\n", r.right ) ; fprintf( fp, "ClientRect.top=%ld\n", r.top ) ; fprintf( fp, "ClientRect.bottom=%ld\n", r.bottom ) ; } ret = GetWindowModuleFileName( MainHwnd, buffer, MAX_VALUE_NAME ) ; buffer[ret]='\0'; fprintf( fp, "WindowModuleFileName=%s\n", buffer ) ; WINDOWINFO wi ; wi.cbSize = sizeof( WINDOWINFO ) ; if( GetWindowInfo( MainHwnd, &wi ) ) { fprintf( fp, "WindowInfo.cbSize=%lu\n", wi.cbSize ) ; fprintf( fp, "WindowInfo.rcWindow.left=%ld\n", wi.rcWindow.left ) ; fprintf( fp, "WindowInfo.rcWindow.right=%ld\n", wi.rcWindow.right ) ; fprintf( fp, "WindowInfo.rcWindow.top=%ld\n", wi.rcWindow.top ) ; fprintf( fp, "WindowInfo.rcWindow.bottom=%ld\n", wi.rcWindow.bottom ) ; fprintf( fp, "WindowInfo.rcClient.left=%ld\n", wi.rcWindow.left ) ; fprintf( fp, "WindowInfo.rcClient.right=%ld\n", wi.rcWindow.right ) ; fprintf( fp, "WindowInfo.rcClient.top=%ld\n", wi.rcWindow.top ) ; fprintf( fp, "WindowInfo.rcClient.bottom=%ld\n", wi.rcWindow.bottom ) ; fprintf( fp, "WindowInfo.dwStyle=%lu\n", wi.dwStyle ) ; fprintf( fp, "WindowInfo.dwExStyle=%lu\n", wi.dwExStyle ) ; fprintf( fp, "WindowInfo.dwWindowStatus=%lu\n", wi.dwWindowStatus ) ; fprintf( fp, "WindowInfo.cxWindowBorders=%u\n", wi.cxWindowBorders ) ; fprintf( fp, "WindowInfo.cyWindowBorders=%u\n", wi.cyWindowBorders ) ; fprintf( fp, "WindowInfo.wCreatorVersion=%d\n", wi.wCreatorVersion ) ; } WINDOWPLACEMENT wp; wp.length=sizeof(WINDOWPLACEMENT) ; if( GetWindowPlacement( MainHwnd, &wp ) ) { fprintf( fp, "WindowPlacement.length=%u\n", wp.length ) ; fprintf( fp, "WindowPlacement.flags=%u\n", wp.flags ) ; fprintf( fp, "WindowPlacement.showCmd=%u\n", wp.showCmd ) ; fprintf( fp, "WindowPlacement.ptMinPosition.x=%ld\n", wp.ptMinPosition.x ) ; fprintf( fp, "WindowPlacement.ptMinPosition.y=%ld\n", wp.ptMinPosition.y ) ; fprintf( fp, "WindowPlacement.ptMaxPosition.x=%ld\n", wp.ptMaxPosition.x ) ; fprintf( fp, "WindowPlacement.ptMaxPosition.y=%ld\n", wp.ptMaxPosition.y ) ; fprintf( fp, "WindowPlacement.rcNormalPosition.left=%ld\n", wp.rcNormalPosition.left ) ; fprintf( fp, "WindowPlacement.rcNormalPosition.right=%ld\n", wp.rcNormalPosition.right ) ; fprintf( fp, "WindowPlacement.rcNormalPosition.top=%ld\n", wp.rcNormalPosition.top ) ; fprintf( fp, "WindowPlacement.rcNormalPosition.bottom=%ld\n", wp.rcNormalPosition.bottom ) ; } fprintf( fp, "IsIconic=%d\n", IsIconic( MainHwnd ) ) ; fprintf( fp, "IsWindow=%d\n", IsWindow( MainHwnd ) ) ; fprintf( fp, "IsWindowUnicode=%d\n", IsWindowUnicode( MainHwnd ) ) ; fprintf( fp, "IsWindowVisible=%d\n", IsWindowVisible( MainHwnd ) ) ; fprintf( fp, "IsZoomed=%d\n", IsZoomed( MainHwnd ) ) ; fprintf( fp, "ScaleX=%d\n", GetDeviceCaps(GetDC(MainHwnd),LOGPIXELSX) ) ; fprintf( fp, "ScaleY=%d\n", GetDeviceCaps(GetDC(MainHwnd),LOGPIXELSY) ) ; }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if ( message == WM_DESTROY ) { DestroyWindow( (HWND)hWnd ); UnregisterClass( WndClassName, g_hInstance ); } if ( WM_INPUT == message && gRawInputWnd != NULL ) { BYTE state; WORD code = GetRawInputCode( (void*)lParam, &state ); LPARAM Param = 0; #ifdef FUJITSU_BUILD if (code == 94 || code == 96) { // Check to make sure we're the foreground application HWND fWin = GetForegroundWindow(); if (fWin) { char nameBuf[512]; int numChars = GetWindowModuleFileName(fWin, nameBuf, 512); nameBuf[numChars] = '\0'; if (strstr(nameBuf, "awt.dll")) { SetEvent(hEvtKiller); } } return 1; } #endif switch (code) { case RAWINPUT_DETAILS: Param = sage_UserEvent_INFO; ; break; case RAWINPUT_GUIDE: Param = sage_UserEvent_GUIDE; break; case RAWINPUT_TVJUMP: Param = sage_UserEvent_LIVE_TV; break; case RAWINPUT_QUIT: Param = sage_UserEvent_POWER_OFF; break; case RAWINPUT_STANDBY: Param = 0; break; case RAWINPUT_OEM1: Param = sage_UserEvent_CUSTOM1; break; case RAWINPUT_OEM2: Param = sage_UserEvent_CUSTOM2; break; case RAWINPUT_MYTV: Param = sage_UserEvent_RECORDINGS; break; case RAWINPUT_MYVIDEOS: Param = sage_UserEvent_VIDEO_LIBRARY; break; case RAWINPUT_MYPICTURES: Param = sage_UserEvent_PICTURE_LIBRARY; break; case RAWINPUT_MYMUSIC: Param = sage_UserEvent_MUSIC; break; case RAWINPUT_RECORDEDTV: Param = sage_UserEvent_RECORDINGS; break; case RAWINPUT_DVDANGLE: Param = sage_UserEvent_DVD_ANGLE_CHANGE; break; case RAWINPUT_DVDAUDIO: Param = sage_UserEvent_DVD_AUDIO_CHANGE; break; case RAWINPUT_DVDMENU: Param = sage_UserEvent_DVD_MENU; break; case RAWINPUT_DVDSUBTITLE: Param = sage_UserEvent_DVD_TITLE_MENU; break; case RAWINPUT_OEM_RED: Param = sage_UserEvent_RATE_DOWN; break; case RAWINPUT_OEM_GREEN: Param = sage_UserEvent_RATE_UP; break; case RAWINPUT_OEM_YELLOW: Param = sage_UserEvent_OPTIONS; break; case RAWINPUT_OEM_BLUE: Param = sage_UserEvent_WATCHED; break; case RAWINPUT_GREEN_HOME: Param = sage_UserEvent_HOME; break; case 0: #ifndef FUJITSU_BUILD if ( LastCmd == 0 ) Param = sage_UserEvent_HOME; else #endif Param = 0; break; } if (!ignorePowerOff || Param != sage_UserEvent_POWER_OFF) { LastCmd = code; if ( Param ) PostMessage(gRawInputWnd,WM_USER + 234,wParam,Param); return 1; } } return DefWindowProc(hWnd, message, wParam, lParam); }