Ejemplo n.º 1
0
Archivo: kimehook.c Proyecto: komh/kime
BOOL isHCHLB( HWND hwnd )
{
    static CHAR szBuffer[ 256 ];

    WinQueryClassName( hwnd, sizeof( szBuffer ), szBuffer );
    if( strcmp( szBuffer, WC_HCHLB ) == 0 )
        return TRUE;

    WinQueryClassName( WinQueryWindow( hwnd, QW_OWNER ), sizeof( szBuffer ), szBuffer );
    return ( BOOL )( strcmp( szBuffer, WC_HCHLB ) == 0 );
}
Ejemplo n.º 2
0
VOID PumpMessageQueue( VOID )
{
    char        class_name[80];
    QMSG        qmsg;
    ERRORID     err;
    ULONG       ulCount;

    for( ;; ) {
        DosWaitEventSem( PumpMessageSem, SEM_INDEFINITE_WAIT );
        DosResetEventSem( PumpMessageSem, &ulCount );
        WinThreadAssocQueue( GUIGetHAB(), GUIPMmq );
        while ( WinGetMsg( GUIGetHAB(), &qmsg, 0L, 0, 0 ) ) {
            WinQueryClassName( qmsg.hwnd, sizeof( class_name ), class_name );
            if (strcmp( class_name, "GUIClass" ) == 0 ||
                strcmp( class_name, "WTool" ) == 0) {
                WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
            } else {
                WinDispatchMsg( GUIGetHAB(), &qmsg );
            }
        }
        WinThreadAssocQueue( GUIGetHAB(), NULL );
        err = WinGetLastError( GUIGetHAB() );
        DosPostEventSem( PumpMessageDoneSem );
    }
}
Ejemplo n.º 3
0
// Returns true if the given window has the
// given standard class (e.g. WC_FRAME)
//--------------------------------------------------------------------------------
BOOL IsStandardWindowClass( HWND hwnd, PSZ ClassID )
{
  char szClassName[ 256 ];
  USHORT usClass;

  LogEvent( "IsStandardWindowClass" );

  if ( WinQueryClassName( hwnd,
                          sizeof( szClassName ),
                          szClassName ) == 0 )
    // not a valid window
    return FALSE;

  LogEvent( "  Valid window" );

  if ( szClassName[ 0 ] != '#' )
    // not a standard class
    return FALSE;

  LogEvent( "  Is standard class" );

  // Predefined class
  usClass = atoi( szClassName + 1 );

  LogEvent( "  usClass: %hu", usClass );
  LogEvent( "  Match class: %hu", (USHORT) ClassID );

  return usClass == (USHORT) ClassID;
}
Ejemplo n.º 4
0
Archivo: kiphook.c Proyecto: komh/kip
BOOL isInjoy( HWND hwnd )
{
    char className[ 80 ];

    WinQueryClassName( hwnd, sizeof( className ), className );

    return ( strcmp( className, WC_INJOY ) == 0 ? TRUE : FALSE );
}
Ejemplo n.º 5
0
Archivo: kimehook.c Proyecto: komh/kime
BOOL isZtelnet( HWND hwnd )
{
    UCHAR szClassName[ 256 ];

    WinQueryClassName( hwnd, sizeof( szClassName ), szClassName );

    return ( strcmp( szClassName, WC_ZTELNET ) == 0 );
}
Ejemplo n.º 6
0
void XToolBar::Attach(void)
{
   frame->frameWin->AddFrameControl(this);

   WinSetParent(winhandle, frame->frame, TRUE);
   WinSetOwner(winhandle, frame->frame);

   LONG x = borderSize, y = borderSize;
   XRect rect;
   int width = 0, height = 0;

   if (style & TB_RIGHT || style & TB_LEFT)
   {
      for (int i = 0; i < clients; i++)
      {
         clientArray[i]->clientWin->GetSize(&rect);
         if (clientArray[i]->group)
            x = borderSize;
         if (x + clientArray[i]->xOffset + rect.GetWidth() > width)
            width = x + clientArray[i]->xOffset + rect.GetWidth() + borderSize;
         x += clientArray[i]->xOffset + rect.GetWidth();
      }
      cx = width;
   }
   else
   {
      int yy = 0;

      for (int i = 0; i < clients; i++)
      {
         char className[10];

         WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className);
         className[0] = ' ';
         if (atol(className) == 2)
         {
            if (yy < borderSize * 2 + 25)
               yy = borderSize * 2 + 25;
         }
         else
         {
            clientArray[i]->clientWin->GetSize(&rect);
            if (yy < rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset)
               yy = rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset;
         }
      }
      cy = yy;
   }

   cutWindow = NULL;

   XRect rect2;

   frame->GetSize(&rect2);
   rect2.SetHeight(rect2.GetHeight() - 1);
   frame->SetSize(&rect2);
}
//---------------------------------------------------------------
void hide_scrollbars( HWND hwnd )
{
  HENUM henum;
  HWND  hwndNext;
  CHAR  szClass[8];

  henum = WinBeginEnumWindows(hwnd);
  while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) {
    WinQueryClassName( hwndNext, strlen(szClass), szClass );
    if (!strncmp(WC_SCROLLBAR, szClass, strlen(szClass) )) {
      WinShowWindow( hwndNext, FALSE );
      }
    else hide_scrollbars( hwndNext );          // recursive!
    }
  WinEndEnumWindows(henum);
  }
Ejemplo n.º 8
0
/*@ XItemDrawHandler :: XItemDrawHandler(const XWindow * w, const SHORT itemWidth, const SHORT itemHeight)
@remarks   Constructor of XItemDrawHandler
@parameters
<t 'ø' c=2>
øXWindow * w            øthe window
øSHORT itemWidth      øthe width of the items
øSHORT itemHeight      øthe height of the items
</t>
*/
XItemDrawHandler :: XItemDrawHandler(const XWindow * w, const SHORT itemWidth, const SHORT itemHeight):XHandler(OOL_ITMDRAWHANDLER, w)
{
   width = itemWidth;
   height = itemHeight;

   char str[5];

   WinQueryClassName(w->GetHandle(), 5, (PCH) str);
   str[0] = ' ';
   type = atol(str);

   if (type == 2 || type == 7)
   {
      WinSendMsg(w->GetHandle(), LM_SETITEMWIDTH, MPFROMSHORT(width), 0);
      WinSendMsg(w->GetHandle(), LM_SETITEMHEIGHT, MPFROMSHORT(height), 0);
   }
}
Ejemplo n.º 9
0
static MRESULT EXPENTRY newLaunchPadButtonProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
{
  POINTL ptl;
  HWND hwndMenu;
  WPObject * wpObject;
  LPObject* lpo;
  PDRAGINFO pDragInfo;
  static BOOL bDrawn=FALSE;
  static DRAGITEM DragItem;
  static DRAGIMAGE DragImage;
  static DRAGINFO *DragInfo;

  switch (msg)
    {

    case WM_PAINT:
      lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lpo) {
        BTNCDATA btCtrl={0};
        WNDPARAMS wndParams={0};

        // memset(&btCtrl,0,sizeof(btCtrl));
        btCtrl.cb=sizeof(btCtrl);
        if(somIsObj(lpo->wpObject)) {
          btCtrl.hImage=lpo->wpObject->wpQueryIcon();
          // memset(&wndParams,0,sizeof(wndParams));
          wndParams.fsStatus=WPM_CTLDATA;
          wndParams.cbCtlData=btCtrl.cb;
          wndParams.pCtlData=&btCtrl;
          WinSendMsg(hwnd,WM_SETWINDOWPARAMS,
                     MPFROMP(&wndParams),0);
        }
      }
      break;
    case WM_CONTEXTMENU:
      if(!SHORT2FROMMP(mp2)) {

        lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lpo) {
          wpObject=lpo->wpObject;
          if(somIsObj(wpObject)) {
            ptl.y=0;
            ptl.x=0;
            hwndMenu=wpObject->wpDisplayMenu(hwnd,hwnd,&ptl,MENU_OBJECTPOPUP,0);
          }
          return (MRESULT) TRUE;
        }
      }/* end of if(!SHORT2FROMMP(mp2)) */
      break;
    case DM_DRAGOVER:
      {
        BOOL bReturn=FALSE;

        TRY_LOUD(LP_DRAGOVER) {
        lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lpo) {
          wpObject=lpo->wpObject;
          if(somIsObj(wpObject)) {
            char chrClassName[10];
            LONG lLength;
            
            pDragInfo=(PDRAGINFO) mp1;
            hwndMenu=pDragInfo->hwndSource;
            lLength=sizeof(chrClassName);
            WinQueryClassName(hwndMenu, lLength, chrClassName);
            if(strcmp(chrClassName,"#37"))
              hwndMenu=NULL;/* Source isn't a container */
            if(!bDrawn) {
              HPS hps;
              RECTL rectl;
              SWP swp;

              /* Draw the rect */
              hps=DrgGetPS(hwnd);
              WinQueryWindowPos(hwnd,&swp);
              rectl.xLeft=1;
              rectl.yBottom=1;
              rectl.xRight=swp.cx-1;
              rectl.yTop=swp.cy-1;
              //WinDrawBorder(hps,&rectl, 3, 3, 0, 0, DB_STANDARD|DB_PATINVERT);  
              DrgReleasePS(hps);
              //bDrawn=TRUE;
            }
            bReturn=TRUE;
          }
        }
        }
        CATCH(LP_DRAGOVER)
          {
          } END_CATCH;
          if(bReturn)
            return wpObject->wpDragOver(hwndMenu,(PDRAGINFO) mp1);
          break;
      }
    case DM_DRAGLEAVE:
      {
        RECTL rectl;
        SWP swp;
        HPS hps;
        
        /* Remove target emphasis here */
        hps=DrgGetPS(hwnd);
        WinQueryWindowPos(hwnd,&swp);
        rectl.xLeft=1;
        rectl.yBottom=1;
        rectl.xRight=swp.cx-1;
        rectl.yTop=swp.cy-1;
        // WinDrawBorder(hps,&rectl,3, 3, 0, 0, DB_STANDARD|DB_PATINVERT);  
        bDrawn=FALSE;
        DrgReleasePS(hps);
        return (MRESULT) FALSE;
      } 
   case DM_DROP:
      {
        BOOL bReturn=FALSE;
        char chrClassName[10];
        LONG lLength;
        PDRAGITEM pDragItem;

        TRY_LOUD(LP_DROP) {
          /* A drop on a toolbar button */
          lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
          if(lpo) {
            wpObject=lpo->wpObject;
            if(somIsObj(wpObject)) { 
              pDragInfo=(PDRAGINFO) mp1;
              pDragItem=DrgQueryDragitemPtr(pDragInfo, 0);
              hwndMenu=pDragInfo->hwndSource;
              lLength=sizeof(chrClassName);
              WinQueryClassName(hwndMenu, lLength, chrClassName);
              if(strcmp(chrClassName,"#37"))
                hwndMenu=NULL;/* Source isn't a container */
              bReturn=TRUE;
            }
          }
        }
        CATCH(LP_DROP)
          {
          } END_CATCH;
          if(bReturn)
            return wpObject->wpDrop(hwndMenu,(PDRAGINFO) mp1, pDragItem);
          break;
      }
    case WM_COMMAND:
      TRY_LOUD(LP_COMMAND) {
      lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lpo) {
        wpObject=lpo->wpObject;
        if(somIsObj(wpObject)) {
          if((SHORT)0x6d==SHORT1FROMMP(mp1)) {
            /* Delete menu item */       
            if(wpObject->wpDelete(CONFIRM_DELETE|CONFIRM_DELETEFOLDER ) == OK_DELETE)
              lpo->lpParent->lpRemoveButton(lpo);
          }
          else
            wpObject->wpMenuItemSelected(NULL, SHORT1FROMMP(mp1));
        }/* end of if(somIsObj(wpObject)) */
      }
      }  
      CATCH(LP_COMMAND)
        {
        } END_CATCH;
        return (MRESULT) FALSE;
    default:
      break;			
    }
  // call the standard flyover button procedure to handle the rest of the messages
  return (newButtonProc)(hwnd,msg,mp1,mp2);	
};
Ejemplo n.º 10
0
/*----------------------------------------------------------------------*/
void DMLBCheckTargetLocation(HWND SrcHwnd, DMLBData *InstData, SHORT X, SHORT Y)
/*----------------------------------------------------------------------*/
/* X,Y is in SrcHwnd window coordinates.                                */
/* Given an Y,Y coordinate of the pointer, determine if the pointer is  */
/* over a listbox that will accept a drop.  If it is, we save the       */
/* handle of the listbox and set the PrevLocation to POINT_INSIDE in    */
/* the instance data.  Otherwise, we see if the position is near the    */
/* top/bottom edge of the last good target listbox we had.  If so, set  */
/* the PrevLocation to POINT_NORTH/SOUTH as appropriate.  Finally, if   */
/* none of the above, just set the PrevLocation to POINT_OUTSIDE.       */
/*----------------------------------------------------------------------*/
{
RECTL Rect;
POINTL ScreenPoint;
HWND  OverHwnd;
char  OverClass[10];

  InstData->PrevLocation = POINT_OUTSIDE; // Assume this until we know otherwise

  /* See if window under the pointer is a listbox.             */
  ScreenPoint.x = X;
  ScreenPoint.y = Y;
  WinMapWindowPoints(SrcHwnd, HWND_DESKTOP, &ScreenPoint, 1L);
  OverHwnd = WinWindowFromPoint(HWND_DESKTOP, &ScreenPoint, TRUE);
  WinQueryClassName(OverHwnd, sizeof(OverClass), OverClass);

  if (!strcmp(OverClass, LISTBOX_CLASS_STRING)) {
    /* Yes, it is a listbox -- see if it will accept our drop */
    MRESULT Answer;

    /* If this is part of an MCLB, the MCLB is really the target */
    WinQueryClassName(WinQueryWindow(OverHwnd, QW_OWNER), sizeof(OverClass), OverClass);
    if (!strcmp(OverClass, "MCLBCls"))
      OverHwnd = WinQueryWindow(OverHwnd, QW_OWNER);

    Answer = WinSendMsg(WinQueryWindow(OverHwnd, QW_OWNER),
                        WM_CONTROL,
                        MPFROM2SHORT(WinQueryWindowUShort(OverHwnd, QWS_ID), LN_DMLB_QRYDROP),
                        MPFROMHWND(SrcHwnd));
    if ((BOOL)SHORT1FROMMR(Answer)) {
      /* Yes, it will accept the drop */
      InstData->TargetHwnd = OverHwnd;                 // Note new target
   // if (SrcHwnd == OverHwnd)
   //   InstData->TargetDropMode = DROPMODE_MOVE;      // Force MOVE for same-listbox drops
   // else
        InstData->TargetDropMode = SHORT2FROMMR(Answer); // Copy, Move, or Delete
      InstData->PrevLocation = POINT_INSIDE;           // We are inside the listbox now
      return;
    }
    /* It will not accept a drop, proceed as point outside */
    return;
  }

  /* Not a listbox class window.  See if pointer is near north/south */
  /* edge of last good target listbox.  ("Near" is defined as the    */
  /* height of a menu bar).                                          */

  WinQueryWindowRect(InstData->TargetHwnd, &Rect);
  /* Translate rectangle to screen coordinates */
  WinMapWindowPoints(InstData->TargetHwnd, HWND_DESKTOP, (POINTL *)&Rect, 2L);

  if ((ScreenPoint.x >= Rect.xLeft) && (ScreenPoint.x <= Rect.xRight)) {
    if ((ScreenPoint.y < Rect.yTop + WinQuerySysValue(HWND_DESKTOP, SV_CYMENU)) &&
        (ScreenPoint.y > Rect.yBottom - WinQuerySysValue(HWND_DESKTOP, SV_CYMENU))) {
       if (ScreenPoint.y > Rect.yTop)
         InstData->PrevLocation = POINT_NORTH;
       else if (ScreenPoint.y < Rect.yBottom)
         InstData->PrevLocation = POINT_SOUTH;
       return;
    } // Within a menu-size distance of north/south edge
  } // Within the horizontal boundries of the listbox

  /* Pointer is outside the range of interest */
  return;
}
Ejemplo n.º 11
0
/*----------------------------------------------------------------------*/
SHORT DMLBLocateListboxItem( HWND hwnd, HWND RelHwnd, SHORT Y, SHORT Option )
/*----------------------------------------------------------------------*/
/* Parameters:                                                          */
/*   hwnd         Listbox of interest                                   */
/*   RelHwnd      Window to which Y is relative to                      */
/*   Y            Y position of the pointer                             */
/*   Option       LLI_UNDER to return index of item under pointer,      */
/*                LLI_INSERTPOINT to index of item nearest insert point */
/*----------------------------------------------------------------------*/
/* Given a Y window coordinate, this function will calculate the item   */
/* number of the listbox item at that position.  The LLI_UNDER option   */
/* will return the item directly under the pointer.  The LLI_INSERTPOINT*/
/* option will return the item number *before* which an insertion should*/
/* be made (drop zones are calculated as the half-way points through    */
/* each item).                                                          */
/*----------------------------------------------------------------------*/
{
   RECTL   Rect;
   POINTL  Points[2];
   HPS     hps;
   LONG    VertSize;
   SHORT   ItemNum;
   char    ClassName[10];

   /* Map coordinate from window it is relative to, to win of interst*/
   Points[0].x = 0;
   Points[0].y = Y;
   WinMapWindowPoints(RelHwnd, hwnd, &(Points[0]), 1L);
   Y = Points[0].y;

   /* If this is actually a MultiColumn ListBox, we must find the    */
   /* real listbox which is the first column and use it for our      */
   /* location calculations.  Since we only care about the Y         */
   /* coordinate we only need to look at the 1st column of the MCLB. */

   WinQueryClassName(hwnd, sizeof(ClassName), ClassName);
   if (!strcmp("MCLBCls", ClassName))
     hwnd = WinWindowFromID(hwnd, 1);   /* Get handle of 1st column's listbox */

   /* If this is an OWNERDRAW listbox, ask owner how big items are.  */

   VertSize = 0;
   if (WinQueryWindowULong(hwnd, QWL_STYLE) & LS_OWNERDRAW)
     VertSize = SHORT1FROMMR(                               // Take returned Height
                WinSendMsg(WinQueryWindow(hwnd, QW_OWNER),  // Query owner of listbox
                   WM_MEASUREITEM,                          // Ask owner the size
                   MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),  // Listbox ID
                   MPFROMSHORT(0)));                        // First item

   if (VertSize == 0) {
     /* For a normal listbox, items are the size of the font.  To */
     /* determine the size we get the bounding box of a space.    */
     hps = WinGetPS(hwnd);
     GpiQueryTextBox(hps, 1L, " ", 2, Points);
     VertSize = Points[TXTBOX_TOPLEFT].y - Points[TXTBOX_BOTTOMLEFT].y;
     WinReleasePS(hps);
   }

   WinQueryWindowRect(hwnd, &Rect);
   Rect.yTop = Rect.yTop-2;         /* Listbox frame is 2 pixels */

   /* Calculate item number of item under the pointer */
   ItemNum = (SHORT)WinSendMsg(hwnd, LM_QUERYTOPINDEX, 0L, 0L)
             + ((Rect.yTop-Y)/VertSize);

   /* Return item under pointer, or insertion point */

   switch (Option) {
     case LLI_UNDER:
       return ItemNum;
     case LLI_INSERTPOINT:
       if (((Rect.yTop-Y) % VertSize) <= (VertSize / 2))
         return ItemNum;
       return ItemNum+1;  /* Note: May exceed num of items in list */
   }
}
MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
   RECTL    clientrect;                     /* Rectangle coordinates        */
   HPS      hpsPaint;
   POINTL   pt;                            /* String screen coordinates    */
   BOOL     Invalid;
   int      Line;
   ERRORID  Err;
   HWND     Focus,Active;
   HMQ      hmqDeb;
   PID      pid,cpid;
   TID      tid,ctid;
   switch( msg )
   {
   case WM_CREATE:
      WinStartTimer(hab,hwnd,1234,500);
      break;                                /* end the application.     */
   case WM_TIMER:
      rc=DosOpen("KBD$", &hKbd, &Action, 0, FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE |
                 OPEN_FLAGS_FAIL_ON_ERROR, 0);
      if (rc) {
         char Buf[80];
         sprintf(Buf,"Open rc = %d",rc);
         WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
                       Buf,
                       "TRAPIT",
                        1234,
                        MB_OK);
      } /* endif */
      Dlen= sizeof(State);
      rc = DosDevIOCtl( hKbd, 4, 0x73, 0, 0, 0, &State, sizeof(State), &Dlen );
      Shift=(USHORT)State;
      DosClose(hKbd);
      Invalid=FALSE;
      if ((State&0x0500)==0x0500) {
         if (Color!=CLR_RED) {
            Color=CLR_RED;
            Invalid=TRUE;
         } /* endif */
         Focus=WinQueryFocus(HWND_DESKTOP);
         Active=WinQueryActiveWindow(HWND_DESKTOP);
         WinQueryWindowProcess(Focus,&pid,&tid);
         hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
         if (hmqDeb==hmq) {
            sprintf(Buffer,"Sorry Can't unhang Myself");
         } else {
            DosKillProcess(DKP_PROCESS,pid);
         } /* endif */
      } else {
         if ((State&0x0A00)==0x0A00) {
            if (Color!=CLR_BLUE) {
               Color=CLR_BLUE;
               Invalid=TRUE;
            } /* endif */
            Focus=WinQueryFocus(HWND_DESKTOP);
            Active=WinQueryActiveWindow(HWND_DESKTOP);
            WinQueryWindowProcess(Focus,&pid,&tid);
            hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
            if (hmqDeb==hmq) {
               sprintf(Buffer,"Sorry Can't trap Myself");
            } else {
               HENUM hEnum;
               CHAR Class[20];
               HWND Child;
               hEnum = WinBeginEnumWindows(HWND_OBJECT);
               while ( (Child=WinGetNextWindow(hEnum)) != 0) {
                   WinQueryWindowProcess(Child,&cpid,&ctid);
                   if (cpid==pid) {
                       Class[0]=0;
                       WinQueryClassName(Child,sizeof(Class)-1,Class);
                       if (strcmp(Class,"Killer")==0) {
                           if (WinPostMsg(Child,WM_USER+1,0,0)) {
                              DosBeep(1800,80);
                              DosBeep(600,80);
                              DosBeep(1800,80);
                           }
                       } /* endif */
                   } /* endif */
               }
               WinEndEnumWindows(hEnum);
            } /* endif */
         } else {
            if (Color!=CLR_BACKGROUND) {
               Color=CLR_BACKGROUND;
               Invalid=TRUE;
            }
         } /* endif */
      } /* endif */
      if (Invalid) {
            WinInvalidateRect( hwnd, NULL, TRUE );
      } /* endif */
      break;
   case WM_PAINT:
      hpsPaint=WinBeginPaint( hwnd,0, &clientrect );
      WinFillRect( hpsPaint, &clientrect,Color );/* Fill invalid rectangle       */
      pt.x = 10; pt.y = 190;                    /* Set the text coordinates,    */
      GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(Buffer),Buffer);
      for (Line=0;Line<8;Line++ ) {
         pt.x = 10; pt.y = 170-(20*Line);   /* Set the text coordinates,    */
         GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(LabelText[Line]),LabelText[Line]);
      } /* endfor */
      WinEndPaint( hpsPaint );                        /* Drawing is complete   */
      break;
    case WM_CLOSE:
      /******************************************************************/
      /* This is the place to put your termination routines             */
      /******************************************************************/
      WinPostMsg( hwnd, WM_QUIT, 0L, 0L );  /* Cause termination        */
      break;
    default:
      /******************************************************************/
      /* Everything else comes here.  This call MUST exist              */
      /* in your window procedure.                                      */
      /******************************************************************/
      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }
  return FALSE;
}
Ejemplo n.º 13
0
/*@ XToolBar::ReSize(void)
@group sizing
@remarks The positions of the attached windows are recalculated.
*/
void XToolBar::ReSize(void)
{
   int i;
   XRect rect2, rect;

   GetSize(&rect2);

   int x = borderSize;

   if (style & TB_RIGHT || style & TB_LEFT)
   {
      int y = rect2.GetHeight() - borderSize;

      for (i = 0; i < clients; i++)
      {
         clientArray[i]->clientWin->GetSize(&rect);
         if (clientArray[i]->group == TRUE)
         {
            x = borderSize;
            char className[10];

            WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className);
            className[0] = ' ';
            if (atol(className) == 2)
            {
               if (i > 0)
                  y -= (25 + clientArray[i]->yOffset + spacing);
               else
                  y -= (25 + clientArray[i]->yOffset);
               rect.SetY(y + 25 + clientArray[i]->yOffset - rect.GetHeight());
            }
            else
            {
               if (i > 0)
                  y -= (rect.GetHeight() + clientArray[i]->yOffset + spacing);
               else
                  y -= (rect.GetHeight() + clientArray[i]->yOffset - borderSize);
               rect.SetY(y + clientArray[i]->yOffset);
            }
         }
         else
         {
            if (i == 0)
               y -= (rect.GetHeight() + clientArray[i]->yOffset);
            else
               rect.SetY(y + clientArray[i]->yOffset);
         }
         rect.SetX(x + clientArray[i]->xOffset);
         x += rect.GetWidth() + clientArray[i]->xOffset;
         clientArray[i]->clientWin->SetSize(&rect);
      }
   }
   else
   {
      for (i = 0; i < clients; i++)
      {
         clientArray[i]->clientWin->GetSize(&rect);
         rect.SetY(rect2.GetHeight() - rect.GetHeight() + clientArray[i]->yOffset - borderSize);

         if (clientArray[i]->group == TRUE && i > 0)
            x += spacing;

         rect.SetX(x + clientArray[i]->xOffset);
         x += rect.GetWidth() + clientArray[i]->xOffset;
         clientArray[i]->clientWin->SetSize(&rect);
      }
   }
}
Ejemplo n.º 14
0
Archivo: kva_wo.c Proyecto: komh/kva
APIRET APIENTRY kvaWoInit( HWND hwnd, ULONG ulKeyColor, PKVAAPIS pkva )
{
    BOOL        fWOInited = FALSE;
    HWATTRIBUTE attr;
    int         i;
    CHAR        szClassName[ 80 ];
    CLASSINFO   ci;
    ULONG       rc;

    m_HWVideoHandle = NULLHANDLE;
    memset( &m_hwvc, 0, sizeof( HWVIDEOCAPS ));
    memset( &m_hwvs, 0, sizeof( HWVIDEOSETUP ));

    m_pfnwpOld = NULL;

    rc = KVAE_NO_ERROR;

    if( !LoadOverlay())
    {
        rc = KVAE_CANNOT_LOAD_WO;
        goto exit_error;
    }

    rc = m_pfnHWVIDEOInit();
    if( rc )
        goto exit_error;

    fWOInited = TRUE;

    // Query overlay capabilities
    m_hwvc.ulLength = sizeof( m_hwvc );

    // First time we need to call with zero value
    m_hwvc.ulNumColors = 0;
    m_hwvc.fccColorType = NULL;
    m_pfnHWVIDEOCaps( &m_hwvc );

    // this time hwvc.ulNumColors filled with actual count of supported FOURCCs
    // but need to check this
    if( m_hwvc.ulNumColors )
    {
        m_hwvc.fccColorType = malloc( m_hwvc.ulNumColors * sizeof( FOURCC ));
        m_pfnHWVIDEOCaps( &m_hwvc );
    }
    else
    {
        rc = KVAE_NO_SUPPORTED_FOURCC;
        goto exit_error;
    }

    if( m_hwvc.fccDstColor == FOURCC_LUT8 )
    {
        // WO doesn't supports palettized mode.
        rc = KVAE_WO_PALETTIZED_MODE;
        goto exit_error;
    }

    attr.ulLength = sizeof( HWATTRIBUTE );

    for( i = 0; i < m_hwvc.ulAttrCount; i++ )
    {
        m_pfnHWVIDEOGetAttrib( i, &attr );

        if( !strcmp( attr.szAttrDesc, ATTRIBUTE_BRIGHTNESS ))
            m_aulAttr[ KVAA_BRIGHTNESS ] = i;
        else if ( !strcmp( attr.szAttrDesc, ATTRIBUTE_CONTRAST ))
            m_aulAttr[ KVAA_CONTRAST ] = i;
        else if( !strcmp( attr.szAttrDesc, ATTRIBUTE_SATURATION ))
            m_aulAttr[ KVAA_SATURATION ] = i;
        else if( !strcmp( attr.szAttrDesc, ATTRIBUTE_HUE ))
            m_aulAttr[ KVAA_HUE ] = i;
    }

    m_hwndKVA = hwnd;
    m_hwvs.ulKeyColor = ulKeyColor;

    WinQueryClassName( m_hwndKVA, sizeof( szClassName ), szClassName );
    WinQueryClassInfo( WinQueryAnchorBlock( m_hwndKVA ), szClassName, &ci );

    if( !( ci.flClassStyle & CS_MOVENOTIFY ))
    {
        ci.flClassStyle |= CS_MOVENOTIFY;

        WinRegisterClass( WinQueryAnchorBlock( m_hwndKVA ),
                          szClassName,
                          ci.pfnWindowProc,
                          ci.flClassStyle,
                          ci.cbWindowData );
    }

    m_pfnwpOld = WinSubclassWindow( m_hwndKVA, woNewWindowProc );

    if( m_pfnwpOld )
    {
        pkva->pfnDone = woDone;
        pkva->pfnLockBuffer = woLockBuffer;
        pkva->pfnUnlockBuffer = woUnlockBuffer;
        pkva->pfnSetup = woSetup;
        pkva->pfnCaps = woCaps;
        pkva->pfnQueryAttr = woQueryAttr;
        pkva->pfnSetAttr = woSetAttr;
    }
    else
    {
        rc = KVAE_CANNOT_SUBCLASS;
        goto exit_error;
    }

    return KVAE_NO_ERROR;

exit_error :
    if( m_HWVideoHandle )
    {
        if( m_hwvc.fccColorType )
            free( m_hwvc.fccColorType );

        if( fWOInited )
            m_pfnHWVIDEOClose();

        DosFreeModule( m_HWVideoHandle );
    }

    return rc;
}
Ejemplo n.º 15
0
unsigned int CallDosDebug( dos_debug __far *buff )
{
    QMSG        qmsg;
    int         num_paints;
    int         i;
    struct {
        RECTL   rcl;
        HWND    hwnd;
    }           paints[MAX_PAINTS];
    HPS         ps;
    char        class_name[80];
    TID         tid;

    if( !IsPMDebugger() ) {
        return( Call32BitDosDebug( buff ) );
    }

    switch( buff->Cmd ) {
    case DBG_C_ClearWatch:
    case DBG_C_Freeze:
    case DBG_C_LinToSel:
    case DBG_C_NumToAddr:
    case DBG_C_ReadCoRegs:
    case DBG_C_ReadMemBuf:
    case DBG_C_ReadMem_D:
    case DBG_C_ReadReg:
    case DBG_C_SelToLin:
    case DBG_C_SetWatch:
    case DBG_C_ThrdStat:
    case DBG_C_WriteCoRegs:
    case DBG_C_WriteMemBuf:
    case DBG_C_WriteMem_D:
    case DBG_C_WriteReg:
        return( Call32BitDosDebug( buff ) );
    }
    switch( buff->Cmd ) {
    case DBG_C_Go:
    case DBG_C_SStep:
    case DBG_C_Term:
        ReleaseQueue( buff->Pid, buff->Tid );
    }
    DebugReqBuff = buff;
    StopBuff = *buff;
    DosSemSet( &DebugDoneSem );
    DosSemClear( &DebugReqSem );
    num_paints = 0;
    if( IsPMDebugger() ) {
        while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) {
            WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name );
            switch( qmsg.msg ) {
            case WM_CHAR:
                if( ( SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY ) &&
                    ( SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK ) ) {
                    SetBrkPending();
                    DosCreateThread( StopApplication, &tid, stack2 + STACK_SIZE );
                    DosSetPrty( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid );
                    WakeThreads( StopBuff.Pid );
                    DosSemWait( &StopDoneSem, SEM_INDEFINITE_WAIT );
                    DosSemSet( &StopDoneSem );
                }
                break;
            case WM_COMMAND:
                CantDoIt();
                break;
            default:
                if( strcmp( class_name, "GUIClass" ) == 0 ||
                    strcmp( class_name, "WTool" ) == 0 ) {
                    switch( qmsg.msg ) {
                    case WM_PAINT:
                        if( num_paints >= MAX_PAINTS ) --num_paints;
                        paints[num_paints].hwnd = qmsg.hwnd;
                        ps = WinBeginPaint( qmsg.hwnd, 0, &paints[ num_paints ].rcl );
                        GpiErase( ps );
                        WinEndPaint( ps );
                        num_paints++;
                        break;
                    case WM_BUTTON1DOWN:
                    case WM_BUTTON2DOWN:
                    case WM_BUTTON3DOWN:
                        CantDoIt();
                        break;
                    case WM_MOUSEMOVE:
                    {
                        HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
                        if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) {
                            WinSetPointer( HWND_DESKTOP, hourglass );
                        }
                        break;
                    }
                    default:
                        WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
                    }
                } else {
                    WinDispatchMsg( HabDebugger, &qmsg );
                }
            }
        }
    } else {
        DosSemWait( &DebugDoneSem, SEM_INDEFINITE_WAIT );
    }
    switch( buff->Cmd ) {
    case DBG_N_Exception:
    case DBG_N_AsyncStop:
    case DBG_N_Watchpoint:
        AssumeQueue( buff->Pid, buff->Tid );
        break;
    }
    for( i = 0; i < num_paints; ++i ) {
        WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE );
    }
    return( DebugReqResult );
}