MRESULT EXPENTRY MeasureDlgProc(HWND hwnd, ULONG mess, MPARAM mp1, MPARAM mp2) { switch(mess) { case WM_INITDLG: hwnd_measure = hwnd; measure_dialog_unit(); measure_setpoint(0.0, 0.0); break; case WM_COMMAND: switch(SHORT1FROMMP(mp1)) { case IDM_MEASURE_CALC: show_calc_dialog(); measure_dialog_unit(); measure_update_last(); return (MRESULT)FALSE; case IDCANCEL: WinDestroyWindow(hwnd); hwnd_measure = 0; return (MRESULT)TRUE; } break; case WM_CLOSE: WinDestroyWindow(hwnd); return (MRESULT)TRUE; case WM_DESTROY: hwnd_measure = 0; break; } return WinDefDlgProc(hwnd, mess, mp1, mp2); }
HWND bookSetup( ULONG idInitialPage ) { HWND hwndFrame; if( hwndBook ) { hwndFrame = PARENT( hwndBook ); // For some reason it is necessary to restore the notebook before // setting the frame as the active window if the frame is being // restored from a minimized state. WinSetWindowPos( hwndBook, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE ); WinSetWindowPos( hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE ); } else { FRAMECDATA fcdata; memset( &fcdata, 0, sizeof fcdata ); fcdata.cb = sizeof( FRAMECDATA ); fcdata.flCreateFlags = FRAME_FLAGS; fcdata.idResources = ID_NBFRAME; hwndFrame = WinCreateWindow( HWND_DESKTOP, WC_FRAME, NULL, WS_ANIMATE, 0, 0, 0, 0, NULLHANDLE, HWND_TOP, ID_NBFRAME, &fcdata, NULL ); if( hwndFrame ) { pfnwpFrame = WinSubclassWindow( hwndFrame, wpNBFrame ); if( pfnwpFrame ) if( CreateNotebookWindow( hwndFrame ) ) WinSetWindowText( hwndFrame, BOOK_TITLE ); else { WinDestroyWindow( hwndFrame ); hwndFrame = NULLHANDLE; } else { WinDestroyWindow( hwndFrame ); Msg( "bookSetup WinSubclassWindow RC(%X)", HWNDERR(hwndFrame) ); hwndFrame = NULLHANDLE; } } else Msg( "bookSetup WinCreateWindow of frame window RC(%X)", HABERR(0)); } if( hwndBook ) TurnToPage( idInitialPage ); return hwndFrame; }
void kstDestroy(void) { if (hwndStateCtl != NULLHANDLE) { WinDestroyWindow(hwndStateCtl) ; hwndStateCtl = NULLHANDLE ; } if (hwndStateAlt != NULLHANDLE) { WinDestroyWindow(hwndStateAlt) ; hwndStateAlt = NULLHANDLE ; } }
MRESULT EXPENTRY wpNBFrame( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { switch( msg ) { case WM_CONTROL: if( ControlMsg( hwnd, SHORT1FROMMP( mp1 ), SHORT2FROMMP( mp1 ), mp2 ) ) return 0; else break; // You need to process the SC_CLOSE WM_SYSCOMMAND message instead of // WM_CLOSE when working with frame windows. case WM_SYSCOMMAND: if( SHORT1FROMMP( mp1 ) == SC_CLOSE ) { WinDestroyWindow( hwnd ); // Don't let the WM_QUIT message through return 0; } break; // The Notebook prevents the Accelerator key processing from working // correctly so we must do another kludge. Here we close the window if // the user hit the F3 key. case WM_TRANSLATEACCEL: { PQMSG pQmsg = (PQMSG) mp1; USHORT fsFlags = SHORT1FROMMP( pQmsg->mp1 ); if( !(fsFlags & (KC_CTRL | KC_SHIFT | KC_ALT | KC_CHAR)) && (fsFlags & KC_KEYUP) && (SHORT2FROMMP( pQmsg->mp2 ) == VK_F3) ) { WinDestroyWindow( hwnd ); return (MRESULT) TRUE; } else return FALSE; } case WM_DESTROY: FreeResources(); break; } return pfnwpFrame( hwnd, msg, mp1, mp2 ); }
// ------------------------------------------------------------------------------------------------------------ int main( int argc, char **argv ) { HMQ hmq; QMSG qmsg; ULONG ulWork; SWP swp; LONG cx; // initialize globals struct to defaults memset( &globals, 0, sizeof( globals )); strcpy( globals.szRexxFileName, "DRAW.CMD" ); // parameter is a REXX filename if( argc > 1 ) { strcpy( globals.szRexxFileName, argv[ 1 ] ); } // PM application init globals.hab = WinInitialize( 0 ); hmq = WinCreateMsgQueue( globals.hab, 0); // create a frame window with listbox to display REXX diagnostic output ulWork = FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_TASKLIST; globals.hwndOutputFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulWork, WC_LISTBOX, OUTPUTCAPTION, LS_NOADJUSTPOS, (HMODULE)0, ID_RXDRAW, &globals.hwndOutputListbox ); assert( globals.hwndOutputFrame ); assert( globals.hwndOutputListbox ); // create a frame window to display REXX graphical output WinRegisterClass( globals.hab, CLASSNAME, (PFNWP)ClientWinProc, CS_SIZEREDRAW, 0 ); ulWork = FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX | FCF_MENU | FCF_ICON | FCF_TASKLIST; globals.hwndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulWork, CLASSNAME, CAPTION, 0, (HMODULE)0, ID_RXDRAW, &globals.hwndClient ); assert( globals.hwndFrame ); assert( globals.hwndClient ); // tile the two windows using shell's preferred placement for one WinQueryTaskSizePos( globals.hab, 0, &swp ); cx = (swp.cx * 2) / 3; ulWork = SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE | SWP_RESTORE; WinSetWindowPos( globals.hwndOutputFrame, HWND_TOP, swp.x+cx, swp.y, swp.cx-cx, swp.cy, ulWork ); WinSetWindowPos( globals.hwndFrame, HWND_TOP, swp.x, swp.y, cx, swp.cy, ulWork ); // message loop while( WinGetMsg( globals.hab, &qmsg, 0, 0, 0 )) WinDispatchMsg( globals.hab, &qmsg ); if( !globals.fCloseMsgSent ) { // got a WM_QUIT without WM_CLOSE; must be shutdown or Close from Window List WinPostMsg( globals.hwndObject, WM_QUIT, 0, 0 ); } // clean up WinDestroyWindow( globals.hwndFrame ); WinDestroyWindow( globals.hwndOutputFrame ); WinDestroyMsgQueue( hmq ); WinTerminate( globals.hab ); DosWaitThread( &globals.tidObject, DCWW_WAIT ); return 0; }
int main( void) { HAB hab = 0; HMQ hmq = 0; HWND hwnd = 0; int nRtn = 8; QMSG qmsg; do { Morph(); hab = WinInitialize( 0); if (!hab) break; hmq = WinCreateMsgQueue( hab, 0); if (!hmq) break; // avoid compatibility problems // RWSFULLVERSION for RwsTest v0.80 is 0x08000100 if (RwsQueryVersion( 0) < RWSFULLVERSION) { WinMessageBox( HWND_DESKTOP, 0, "Please use a newer version of the RWS08 dlls", "FPos", 1, MB_OK | MB_ERROR | MB_MOVEABLE); break; } hwnd = WinLoadDlg( HWND_DESKTOP, // parent-window NULLHANDLE, // owner-window MainWndProc, // dialog proc NULLHANDLE, // EXE module handle IDD_MAIN, // dialog id NULL); // pointer to create params if (!hwnd) break; while (WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg( hab, &qmsg); nRtn = 0; } while (fFalse); if (nRtn) DosBeep( 440, 150); if (hwnd) WinDestroyWindow( hwnd); if (hmq) WinDestroyMsgQueue( hmq); if (hab) WinTerminate( hab); return (nRtn); }
INT main(VOID) { HWND hwnd; HAB hab; HMQ hmq; QMSG qmsg; HWND hHlp; hmq = WinCreateMsgQueue(hab = WinInitialize(0), 0); hwnd = WinLoadDlg(HWND_DESKTOP, // parent NULLHANDLE, // owner dlgProc, // dialog window proc NULLHANDLE, // module handle ID_MAIN, // dialog template ID NULL); // application data pointer if (hwnd) { hHlp = initHelp(hwnd); while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg(hab, &qmsg); endHelp(hwnd, hHlp); } WinDestroyWindow(hwnd); WinDestroyMsgQueue(hmq); WinTerminate(hab); return 0; } /* end main */
int main() { HMQ hmq; QMSG qmsg; ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST | FCF_ICON | FCF_MENU; CHAR szClientClass[] = "CLIENT"; hab = WinInitialize (0); hmq = WinCreateMsgQueue (hab, 0); WinRegisterClass (hab, szClientClass, (PFNWP)ClientWndProc, 0, 0); WinLoadString (hab, 0, ID_APPNAME, sizeof(szTitle), szTitle); hWndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, szClientClass, szTitle, 0, 0, ID_APPNAME, &hWndClient); while (WinGetMsg (hab, &qmsg, 0, 0, 0)) WinDispatchMsg (hab, &qmsg); WinDestroyWindow (hWndFrame); WinDestroyMsgQueue (hmq); WinTerminate (hab); return (0); }
HWND LoadAndAssociate( HWND hwndFrame, PPAGEDATA pPageData, PPAGESELECTNOTIFY ppsn ) { HWND hwndDlg = WinLoadDlg( hwndFrame, ppsn->hwndBook, pPageData->pfnwpDlg, 0, pPageData->idDlg, NULL ); if( hwndDlg ) { // Allow the dialog to give us its initial focus id. pPageData->idFocus = (ULONG) WinSendMsg( hwndDlg, UM_GET_FOCUS_ID, NULL, NULL ); // Associate the dialog with the page. if( WinSendMsg( ppsn->hwndBook, BKM_SETPAGEWINDOWHWND, MPFROMP( ppsn->ulPageIdNew ), MPFROMLONG( hwndDlg ) ) ) WinSetWindowPtr( hwndDlg, QWL_USER, pPageData ); else { WinDestroyWindow( hwndDlg ); hwndDlg = NULLHANDLE; Msg( "LoadAndAssociate SETPAGEWINDOWHWND RC(%X)", HWNDERR( ppsn->hwndBook ) ); } } else Msg( "LoadAndAssociate WinLoadDlg RC(%X)", HWNDERR( hwndBook ) ); return hwndDlg; }
void main (void) { QMSG qmsg; HMQ hmq; HWND hwndClient; ULONG flFrameFlags; WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); /* get access to shared memory */ DosGetNamedSharedMem((PVOID*)&memptr, MEM_NAME, PAG_READ); if (!memptr) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, " FreeType/2 is not running!", "Error", 0, MB_OK | MB_ERROR); else { meminfo = memptr->address; if (meminfo->signature != 0x46524545) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, " FreeType/2 is not running!", "Error", 0, MB_OK | MB_ERROR); else { flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST ; WinRegisterClass(hab, "MyClass", (PFNWP) ClientWndProc, CS_SIZEREDRAW, 0); hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, "MyClass", "FreeType/2 Heap Usage", 0, (HMODULE) NULL, 0, &hwndClient); WinSetVisibleRegionNotify(hwndClient, TRUE); /* make titlebar text look better */ WinSetPresParam(WinWindowFromID(hwndFrame, FID_TITLEBAR), PP_FONTNAMESIZE, 9, (PVOID)"8.Helv"); WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 350, 42, SWP_MOVE | SWP_SIZE | SWP_SHOW); while (WinGetMsg(hab, &qmsg, (HWND) NULL, 0, 0)) WinDispatchMsg(hab, &qmsg); WinSetVisibleRegionNotify(hwndClient, FALSE); } } /* free shared memory block */ DosFreeMem(memptr); WinDestroyWindow(hwndFrame); WinDestroyMsgQueue(hmq); WinTerminate(hab); }
VOID ExitListRoutine( ULONG ExitReason ) { SpyDeRegister( SpyInstance ); /* De-Register with our DLL */ if ( hSwitch != NULLH ) WinRemoveSwitchEntry(hSwitch); if ( hwndFrame != NULLH ) WinDestroyWindow(hwndFrame); if ( hmq != NULLH ) WinDestroyMsgQueue(hmq); /* cleanup STRINGTABLEs loaded for us... */ FreeStringTable(sizeof(Strings) / sizeof(Strings[0]), /* max # Strings[] */ Strings); /* start of string table */ FreeStringTable(sizeof(Controls) / sizeof(Controls[0]), /* max # Controls[] */ Controls); /* start of string table */ if ( hmodNLS != 0 ) DosFreeModule(hmodNLS); if ( hab != 0 ) WinTerminate(hab); DosExitList(EXLST_EXIT, NULL); /* Indicate "done" */ }
launchPad::~launchPad() { LPList *lplTemp, *lplTemp2; lpSaveObjectList(); lpFreeObjectList(); if(hwndLaunchPad) WinDestroyWindow(hwndLaunchPad); /* Remove this pad from the list of pads */ lplTemp=lplAllLPads; if(lplTemp->lpPad==this) { lplAllLPads=lplTemp->lplNext; delete(lplTemp); } else { while(lplTemp->lplNext) { if(lplTemp->lplNext->lpPad==this) { lplTemp2=lplTemp->lplNext; lplTemp->lplNext=lplTemp->lplNext->lplNext; delete(lplTemp2); break; } lplTemp=lplTemp->lplNext; } } }
int main(int argc,char **argv) { ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST | FCF_SIZEBORDER | FCF_SHELLPOSITION | FCF_MINBUTTON | FCF_MAXBUTTON; QMSG qmsg; HAB hab; HMQ hmq; hab = WinInitialize(0); if (hab == (HAB)0) return 1; hmq = WinCreateMsgQueue(hab,0); if (hmq == (HMQ)0) return 1; WinRegisterClass(hab,"HelloWnd",(PFNWP)HelloWndProc,CS_SIZEREDRAW,0); HelloWnd = WinCreateStdWindow(HWND_DESKTOP,WS_VISIBLE,&flFrameFlags,"HelloWnd","Hello world",0L,0/*NULLHANDLE*/,ID_PRIMWIN,&HelloWndClient); if (HelloWnd == (HWND)0 || HelloWndClient == (HWND)0) return 1; while (WinGetMsg(hab,&qmsg,0/*NULLHANDLE*/,0,0)) WinDispatchMsg(hab,&qmsg); WinDestroyWindow(HelloWnd); WinDestroyMsgQueue(hmq); WinTerminate(hab); return 0; }
VOID Finalize(VOID) { APIRET rc; // Save Options to INI file SaveScoresToIni(); SaveOptionsToIni(); WinStoreWindowPos(szAppName, szKeyPosition, hwndFrame); // close the game engine and the associated async thread, if any Eng_Close(); dprint("gameEng close\n"); GfxEng->close(); dprint("GfxEng close\n"); // close the sound engine // this also takes care of any sound threads SndEng->close(); dprint("SoundEng close"); if( hrgnInvalid) GpiDestroyRegion( hpsClient, hrgnInvalid); if( hpsClient) { GpiAssociate( hpsClient, NULLHANDLE); GpiDestroyPS( hpsClient); } if( hpsPaint) GpiDestroyPS( hpsPaint); dprint("Destroyed hPS\n"); DestroyHelpInstance(); if (hwndFrame) WinDestroyWindow( hwndFrame); if (hmqMain) WinDestroyMsgQueue( hmqMain); if (habMain) WinTerminate( habMain); if (hGame) DosClose(hGame); dprint("Destroyed handles\n"); if (debOut) { fprintf(debOut, "Exiting MakMan/2\n"); fflush(debOut); fclose(debOut); } DosExit( EXIT_PROCESS, 0); } /* end Finalize() */
int main (void) { static CHAR szClientClass [] = "EndJoin" ; static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST ; HAB hab ; HMQ hmq ; HWND hwndFrame, hwndClient ; QMSG qmsg ; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ; hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, szClientClass, NULL, 0L, 0, 0, &hwndClient) ; while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg (hab, &qmsg) ; WinDestroyWindow (hwndFrame) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; return 0 ; }
/**************************************************************************** Main Program start *****************************************************************************/ int main() { HMQ hmq; QMSG qmsg; hab = WinInitialize (0); hmq = WinCreateMsgQueue (hab, 0); hWndFrame = WinLoadDlg (HWND_DESKTOP, HWND_DESKTOP, MainDlgProc, 0, IDD_CLOCK,NULL); TitleDefProc = WinSubclassWindow(WinWindowFromID(hWndFrame, FID_TITLEBAR), (PFNWP)TitleBarProc ); SysMenuDefProc = WinSubclassWindow(WinWindowFromID(hWndFrame, FID_SYSMENU), (PFNWP)SysMenuProc ); SysMenuButton = WinLoadPointer (HWND_DESKTOP, 0, IDD_CLOCK); WinQueryPointerInfo(SysMenuButton,&PointerInfo); WinSendMsg (hWndFrame, WM_SETICON, (MPARAM)SysMenuButton, NULL); while (WinGetMsg (hab, &qmsg, 0, 0, 0)) WinDispatchMsg (hab, &qmsg); WinDestroyWindow (hWndFrame); WinDestroyMsgQueue (hmq); WinTerminate (hab); return (0); }
int SampleSlideTextProc(WND wnd, int nMsg, int wParam, int lParam) { WND slideAppWND; int ScreenWidth, ScreenHeight; int bHandled = FALSE; switch(nMsg) { case AWM_CREATE: // Create Window for this application GdiGetScreenInfo( &ScreenWidth, &ScreenHeight ); // We are going to use whole screen slideAppWND = WinCreateWindow( PrvSlideTextMainProc, 0, 0, ScreenWidth, ScreenHeight, WND_PANEL ); bHandled = TRUE; break; case AWM_DESTROY: WinDestroyWindow(wnd); bHandled = TRUE; break; default: break; } return bHandled; }
int main() { ULONG fl = FCF_SIZEBORDER | FCF_TASKLIST | FCF_ICON | FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_SHELLPOSITION; static CHAR szClass [] = "Tray Example" ; HMQ hmq ; QMSG qmsg ; LONG i; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinRegisterClass (hab, (PSZ)szClass, (PFNWP)windowproc, CS_SIZEREDRAW, 0) ; hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE, &fl, (PSZ)szClass, (PSZ)szClass, 0L, NULL, 100, &hwndClient) ; for(i=100;i<=104;i++) hIcon[i-100] = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,i); while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) WinDispatchMsg (hab, &qmsg) ; WinDestroyWindow (hwndFrame) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; return 0 ; }
VOID _Optlink fntMoveThread(PTHREADINFO pti) { // give ourselves higher priority... // otherwise we can't compete with Netscape and Win-OS/2 windows. DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, PRTYD_MAXIMUM, 0); // current thread if ( (G_pHookData->hwndPagerMoveThread = WinCreateWindow(HWND_OBJECT, WC_STATIC, "", 0, 0, 0, 0, 0, 0, HWND_BOTTOM, 0, NULL, NULL)) && (G_pfnwpMoveStaticOrig = WinSubclassWindow(G_pHookData->hwndPagerMoveThread, fnwpMoveThread)) ) { QMSG qmsg; while (WinGetMsg(pti->hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg(pti->hab, &qmsg); } // destroy the object window V0.9.12 (2001-05-12) [umoeller] WinDestroyWindow(G_pHookData->hwndPagerMoveThread); G_pHookData->hwndPagerMoveThread = NULLHANDLE; }
OS2Factory::~OS2Factory() { if( m_hParentWindow ) WinDestroyWindow( m_hParentWindow ); WinDestroyMsgQueue( m_hmq ); WinTerminate( m_hab ); }
VOID terminateTimerMgr(HMQ hmq) { g.is.expired = 1; if (g.timerThrd.hwnd) WinDestroyWindow(g.timerThrd.hwnd); WinDestroyMsgQueue(hmq); WinTerminate(g.timerThrd.hab); DosExit(EXIT_THREAD, 0); }
void ui_cmdline_show_help(unsigned int num_options, cmdline_option_ram_t *opt, void *arg) { int chars; // maximum area could be shown char format[13]; unsigned int i; HWND hwnd; // // calculate maximum width of text // size_t jmax = 0; for (i = 0; i < num_options; i++) { size_t j = strlen(opt[i].name) + 1; j += strlen((opt[i].need_arg && cmdline_options_get_param(i) != NULL) ? cmdline_options_get_param(i) : "") + 1; jmax = j > jmax ? j : jmax; j += strlen(cmdline_options_get_description(i)) + 1; chars = j > chars ? j : chars; } sprintf(format, "%%-%ds%%s", jmax); // // open dialog // hwnd = cmdopt_dialog((HWND)arg); if (!hwnd) { return; } // // fill dialog with text // for (i = 0; i < num_options; i++) { char *textopt = lib_msprintf("%s %s", opt[i].name, (opt[i].need_arg && cmdline_options_get_param(i) != NULL) ? cmdline_options_get_param(i) : ""); char *text = lib_msprintf(format, textopt, cmdline_options_get_description(i)); lib_free(textopt); WinSendMsg(hwnd, WM_INSERT, text, (void*)TRUE); lib_free(text); } // // MAINLOOP // WinProcessDlg(hwnd); // // WinProcessDlg() does NOT destroy the window on return! Do it here, // otherwise the window procedure won't ever get a WM_DESTROY, // which we may want :-) // WinDestroyWindow(hwnd); }
WEXPORT WClient::~WClient() { /***************************/ disconnect(); if( _clientWindow != NULLHANDLE ) { WinDestroyWindow( _clientWindow ); } }
void PM_mainloop(VOID *arg) { SIZEL sizelHps = {0,0}; HAB hab; // Anchor Block to PM HMQ hmq; // Handle to Msg Queue HDC hdc; // Handle to Device (Window-Screen) QMSG qmsg; // Msg Queue Event video_canvas_t *ptr=(video_canvas_t*)arg; hab = WinInitialize(0); // Initialize PM hmq = WinCreateMsgQueue(hab, 0); // Create Msg Queue // 2048 Byte Memory (Used eg for the Anchor Blocks WinRegisterClass(hab, szClientClass, PM_winProc, CS_SIZEREDRAW, 2048); (*ptr)->hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_ANIMATE, &flFrameFlags, szClientClass, szTitleBarText, 0L, 0, 0, &((*ptr)->hwndClient)); WinSetWindowPos((*ptr)->hwndFrame, HWND_TOP, 0, 0, (*ptr)->width*stretch, (*ptr)->height*stretch+ WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR), // +1 with gcc? SWP_SIZE|SWP_SHOW|SWP_ZORDER|SWP_ACTIVATE); // Make visible, resize, top window WinSetWindowPtr((*ptr)->hwndClient, QWL_USER, (VOID*)(*ptr)); // -------------------- // maybe ---> WM_CREATE // -------------------- hdc = WinOpenWindowDC((*ptr)->hwndFrame); (*ptr)->hps = GpiCreatePS(WinQueryAnchorBlock((*ptr)->hwndFrame), hdc, &sizelHps, PU_PELS|GPIF_DEFAULT|GPIT_MICRO|GPIA_ASSOC); // GPIT_NORMAL does also work with vac++ (*ptr)->pbmi = lib_calloc(1, 16+sizeof(RGB2)*256); (*ptr)->pbmi->cbFix = 16; // Size of cbFix, cPlanes, cBitCount = Begin of RGB2 (*ptr)->pbmi->cPlanes = 1; (*ptr)->pbmi->cBitCount = 8; // Using 8-bit color mode (*ptr)->palette=(RGB2*)((ULONG)(*ptr)->pbmi+(*ptr)->pbmi->cbFix); vidlog("pbmiAllocated",0); (*ptr)->pbmi_initialized = TRUE; // All stuff for pbmi created // DosReleaseMutexSem(hmtx); // gfx init end //----------------------- while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg (hab, &qmsg) ; // (*ptr)->pbmi_initialized = FALSE; DosRequestMutexSem(hmtx, SEM_INDEFINITE_WAIT); GpiDestroyPS((*ptr)->hps); WinDestroyWindow ((*ptr)->hwndFrame); // why was this commented out? --> WM_CLOSE ?? WinDestroyMsgQueue(hmq); // Destroy Msg Queue WinTerminate (hab); // Release Anchor to PM lib_free((*ptr)->pbmi); // is this the right moment to do this??? // lib_free(*ptr); // Vice crashes... why??? This must be done in the main thread! exit(0); // Kill VICE, All went OK }
int main(int argc, char **argv) { ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_HIDEBUTTON | FCF_SHELLPOSITION | FCF_TASKLIST; HAB hab; HMQ hmq; HWND Client; QMSG qmsg; arglist args; int python_tid; /* init PM and create message queue */ hab = WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); /* create a (hidden) Window to house the window procedure */ args.Frame = WinCreateStdWindow(HWND_DESKTOP, 0, &FrameFlags, NULL, "PythonPM", 0L, 0, 0, &Client); /* run Python interpreter in a thread */ args.argc = argc; args.argv = argv; args.running = 0; if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) { /* couldn't start thread */ WinAlarm(HWND_DESKTOP, WA_ERROR); PythonRC = 1; } else { /* process PM messages, until Python exits */ while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg(hab, &qmsg); if (args.running > 0) DosKillThread(python_tid); } /* destroy window, shutdown message queue and PM */ WinDestroyWindow(args.Frame); WinDestroyMsgQueue(hmq); WinTerminate(hab); return PythonRC; }
_WCRTLINK void __FiniDefaultWin() { //================================== if( _MainWindow != 0 ) { WinDestroyWindow( _MainWindow ); } if( hMessageQueue != 0 ) { WinDestroyMsgQueue( hMessageQueue ); } WinTerminate( _AnchorBlock ); }
/********************** Start of main procedure ***********************/ void main( ) { HMQ hmq; /* Message queue handle */ HWND hwndClient; /* Client area window handle */ HWND hwndFrame; /* Frame window handle */ QMSG qmsg; /* Message from message queue */ ULONG flCreate; /* Window creation control flags*/ Hab = WinInitialize( NULL ); /* Initialize PM */ hmq = WinCreateMsgQueue( Hab, 0 ); /* Create a message queue */ WinRegisterClass( /* Register window class */ Hab, /* Anchor block handle */ "MyWindow", /* Window class name */ MyWindowProc, /* Address of window procedure */ CS_SIZEREDRAW, /* Class style */ 0 /* No extra window words */ ); flCreate = FCF_STANDARD & /* Set frame control flags to */ ~FCF_SHELLPOSITION; /* standard except for shell */ /* positioning. */ hwndFrame = WinCreateStdWindow( HWND_DESKTOP, /* Desktop window is parent */ 0L, /* No frame styles */ &flCreate, /* Frame control flag */ "MyWindow", /* Client window class name */ "", /* No window text */ 0L, /* No special class style */ NULL, /* Resource is in .EXE file */ ID_WINDOW, /* Frame window identifier */ &hwndClient /* Client window handle */ ); WinSetWindowPos( hwndFrame, /* Shows and activates frame */ HWND_TOP, /* window at position 100, 100, */ 100, 100, 400, 200, /* and size 200, 200. */ SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_SHOW ); /************************************************************************/ /* Get and dispatch messages from the application message queue */ /* until WinGetMsg returns FALSE, indicating a WM_QUIT message. */ /************************************************************************/ while( WinGetMsg( Hab, &qmsg, NULL, 0, 0 ) ) { WinDispatchMsg( Hab, &qmsg ); } WinDestroyWindow( hwndFrame ); /* Tidy up... */ WinDestroyMsgQueue( hmq ); /* and */ WinTerminate( Hab ); /* terminate the application */ }
/*-------------------------------------------------- * Destroys the window *--------------------------------------------------*/ PMWindow& PMWindow::destroy() { // Prevent recursive destroying win_wrapper = TRUE; if( WinIsWindow( PMGUI::hab(), handle())) if( !WinDestroyWindow( handle())) PM_THROW_GUIERROR(); return *this; }
BOOL APIENTRY WprogressBar(HWND hParent, HWND hOwner, PPROGRESSDLG ppd) { QMSG qmsg; HWND hwnd; PPRGSAPPDATA pad; BOOL rc = FALSE; // allocate storage for application data if (!(pad = (PPRGSAPPDATA)malloc(sizeof(PRGSAPPDATA)))) return FALSE; memset(pad, 0, sizeof(PRGSAPPDATA)); pad->ppd = ppd; // ottiene tempo di inizio pad->start = WinGetCurrentTime(pad->hab = WinQueryAnchorBlock(hOwner)) / 1000; // window handles if (ppd->fl & PRGSS_BITMAP) { SIZEL szl; WqueryBitmapSize(pad->ppd->hbmp, &szl); pad->cxbmp = szl.cx; } /* endif */ if (NULLHANDLE != (hwnd = WinLoadDlg(hParent, hOwner, ProgressDlgProc, hmod, DLG_PROGRESS, pad))) { if (!ppd->pszPrgrss) ppd->pszPrgrss = SZ_PROGRESS; if (!ppd->pszTime) ppd->pszTime = SZ_ELAPSTIME; if (ppd->pszStop) WinSetDlgItemText(hwnd, BTN_STOP, ppd->pszStop); pad->hOwner = WinQueryWindow(hwnd, QW_OWNER); WinEnableWindow(pad->hOwner, FALSE); for(;;) { if (WinGetMsg(pad->hab, &qmsg, NULLHANDLE, 0, 0)) { // loop standard if (qmsg.msg == PRGSM_END && qmsg.hwnd == hwnd) { if (pad->qQuit.msg) WinPostMsg(pad->qQuit.hwnd, pad->qQuit.msg, pad->qQuit.mp1, pad->qQuit.mp2); break; } // end if WinDispatchMsg(pad->hab, &qmsg); } else { // WM_QUIT pad->qQuit = qmsg; if(qmsg.hwnd == NULLHANDLE) // SHUTDOWN WinPostMsg(hwnd, WM_CLOSE, MPFROMLONG(TRUE), NULL); else if(qmsg.hwnd == HWNDFROMMP(qmsg.mp2)) // TASKLIST WinPostMsg(hwnd, WM_CLOSE, 0L, 0L); else // chiusura regolare: termina break; } // end if } // end forever WinSetFocus(HWND_DESKTOP, hOwner); WinDestroyWindow(hwnd); WinEnableWindow(pad->hOwner, TRUE); rc = TRUE; } // end if free(pad); return rc; }
OWindow& OWindow::initReplace(const ULONG id, SWP& swp) { HWND _hwnd = WinWindowFromID(parent, id); if (!_hwnd) throw OPMException(OCL::error(137), 0); WinQueryWindowPos(_hwnd, &swp); WinDestroyWindow(_hwnd); return(*this); }