void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect) { WinHandle handle = (WinHandle)GetHWND(); if(handle) { #ifdef __WXPALMOS6__ if(rect) { RectangleType dirtyRect; dirtyRect.topLeft.x = rect->GetX() - 1; dirtyRect.topLeft.y = rect->GetY() - 1; dirtyRect.extent.x = rect->GetWidth() + 1; dirtyRect.extent.y = rect->GetHeight() + 1; WinInvalidateRect(handle, &dirtyRect); } else { WinInvalidateWindow(handle); } #else // __WXPALMOS5__ WinSetActiveWindow (handle); #endif } }
bool DebugScreen( void ) { if( !WndMain ) return( FALSE ); if( FocusWnd && WinIsWindow( GUIGetHAB(), FocusWnd ) && FocusWnd != WinQueryFocus( HWND_DESKTOP, 0 ) ) { WinSetFocus( HWND_DESKTOP, FocusWnd ); } if( ActiveWnd && WinIsWindow( GUIGetHAB(), ActiveWnd ) && ActiveWnd != WinQueryActiveWindow( HWND_DESKTOP, 0 ) ) { WinSetActiveWindow( HWND_DESKTOP, ActiveWnd ); } return( FALSE ); }
void SwitchTo( TASKDATA* data ) { SWP swp; if( WinQueryWindowPos( data->hWindow, &swp )) { if( swp.fl & ( SWP_HIDE | SWP_MINIMIZE )) { // window is hidden or minimized: restore and activate HSWITCH hsw = WinQuerySwitchHandle( data->hWindow, data->pid ); if( hsw ) { // first check if the thing is hidden if( swp.fl & SWP_HIDE ) { WinSetWindowPos( data->hWindow, 0, 0, 0, 0, 0, SWP_SHOW ); } if( !WinSwitchToProgram( hsw )) { // OK, now we have the program active, but it's // probably in the background... WinSetWindowPos( data->hWindow, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER ); } } } else { // not minimized: see if it's active HWND hwndActive = WinQueryActiveWindow( HWND_DESKTOP ); if( hwndActive != data->hWindow ) { // not minimized, not active: WinSetActiveWindow( HWND_DESKTOP, data->hWindow ); } } } }
void Window::activate( BOOL active ) { if( active ) WinSetActiveWindow( HWND_DESKTOP, hWndFrame ); }
main( /* INT argc, CHAR *argv[], CHAR *envp[] */ ) { QMSG qmsg; // message queue ULONG fWndCtrlData; // game Window style flags BOOL fRegistered; // // RECTL RectWinPos; // needed when resizing the window // LONG cxScreen; // LONG cyScreen; INT rc; ERRORID error; static CHAR szClientClass[] = "bermuda.child"; // pszProgName = argv[0]; // get the full qualified program name if( ( hab = WinInitialize(0) ) == NULLHANDLE ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); return 1; } if( (hmq = WinCreateMsgQueue( hab, 0 ) ) == NULLHANDLE ){ error = WinGetLastError( hab ); DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); WinTerminate( hab ); return 1; } fRegistered = WinRegisterClass( hab, szClientClass, (PFNWP)WndProc, CS_SIZEREDRAW | CS_MOVENOTIFY, 0 ); if( !fRegistered ){ rc = WinGetLastError( hab ); DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 1; } fWndCtrlData = FCF_MINMAX | FCF_TASKLIST | FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MENU | FCF_ICON | FCF_AUTOICON; /* FCF_ACCELTABLE */ // use these later hwndFrame = WinCreateStdWindow( HWND_DESKTOP, // parent window NULL, //WS_ANIMATE, // don't make window visible yet &fWndCtrlData, // window parameters, defined above szClientClass, // window class, def. above pszAppName, // Title Bar text 0, // client window style 0, // resources are bound within the .exe IDR_MAIN, // frame-window identifier (see .rc) &hwndMain ); // output client-window handle if( hwndFrame == NULLHANDLE ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 150, BEEP_WARN_DUR); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 1; } // allocate space for the gameboard // GBoard = new GRAPHBOARD( 6, 9 ); // initialize the help facility HelpInit.cb = sizeof(HELPINIT); HelpInit.pszTutorialName = NULL; HelpInit.phtHelpTable = (PHELPTABLE)MAKELONG(HELP_TABLE, 0xFFFF ); HelpInit.hmodHelpTableModule = NULLHANDLE; HelpInit.hmodAccelActionBarModule = NULLHANDLE; HelpInit.idAccelTable = 0; HelpInit.idActionBar = 0; HelpInit.pszHelpWindowTitle = "Help for Bermuda Triangle"; HelpInit.fShowPanelId = CMIC_HIDE_PANEL_ID; HelpInit.pszHelpLibraryName = "bermuda.hlp"; hwndHelp = WinCreateHelpInstance( hab, &HelpInit ); if( !hwndHelp || HelpInit.ulReturnCode ){ // Help instance creation failed WinMessageBox( HWND_DESKTOP, hwndMain, "Couldn't create help instance.\nHelp will be disabled.\n" \ "To use the online help the file bermuda.hlp must either be " \ "in the current working directory or in one of the " \ "directories listed in your HELP environment variable.", "Error when using WinCreateHelpInstance", 0, MB_OK | MB_INFORMATION ); } else { if ( !WinAssociateHelpInstance( hwndHelp, hwndFrame ) ) WinMessageBox( hwndMain, hwndFrame, "Couldn't associate help instance.\nHelp will be disabled.", "Error when using WinAssociateHelpInstance", 0, MB_OK | MB_INFORMATION ); } LONG cxScreen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); LONG cyScreen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); wcprintf("jetzt kommt WinSetWindowPos in main: %d %d", cxScreen *2 / 3, cyScreen * 2 / 3 ); WinSetWindowPos( hwndFrame, NULLHANDLE, cxScreen / 6, cyScreen / 6, cxScreen * 2 / 3, cyScreen * 2 / 3, SWP_SIZE | SWP_MOVE ); wcprintf("fertig mit WinSetWindowPos"); InfoData.SetLineStyle( IDC_DIAGONALS_AND_VERTICALS ); InfoData.SetSound( TRUE ); // ReadProfile( hab ); // Now we can make the active window visible: if( !WinShowWindow( hwndFrame, TRUE ) ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 150, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 200, BEEP_WARN_DUR ); } // Now we can bring the window to the foreground // (it doesn't matter if this isn't successful) WinSetActiveWindow( HWND_DESKTOP, hwndFrame ); // get / dispatch message loop while( WinGetMsg( hab, (PQMSG)&qmsg, NULLHANDLE, 0L, 0L ) ) WinDispatchMsg( hab, (PQMSG)&qmsg ); // clean up WinDestroyWindow( hwndFrame ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 0; } // end of main
static MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { HPS hps; RECTL rc; switch( msg ) { case WM_CREATE: break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ) { case ID_UNLOCK: Say( "Unlocked" ); UnLockIt(); if( FocusWnd != NULL ) { WinSetFocus( HWND_DESKTOP, FocusWnd ); } WinSetActiveWindow( HWND_DESKTOP, hwndClient ); if( ActiveWnd != NULL ) { WinSetActiveWindow( HWND_DESKTOP, ActiveWnd ); } break; case ID_SWITCH: Say( "Switched" ); SwitchBack(); break; case ID_EXITPROG: WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 ); break; default: return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) ); } break; case WM_ERASEBACKGROUND: return( (MRESULT)TRUE ); case WM_PAINT: hps = WinBeginPaint( hwnd, 0L, &rc ); #ifdef DEBUG { POINTL pt; pt.x = 0; pt.y = 50; GpiSetColor( hps, CLR_NEUTRAL ); GpiSetBackColor( hps, CLR_BACKGROUND ); GpiSetBackMix( hps, BM_OVERPAINT ); GpiCharStringAt( hps, &pt, (LONG)strlen( Message ), Message ); } #endif WinEndPaint( hps ); break; case WM_CLOSE: WinPostMsg( hwnd, WM_QUIT, 0, 0 ); break; case WM_DESTROY: UnLockIt(); // fall thru default: return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) ); } return( FALSE ); }
BOOL SETTINGS :: Dialog (BOOL fOnlyLanguage) { #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 1" ); #endif fAutoLanguage = fOnlyLanguage; // load the main dialog window hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure), GETMODULE, ID_DLG_SETTINGS, this); // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-) g_hwndSettingsDialog = hwndDlg; #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 2" ); #endif // disable this two buttons if only language select if (fAutoLanguage) { WinEnableWindow (WinWindowFromID (hwndDlg, WID_PB_HELP), FALSE); WinEnableWindow (WinWindowFromID (hwndDlg, WID_PB_UNDO), FALSE); } HWND hwndNB = WinWindowFromID (hwndDlg, WID_NB_SETTINGS); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 3" ); #endif // set notebook background color WinSendMsg (hwndNB, BKM_SETNOTEBOOKCOLORS, MPFROMLONG (SYSCLR_DIALOGBACKGROUND), MPFROMSHORT (BKA_BACKGROUNDPAGECOLORINDEX)); // set tab dimensions WinSendMsg (hwndNB, BKM_SETDIMENSIONS, MPFROM2SHORT (80, 25), MPFROMSHORT (BKA_MAJORTAB)); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 4" ); #endif ULONG idPage[COUNT_PAGES]; USHORT i, cPages; if (fOnlyLanguage) { cPages = 1; idPage[0] = (ULONG) WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L, MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE, BKA_LAST)); WinSendMsg (hwndNB, BKM_SETTABTEXT, MPFROMLONG (idPage[0]), MPFROMP (pszPageTab[COUNT_PAGES-1])); hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure, GETMODULE, ID_DLG_SETTINGSPAGE4, this); } else { cPages = COUNT_PAGES; // insert empty pages for (i = 0; i < cPages; i++) { idPage[i] = (ULONG) WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L, MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE, BKA_LAST)); WinSendMsg (hwndNB, BKM_SETTABTEXT, MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i])); } // open and assign dialogs to pages hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page1Procedure, GETMODULE, ID_DLG_SETTINGSPAGE1, this); hwndPage[1] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page2Procedure, GETMODULE, ID_DLG_SETTINGSPAGE2, this); hwndPage[2] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page3Procedure, GETMODULE, ID_DLG_SETTINGSPAGE3, this); hwndPage[3] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure, GETMODULE, ID_DLG_SETTINGSPAGE4, this); } #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 5" ); #endif // combine dlg-handle and page ids for (i = 0; i < cPages; i++) WinSendMsg (hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMLONG (idPage[i]), MPFROMHWND (hwndPage[i])); /* if (fAutoLanguage) WinSendMsg (hwndNB, BKM_TURNTOPAGE, MPFROMLONG (idPage[0]), 0L); #if (COUNT_PAGES != 4) #warning FIXME settings.cpp 264 or so ... #endif */ for (i = 0; i < cPages; i++) WinSendMsg (hwndPage[i], UM_SETTINGS2DIALOG, 0,0); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 6" ); #endif //WinSetFocus (WinWindowFromID (hwndDlg, WID_PB_OK), TRUE); //WinSetFocus( hwndPage[0], TRUE ); WinSetActiveWindow( HWND_DESKTOP, hwndPage[0] ); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 7" ); #endif WinProcessDlg (hwndDlg); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 7.5" ); #endif WinDestroyWindow (hwndDlg); #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 8" ); #endif // it ain't the best way to do it, but ... SetIdlePriority(QueryFlag(SEI_IDLEPRIORITY)); for (i = 0; i < COUNT_PAGES; i++) hwndPage[i] = NULL; hwndDlg = NULLHANDLE; #ifdef _DOLOGDEBUG_ LogDebug( "Dialog: checkpoint 9" ); #endif return TRUE; }
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение. // Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением. MRESULT EXPENTRY Installer_ClientWindowProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter ) { switch( Message ) { // Выполняем действия при создании окна. case WM_CREATE: { WinPostMsg( Window, MY_CREATE, 0, 0 ); } return 0; case MY_CREATE: { // Задаем заголовок окна приложения. if( Installer.Code_page == RUSSIAN ) strcpy( Installer.Frame_window_title, StrConst_RU_Title ); else strcpy( Installer.Frame_window_title, StrConst_EN_Title ); WinSetWindowText( Installer.Frame_window, Installer.Frame_window_title ); // Устанавливаем картинку в левом верхнем углу окна. WinSendMsg( Installer.Frame_window, WM_SETICON, (MPARAM) WinLoadPointer( HWND_DESKTOP, NULLHANDLE, 1 ), 0 ); // Задаем расположение окна. { INT X_Screen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); INT Y_Screen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); INT Window_width = X_Screen / 3; if( X_Screen < 1024 ) Window_width *= 1.25; INT Window_height = Y_Screen / 3; if( X_Screen < 1024 ) Window_height *= 1.25; INT Window_position_X = ( X_Screen - Window_width ) / 2; INT Window_position_Y = ( Y_Screen - Window_height ) / 2 + ( Y_Screen - Window_height ) / 4 / 2; WinSetWindowPos( Installer.Frame_window, HWND_TOP, Window_position_X, Window_position_Y, Window_width, Window_height, SWP_ZORDER | SWP_MOVE | SWP_SIZE | SWP_NOADJUST ); WinSetActiveWindow( HWND_DESKTOP, Installer.Frame_window ); } // Добавляем его в список окон. { SWCNTRL Task; HSWITCH Switch_handle = NULLHANDLE; bzero( &Task, sizeof( SWCNTRL ) ); Task.hwnd = Installer.Frame_window; Task.hwndIcon = (HPOINTER) WinSendMsg( Installer.Frame_window, WM_QUERYICON, 0, 0 ); WinQueryWindowProcess( Installer.Frame_window, &Task.idProcess, NULL ); strcpy( Task.szSwtitle, Installer.Frame_window_title ); Task.uchVisibility = SWL_VISIBLE; Task.fbJump = SWL_JUMPABLE; Switch_handle = WinCreateSwitchEntry( Installer.Application, &Task ); WinChangeSwitchEntry( Switch_handle, &Task ); } // Создаем поля ввода в окне рабочей области. ClientWindow_CreatePage( Installer.Client_window ); } return 0; // Передвигаем поля ввода. case MY_APPLY_LAYOUT: { LitApplyLayout( &Client_Window.Layout ); } return 0; // Включаем и отключаем поля ввода. case MY_ENABLE_BUTTONS: { ULONG Action = (ULONG) First_parameter; WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Install_button_ID ), Action ); WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Remove_button_ID ), Action ); WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Cancel_button_ID ), Action ); if( !Action ) WinSendMsg( WinWindowFromID( Installer.Frame_window, FID_SYSMENU ), MM_SETITEMATTR, MPFROM2SHORT( SC_CLOSE, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_DISABLED, MIA_DISABLED ) ); else WinSendMsg( WinWindowFromID( Installer.Frame_window, FID_SYSMENU ), MM_SETITEMATTR, MPFROM2SHORT( SC_CLOSE, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_DISABLED, 0 ) ); } return 0; // Обрабатываем нажатия на кнопки. case WM_COMMAND: { ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter ); if( WM_Control_Button_ID == Client_Window.Settings.Install_button_ID ) { StartInstallerThread( NIA_INSTALL ); } if( WM_Control_Button_ID == Client_Window.Settings.Remove_button_ID ) { StartInstallerThread( NIA_REMOVE ); } if( WM_Control_Button_ID == Client_Window.Settings.Cancel_button_ID ) { WinPostMsg( Installer.Frame_window, WM_SYSCOMMAND, (MPARAM) SC_CLOSE, 0 ); } } return 0; // Закрашиваем пространство окна. case WM_PAINT: { RECT Rectangle = {0}; HPS Presentation_space = WinBeginPaint( Window, 0, &Rectangle ); if( Presentation_space ) { LONG Color_table[ 256 ]; bzero( Color_table, sizeof( Color_table ) ); GpiQueryLogColorTable( Presentation_space, 0, 0, 256, Color_table ); LONG Color_index = ( 256 - 1 ); WinQueryPresParam( Window, PP_BACKGROUNDCOLOR, 0, NULL, sizeof( Color_table[ Color_index ] ), &Color_table[ Color_index ], QPF_NOINHERIT ); GpiCreateLogColorTable( Presentation_space, 0, LCOLF_CONSECRGB, 0, 256, Color_table ); WinFillRect( Presentation_space, &Rectangle, Color_index ); WinEndPaint( Presentation_space ); } } return 0; // Сообщаем окну рамки, что содержимое окна рабочей области закрашивать не следует. case WM_ERASEBACKGROUND: return (MPARAM) 0; // Выполняем действия при нажатии на кнопку закрытия окна. case WM_CLOSE: { // Убираем окно приложения из списка окон. WinRemoveSwitchEntry( WinQuerySwitchHandle( Installer.Frame_window, 0 ) ); // Передаем сообщение обработчику. WinDefWindowProc( Window, Message, First_parameter, Second_parameter ); } return 0; } // Возврат. return WinDefWindowProc( Window, Message, First_parameter, Second_parameter ); }