VOID Changer_ChangerThread( VOID ) { // Определяем поток в системе. HAB Thread = WinInitialize( 0 ); // Если это сделать не удалось - выход. if( Thread == NULLHANDLE ) { // При создании потока произошла ошибка. Thread_responds.Thread_is_created = -1; // Выход. return; } // Создаем очередь сообщений - она должна быть в каждом потоке. HMQ Message_queue = WinCreateMsgQueue( Thread, 0 ); Enhancer.Modules.Changer->Message_queue = Message_queue; // Если очередь создать не удалось - выход. if( Enhancer.Modules.Changer->Message_queue == NULLHANDLE ) { // Завершаем работу потока. WinTerminate( Thread ); // При создании потока произошла ошибка. Thread_responds.Thread_is_created = -1; // Выход. return; } // Поток создан успешно. Thread_responds.Thread_is_created = 1; // Получение и обработка сообщений, приходящих в поток. QMSG Message = {0}; while( WinGetMsg( Thread, &Message, 0, 0, 0 ) ) { // Проверяем, не идет ли следом такое же сообщение. QMSG Next_message = {0}; WinPeekMsg( Thread, &Next_message, NULLHANDLE, Message.msg, Message.msg, PM_NOREMOVE ); if( Next_message.msg == Message.msg ) if( Next_message.mp1 == Message.mp1 ) if( Next_message.mp2 == Message.mp2 ) if( Next_message.hwnd == Message.hwnd ) continue; // Обрабатываем сообщение. Changer_ChangerMessageProcessing( &Message ); } // Завершаем работу потока. WinDestroyMsgQueue( Message_queue ); WinTerminate( Thread ); DosExit( EXIT_THREAD, 0 ); }
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); }
/**************************************************************************** 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 main(int argc,char **argv, char **envp) /*----------------------------------------------------------------------------*/ /* Main routine just runs a dialog box (no main window). */ /*----------------------------------------------------------------------------*/ { HAB hab; HMQ MyQ; /* Initialize PM window environment, get a message queue */ hab = WinInitialize(0L); MyQ = WinCreateMsgQueue(hab, 0) ; WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP) DLG_MAIN_Proc, NULLHANDLE, DLG_MAIN, NULL); /* Cleanup when dialog terminates */ WinDestroyMsgQueue(MyQ); 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() */
OS2Factory::~OS2Factory() { if( m_hParentWindow ) WinDestroyWindow( m_hParentWindow ); WinDestroyMsgQueue( m_hmq ); WinTerminate( m_hab ); }
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 ; }
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); }
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(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; }
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); }
OPMinit::~OPMinit() { if (_hmq) WinDestroyMsgQueue(_hmq); if (_hab) WinTerminate(_hab); }
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 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" */ }
/************************************************************************* * Name : Finalize * * Description : This routine is called after the message dispatch loop * has ended because of a WM_QUIT message. The code will * destroy the messages queue, and window. * * Concepts : None. * * MMPM/2 API's : None. * * Parameters : None. * * Return : None. * *************************************************************************/ VOID Finalize( VOID ) { WinDestroySecondaryWindow( hwndFrame ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); } /* End of Finalize */
void addClntThrdCD::run( void * ) { HAB thab = WinInitialize( 0 ); HMQ hmq = WinCreateMsgQueue( thab , 0 ); // Attempt to create a new socket VSocket *tmpsock; tmpsock = new VSocket; if (tmpsock!=NULL) { // Connect out to the specified host on the VNCviewer listen port // To be really good, we should allow a display number here but // for now we'll just assume we're connecting to display zero tmpsock->Create(); if (tmpsock->Connect(m_host, m_port)) { // Add the new client to this server m_server->AddClient(tmpsock, TRUE, TRUE); } else { // Print up an error message WinMessageBox( HWND_DESKTOP , HWND_DESKTOP , (PSZ)"Failed to connect to listening VNC viewer", (PSZ)"Outgoing Connection", 10001 , MB_ICONEXCLAMATION | MB_OK ); delete tmpsock; } } WinDestroyMsgQueue( hmq ); WinTerminate( thab ); }
static int is_windowed_app( void ) /********************************/ { #ifdef __NT__ return( GetActiveWindow() != NULL ); #elif defined(__OS2__) int retval = 0; int rc; HMQ hMessageQueue = 0; HAB AnchorBlock = 0; AnchorBlock = WinInitialize( 0 ); if( AnchorBlock != 0 ) { hMessageQueue = WinCreateMsgQueue( AnchorBlock, 0 ); if( hMessageQueue == 0 ) { rc = WinGetLastError( AnchorBlock ); if( (rc & 0xFFFF) == PMERR_MSG_QUEUE_ALREADY_EXISTS ) { retval = 1; } } } if( hMessageQueue != 0 ) { WinDestroyMsgQueue( hMessageQueue ); } if( AnchorBlock != 0 ) { WinTerminate( AnchorBlock ); } return( retval ); #endif }
static void done_device( void ) { /* Indicates that we do not use the Presentation Manager, this */ /* will also release all associated resources.. */ WinTerminate( gr_anchor ); }
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; }
int main (int argc, char *argv[]) { HAB hab; HMQ hmq; QMSG qmsg; char text[CCHMAXPATH]; char title[CCHMAXPATH]; short a; HWND hwndClient; ULONG result; ULONG rc; /* Create a copy of the args */ /* argv[0]: progname argv[1]: installdir argv[2]: 0: query wave, 1: query mp3 argv[3]: wavefile */ numArgs=argc; hab=WinInitialize(0); if(hab) { hmq=WinCreateMsgQueue(hab,0); if(hmq) { /* Save installation directory */ /* Get our ressource dll */ WinRegisterClass(hab, CLASS_NAME, newProc,0, SLADDBYTES); if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, waveinfoStatusDialogProc, NULLHANDLE, IDDL_PMTST, 0) == DID_ERROR ) { WinDestroyMsgQueue( hmq ); WinTerminate( hab ); DosBeep(100,600); return( 1 ); } WinDestroyMsgQueue(hmq); } WinTerminate(hab); } return 0; }
VOID Installer_InstallerThread( VOID ) { // Определяем поток в системе. HAB Thread = WinInitialize( 0 ); Installer_Thread.Installer_anchor = Thread; // Если это сделать не удалось - выход. if( Thread == NULLHANDLE ) return; // Создаем очередь сообщений - она должна быть в каждом потоке. { HMQ Messages_queue = WinCreateMsgQueue( Thread, 0 ); Installer_Thread.Installer_queue = Messages_queue; // Если очередь создать не удалось - выход. if( Messages_queue == NULLHANDLE ) { WinTerminate( Thread ); return; } } // Отключаем кнопки WinPostMsg( Installer.Client_window, MY_ENABLE_BUTTONS, 0, 0 ); // Вызываем приложение на Rexx. Installer_ExecuteScript(); // Включаем кнопки WinPostMsg( Installer.Client_window, MY_ENABLE_BUTTONS, (MPARAM) 1, 0 ); // Закрываем окно. WinPostMsg( Installer.Frame_window, WM_SYSCOMMAND, (MPARAM) SC_CLOSE, 0 ); // Поток завершен. Installer_Thread.Processing = 0; // Завершаем поток. WinDestroyMsgQueue( Installer_Thread.Installer_queue ); WinTerminate( Installer_Thread.Installer_anchor ); Installer_Thread.Installer = NULLHANDLE; DosExit( EXIT_THREAD, 0 ); }
main(int argc, char *argv[], char *envp[]) { HAB hab; HMQ hmq; QMSG qmsg; char szBuf[MAX_BUF]; ATOM atom; hab = WinInitialize( 0 ); hmq = WinCreateMsgQueue( hab, 0 ); atom = WinAddAtom(WinQuerySystemAtomTable(), CLASS_NAME); if(Initialize(0, argv[0])) { WinPostQueueMsg(0, WM_QUIT, 1, 0); } else if(!InitApplication(0)) { char szEFailed[MAX_BUF]; if(NS_LoadString(0, IDS_ERROR_FAILED, szEFailed, MAX_BUF) == WIZ_OK) { sprintf(szBuf, szEFailed, "InitApplication()."); PrintError(szBuf, ERROR_CODE_SHOW); } WinPostQueueMsg(0, WM_QUIT, 1, 0); } else if(ParseUninstallIni(argc, argv)) { WinPostQueueMsg(0, WM_QUIT, 1, 0); } else if(ugUninstall.bUninstallFiles == TRUE) { if(diUninstall.bShowDialog == TRUE) hDlgUninstall = InstantiateDialog(hWndMain, DLG_UNINSTALL, diUninstall.szTitle, DlgProcUninstall); else ParseAllUninstallLogs(); } if((ugUninstall.bUninstallFiles == TRUE) && (diUninstall.bShowDialog == TRUE)) { while ( WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0 ) ) WinDispatchMsg( hab, &qmsg ); } /* Do clean up before exiting from the application */ DeInitialize(); WinDeleteAtom(WinQuerySystemAtomTable(), atom); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); }
/********************** 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 */ }
_WCRTLINK void __FiniDefaultWin() { //================================== if( _MainWindow != 0 ) { WinDestroyWindow( _MainWindow ); } if( hMessageQueue != 0 ) { WinDestroyMsgQueue( hMessageQueue ); } WinTerminate( _AnchorBlock ); }
int main (void) { HAB hab ; HMQ hmq ; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; return 0 ; }
int winmain() { HAB hab = NULLHANDLE; HMQ hmq = NULLHANDLE; QMSG qmsg; HWND hwndFrame = NULLHANDLE; HWND hwndClient = NULLHANDLE; ULONG ctlData = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_TASKLIST; do { if ((hab = WinInitialize(0)) == NULLHANDLE) break; if ((hmq = WinCreateMsgQueue(hab,0)) == NULLHANDLE) break; if (!WinRegisterClass(hab, APPCLASS, ClientWndProc, CS_SIZEREDRAW, 4)) break; // Register the HanMLE and HanInputAutomata window class if (!RegisterHanAutomataClass(hab)) break; if (!RegisterHanEntryFieldControl(hab)) break; if ((hwndFrame = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE, &ctlData, APPCLASS, APPTITLE, 0, NULLHANDLE, ID_APP, &hwndClient )) == NULLHANDLE ) { printf("errorcode: %x\n",WinGetLastError(hab)); break; } WinSetWindowPos(hwndFrame,NULLHANDLE, 300,300,300,200, SWP_MOVE|SWP_SIZE); houtInit(hab,256); while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) { WinDispatchMsg(hab, &qmsg); } houtClose(); } while (FALSE); if (hmq != NULLHANDLE) WinDestroyMsgQueue(hmq); if (hab != NULLHANDLE) WinTerminate(hab); return 0; }
/*--------------------------------------------------------------------------------------*\ * Procedure to close a window and its message queue. * * Req: * * pHwndHelp ..... A pointer to HELP window handle * * pHab .......... A pointer to extract the anchor block of the window * * pHmq .......... A pointer to extract message queue of the window * * Returns: * * TRUE/FALSE .... If called sucessfully/unsucessfully * \*--------------------------------------------------------------------------------------*/ BOOL WinCloseDown(HWND *pHwndHelp, HAB *pHab, HMQ *pHmq) { if(!*pHwndHelp) /* Release HELP */ WinDestroyHelpInstance(*pHwndHelp); if(*pHmq!=NULLHANDLE) /* Release handle of message queue */ WinDestroyMsgQueue(*pHmq); if(*pHab!=NULLHANDLE) /* Release handle of anchor block */ WinTerminate(*pHab); /* Any error during WinStartUp */ if((*pHab==NULLHANDLE) || (*pHmq==NULLHANDLE)) return(FALSE); else return(TRUE); }
void _Optlink threadmain( void * pv ) { BOOL bSuccess; HAB hab; HMQ hmq; QMSG qmsg; PGLOBALS pg; // cast and set the void pointer coming in pg = (PGLOBALS) pv; // thread initialization hab = WinInitialize( 0 ); hmq = WinCreateMsgQueue( hab, 0 ); bSuccess = WinRegisterClass( hab, OBJECTCLASSNAME, ObjectWinProc, 0, sizeof( PGLOBALS ) ); pmassert( hab, bSuccess ); // create a window where its parent is the PM object window pg->hwndObject = WinCreateWindow( HWND_OBJECT, // parent OBJECTCLASSNAME, // class name "", // name 0, // style 0, // x,y 0, 0, // cx,cy 0, HWND_OBJECT, // owner HWND_BOTTOM, // position behind this window (nop) 0, // id (PVOID)pg, // globals pointer as control data NULL ); // presparams pmassert( hab, pg->hwndObject ); // WM_CREATE processing completed; application has completely initialized WinPostMsg( pg->hwndClient, WM_USER_ACK, (MPARAM)WM_CREATE, 0 ); // dispatch messages; these messages will be mostly user-defined messages while( WinGetMsg ( hab, &qmsg, 0, 0, 0 )) { WinDispatchMsg ( hab, &qmsg ); } // wrap up WinDestroyWindow ( pg->hwndObject ); WinDestroyMsgQueue ( hmq ); WinTerminate ( hab ); return; }