コード例 #1
0
ファイル: TRAYEX.C プロジェクト: OS2World/UTIL-WPS-Systray-2
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 ;

}
コード例 #2
0
ファイル: threads.cpp プロジェクト: OS2World/MM-SOUND-Minta
VOID MP3DISPLAY :: SaveAllThread (PVOID pv)
{
    PMP3DISPLAY   pmp3d = PMP3DISPLAY (pv);
    CHAR          ach[_MAX_PATH];

    HMQ   hmq = WinCreateMsgQueue (hab, 0);;

    for (ULONG i = 0; i < pmp3d->CountFilesInList (); i++)
    {
        pmp3d->QueryFile (ach, sizeof (ach), i);

        pmp3d->pmp3 = new MP3 (ach);
        if (pmp3d->pmp3->IsValid ())
        {
            pmp3d->AdjustCurrent (FALSE);
            if (pmp3d->QueryMP3 ()->SaveTag ())
            {
                *(pmp3d->pc) += 1;
                if (pmp3d->pstatd)
                    pmp3d->pstatd->Advance (ach);
            }
            delete pmp3d->pmp3;
        }

        if (pmp3d->fBreak)
            break;
    }

    if (pmp3d->pstatd)
        pmp3d->pstatd->Finished ();

    WinDestroyMsgQueue (hmq);
}
コード例 #3
0
ファイル: samp3.C プロジェクト: OS2World/DEV-SAMPLES-PM-mclb
/*----------------------------------------------------------------------------*/
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;
}                                                                               
コード例 #4
0
ファイル: dbgdata.c プロジェクト: ArmstrongJ/open-watcom-v2
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
}
コード例 #5
0
KPMMainThread::KPMMainThread()
{
    SetTID( 1 );

    SetHAB( WinInitialize( 0 ));
    SetHMQ( WinCreateMsgQueue( GetHAB(), 0 ));
}
コード例 #6
0
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 ;
     }
コード例 #7
0
nsresult
nsAppShell::Init()
{
  // a message queue is required to create a window but
  // it is not necessarily created yet
  if (WinQueryQueueInfo(HMQ_CURRENT, NULL, 0) == FALSE) {
    // Set our app to be a PM app before attempting Win calls
    PPIB ppib;
    PTIB ptib;
    DosGetInfoBlocks(&ptib, &ppib);
    ppib->pib_ultype = 3;

    HAB hab = WinInitialize(0);
    WinCreateMsgQueue(hab, 0);
  }

  if (!sMsgId) {
    sMsgId = WinAddAtom( WinQuerySystemAtomTable(), "nsAppShell:EventID");
    WinRegisterClass((HAB)0, "nsAppShell:EventWindowClass", EventWindowProc, NULL, 0);
  }

  mEventWnd = ::WinCreateWindow(HWND_DESKTOP,
                                "nsAppShell:EventWindowClass",
                                "nsAppShell:EventWindow",
                                0,
                                0, 0,
                                10, 10,
                                HWND_DESKTOP,
                                HWND_BOTTOM,
                                0, 0, 0);
  NS_ENSURE_STATE(mEventWnd);

  return nsBaseAppShell::Init();
}
コード例 #8
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);
}
コード例 #9
0
ファイル: pmhelp.c プロジェクト: Azarien/open-watcom-v2
static VOID APIENTRY ServiceRequests( VOID )
{
    USHORT              len;
    pmhelp_packet       data;

    WinCreateMsgQueue( Hab, 0 );
    for( ;; ) {
        if( DosRead( InStream, &data, sizeof( data ), &len ) != 0 ) break;
        if( len != sizeof( data ) ) break;
        switch( data.command ) {
        case PMHELP_LOCK:
            PidDebugee = data.pid;
            TidDebugee = data.tid;
            LockIt();
            break;
        case PMHELP_UNLOCK:
            PidDebugee = data.pid;
            TidDebugee = data.tid;
            UnLockIt();
            break;
        case PMHELP_EXIT:
            WinPostMsg( hwndClient, WM_QUIT, 0, 0 );/* Cause termination*/
            break;
        }
        WinInvalidateRegion( hwndClient, 0L, FALSE );
    }
    Say( "Read Failed" );
}
コード例 #10
0
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 );
}
コード例 #11
0
ファイル: ftmem.c プロジェクト: DavidGriffith/finx
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);
}
コード例 #12
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);
}
コード例 #13
0
ファイル: hellopm.c プロジェクト: joncampbell123/doslib
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;
}
コード例 #14
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 */
コード例 #15
0
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);
}
コード例 #16
0
VOID _System threadTimerMgr(ULONG ul) {
   HMQ hmq;
   QMSG qmsg;

   DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 31, 0);
   // inizializzazione
   hmq = WinCreateMsgQueue((g.timerThrd.hab = WinInitialize(0)), 0);
   WinCancelShutdown(hmq, TRUE);
   // registra classe WC_TIMERMGRCLASS
   if (!WinRegisterClass(g.timerThrd.hab, WC_TIMERMGRCLASS,
                         threadTimerMgrProc, 0L, 0L))
      terminateTimerMgr(hmq);

   // crea l'object window
   if (!(g.timerThrd.hwnd = WinCreateWindow(HWND_OBJECT, WC_TIMERMGRCLASS,
                                            NULL, 0, 0, 0, 0, 0, NULLHANDLE,
                                            HWND_BOTTOM, 0, NULL, NULL)))
      terminateTimerMgr(hmq);

   // message loop
   while (WinGetMsg(g.timerThrd.hab, &qmsg, NULLHANDLE, 0, 0))
      WinDispatchMsg(g.timerThrd.hab, &qmsg);

   // terminazione
   terminateTimerMgr(hmq);
}
コード例 #17
0
ファイル: video_gpi.c プロジェクト: BigBoss21X/vice-emu
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
}
コード例 #18
0
OPMinit::OPMinit(const ULONG queueSize) 
{
 _hab = WinInitialize(0);

 if(_hab)
   _hmq = WinCreateMsgQueue(_hab, queueSize);
 else
   throw OVioException(OCL::error(130), 0);
}
コード例 #19
0
ファイル: pythonpm.c プロジェクト: 1310701102/sl4a
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;
}
コード例 #20
0
/*--------------------------------------------------------------------------------------*\
 * Procedure to initialize a window and its message queue.                              *
 * Req:                                                                                 *
 *      pHab .......... A pointer to be filled with the anchor block of the window      *
 *      pHmq .......... A pointer to be filled with the message queue of the window     *
 * Returns:                                                                             *
 *      TRUE/FALSE .... If called sucessfully/unsucessfully                             *
\*--------------------------------------------------------------------------------------*/
BOOL    WinStartUp(HAB *pHab, HMQ *pHmq)
{
                                        /* Initialize handle of anchor block */
if((*pHab=WinInitialize(0))==NULLHANDLE)
    return(FALSE);
                                        /* Initialize handle of message queue */
if((*pHmq=WinCreateMsgQueue(*pHab, 0))==NULLHANDLE)
    return(FALSE);
return(TRUE);
}
コード例 #21
0
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 );
}
コード例 #22
0
ファイル: uninstall.c プロジェクト: rn10950/RetroZilla
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 ); 

}
コード例 #23
0
/*************************************************************************
 * Name         : InitializeDialog
 *
 * Description  : This function performs the necessary initializations and
 *                setups that are required to show/run a dialog box as a
 *                main window.  The message queue will be created, as will
 *                the dialog box.
 *
 * Concepts     : Secondary Windows is used to create and show a dialog box.
 *                A system clock is displayed till the application is loaded.
 *
 * MMPM/2 API's : WinLoadSecondaryWindow
 *                WinQuerySecondaryHWND
 *
 * Parameters   : None.
 *
 * Return       : None.
 *
 *************************************************************************/
void InitializeDialog()
{
CHAR achTitle[STRING_SIZE] = "";
CHAR achDefaultSize[STRING_SIZE] = "";


   /* Initialize the Dialog window */
   hab = WinInitialize(0);

   /* create a message queue for the window */
   hmq = WinCreateMsgQueue(hab,0);


   /* Load the Dialog - This will return the Handle to the Frame */
   hwndFrame =
       WinLoadSecondaryWindow(HWND_DESKTOP
                            ,HWND_DESKTOP
                            ,(PFNWP)MainDialogProc
                            ,(HMODULE)NULL
                            ,ID_SAMPLE
                            ,(PVOID)NULL);


   /*
    * By specifying the QS_DIALOG flag we will get the handle to the Dialog of
    * the frame
    */
   hwndDiag = WinQuerySecondaryHWND(hwndFrame,QS_DIALOG);

   /* Get the string for default size */
   WinLoadString(
      hab,
      (HMODULE) NULL,
      IDS_DEFAULT_SIZE,
      (SHORT) sizeof( achDefaultSize),
      achDefaultSize);

   /* Add Default Size menu item to system menu of the secondary window. */
   WinInsertDefaultSize(hwndFrame, achDefaultSize);

   /*
    * Get the window title string from the Resource string table
    * and set it as the window text for the dialog window.
    */
   WinLoadString(
      hab,
      (HMODULE) NULL,
      IDS_MAIN_WINDOW_TITLE,
      (SHORT) sizeof( achTitle),
      achTitle);

   /* Set the Title of the Dialog */
   WinSetWindowText( hwndFrame, achTitle);

}
コード例 #24
0
ファイル: 3dsply.cpp プロジェクト: OS2World/LIB-Lib3ds
int InitPM(int mode)
{
	if ( ( mainhab = WinInitialize( 0UL ) ) == NULLHANDLE )
		return 1;
	if ( ( mainhmq = WinCreateMsgQueue( mainhab, 32UL ) ) == NULLHANDLE )
		return 2;
	if (WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,"Use DIVE calls?","2D Acceleration",0L, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE) == MBID_YES)
		OS2_WMesaInitHab(mainhab,1); else OS2_WMesaInitHab(mainhab,0);
	
	return 0;
}
コード例 #25
0
ファイル: pmdbg.c プロジェクト: Azarien/open-watcom-v2
/**********************  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    */
}
コード例 #26
0
int main (void)
     {
     HAB  hab ;
     HMQ  hmq ;

     hab = WinInitialize (0) ;
     hmq = WinCreateMsgQueue (hab, 0) ;

     WinDestroyMsgQueue (hmq) ;
     WinTerminate (hab) ;
     return 0 ;
     }
コード例 #27
0
ファイル: HEFTest.c プロジェクト: komh/hanedit2
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;
}
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;
}
コード例 #29
0
ファイル: archdep.c プロジェクト: BigBoss21X/vice-emu
void PM_open(void)
{
    APIRET rc;

    habMain = WinInitialize(0);              // Initialize PM
    hmqMain = WinCreateMsgQueue(habMain, 0); // Create Msg Queue

    // this should make sure, that the system doesn't hang because
    // vice uses 100% CPU time
    if (rc = DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, -1, 0)) {
        log_error(archlog, "DosSetPriority (rc=%li)", rc);
    }
}
// ------------------------------------------------------------------------------------------------------------
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;
}