static MRESULT EXPENTRY ControlInstructionDlg (HWND hwnd, ULONG msg,
    MPARAM mp1, MPARAM mp2)
{
    PINST   pinstMain;      // Ptr to main application instance data

    pinstMain = (PINST) WinQueryWindowPtr(hwnd,QWL_USER);

    switch (msg)
    {
        case WM_INITDLG:
        {
            // A ptr to main application instance data is passed to
            // this dialog.  Store it in our QWL_USER data.
            pinstMain = (PINST) PVOIDFROMMP (mp2);
            WinSetWindowPtr(hwnd,QWL_USER,pinstMain);

            // Set the limits for the spin controls
            WinSendDlgItemMsg (hwnd, IDSPB_HEADING,
                SPBM_SETLIMITS, MPFROMLONG (360), MPFROMLONG (1));
            WinSendDlgItemMsg (hwnd, IDSPB_ALTITUDE,
                SPBM_SETLIMITS, MPFROMLONG (500), MPFROMLONG (10));
            WinSendDlgItemMsg (hwnd, IDSPB_SPEED,
                SPBM_SETLIMITS, MPFROMLONG (100), MPFROMLONG (5));

            // Set current values for the spin controls
            WinSendDlgItemMsg (hwnd, IDSPB_HEADING,
                SPBM_SETCURRENTVALUE,
                MPFROMLONG (pinstMain->pacrSelected->Heading), 0);
            WinSendDlgItemMsg (hwnd, IDSPB_ALTITUDE,
                SPBM_SETCURRENTVALUE,
                MPFROMLONG (pinstMain->pacrSelected->Altitude), 0);
            WinSendDlgItemMsg (hwnd, IDSPB_SPEED,
                SPBM_SETCURRENTVALUE,
                MPFROMLONG (pinstMain->pacrSelected->Speed), 0);

            return 0;
        }

        case WM_COMMAND:
            switch (SHORT1FROMMP (mp1))
            {
                case DID_OK:
                {
                    // Get current values for the spin controls
                    WinSendDlgItemMsg (hwnd, IDSPB_HEADING,
                        SPBM_QUERYVALUE,
                        MPFROMLONG (&pinstMain->pacrSelected->
                            AssignedHeading), 0);
                    WinSendDlgItemMsg (hwnd, IDSPB_ALTITUDE,
                        SPBM_QUERYVALUE,
                        MPFROMLONG (&pinstMain->pacrSelected->
                            AssignedAltitude), 0);
                    WinSendDlgItemMsg (hwnd, IDSPB_SPEED,
                        SPBM_QUERYVALUE,
                        MPFROMLONG (&pinstMain->pacrSelected->
                            AssignedSpeed), 0);

                    break;
                }
            }

            return WinDefDlgProc (hwnd, msg, mp1, mp2);

        default:
            return WinDefDlgProc (hwnd, msg, mp1, mp2);
    }
}
void plNext(HWND hWnd)
{
   PSTRINGLIST pEntry = (PSTRINGLIST)WinQueryWindowPtr(hWnd, QWP_CURRENTENTRY);
   pEntry = pEntry->next;
   WinSetWindowPtr(hWnd, QWP_CURRENTENTRY, pEntry);
}
示例#3
0
MRESULT EXPENTRY DirDialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch ( msg ) {
      case WM_INITDLG:
         {
         SWP swpFileST;
         SWP swpDirST;
         SWP swpDirLB;
         SWP swpDriveST;
         SWP swpDriveCB;
         SWP swpDriveCBEF;
         SWP swpOK;
         SWP swpCancel;
         HWND hwndFileST;
         HWND hwndDirST;
         HWND hwndDirLB;
         HWND hwndDriveST;
         HWND hwndDriveCB;
         HWND hwndOK;
         HWND hwndCancel;
         HENUM henum;
         HWND hwndNext;
         ULONG ulCurY, ulCurX;
         LONG lScreenX, lScreenY, lDlgFrameX, lDlgFrameY, lTitleBarY;

         lScreenX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
         lScreenY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
         lDlgFrameX = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME);
         lDlgFrameY = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME);
         lTitleBarY = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);

         hwndFileST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT);
         hwndDirST = WinWindowFromID(hwndDlg, DID_DIRECTORY_TXT);
         hwndDirLB = WinWindowFromID(hwndDlg, DID_DIRECTORY_LB);
         hwndDriveST = WinWindowFromID(hwndDlg, DID_DRIVE_TXT);
         hwndDriveCB = WinWindowFromID(hwndDlg, DID_DRIVE_CB);
         hwndOK = WinWindowFromID(hwndDlg, DID_OK);
         hwndCancel = WinWindowFromID(hwndDlg, DID_CANCEL);
         
#define SPACING 10
         // Reposition drives combobox
         ulCurY = SPACING;
         ulCurX = SPACING + lDlgFrameX;
         WinQueryWindowPos(hwndOK, &swpOK);
         WinSetWindowPos(hwndOK, 0, ulCurX, ulCurY, 0, 0, SWP_MOVE);
         ulCurY += swpOK.cy + SPACING;
         WinQueryWindowPos(hwndCancel, &swpCancel);
         WinSetWindowPos(hwndCancel, 0, ulCurX+swpOK.cx+10, SPACING, 0, 0, SWP_MOVE);
         WinQueryWindowPos(hwndDirLB, &swpDirLB);
         WinSetWindowPos(hwndDirLB, 0, ulCurX, ulCurY, swpDirLB.cx, swpDirLB.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDirLB.cy + SPACING;
         WinQueryWindowPos(hwndDirST, &swpDirST);
         WinSetWindowPos(hwndDirST, 0, ulCurX, ulCurY, swpDirST.cx, swpDirST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDirST.cy + SPACING;
         WinQueryWindowPos(hwndDriveCB, &swpDriveCB);
         WinQueryWindowPos(WinWindowFromID(hwndDriveCB, CBID_EDIT), &swpDriveCBEF);
         WinSetWindowPos(hwndDriveCB, 0, ulCurX, ulCurY-(swpDriveCB.cy-swpDriveCBEF.cy)+5,
                                         swpDirLB.cx,
                                         swpDriveCB.cy,
                                         SWP_SIZE | SWP_MOVE);
         ulCurY += swpDriveCBEF.cy + SPACING;
         WinQueryWindowPos(hwndDriveST, &swpDriveST);
         WinSetWindowPos(hwndDriveST, 0, ulCurX, ulCurY, swpDriveST.cx, swpDriveST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDriveST.cy + SPACING;
         WinQueryWindowPos(hwndFileST, &swpFileST);
         WinSetWindowPos(hwndFileST, 0, ulCurX, ulCurY, swpFileST.cx, swpFileST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpFileST.cy + SPACING;

         // Hide unused stuff
         henum = WinBeginEnumWindows(hwndDlg);
         while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE)
         {
           USHORT usID = WinQueryWindowUShort(hwndNext, QWS_ID);
           if (usID != DID_FILENAME_TXT &&
               usID != DID_DIRECTORY_TXT &&
               usID != DID_DIRECTORY_LB &&
               usID != DID_DRIVE_TXT &&
               usID != DID_DRIVE_CB &&
               usID != DID_OK &&
               usID != DID_CANCEL &&
               usID != FID_TITLEBAR &&
               usID != FID_SYSMENU &&
               usID != FID_MINMAX) 
           {
             WinShowWindow(hwndNext, FALSE);
           }
         }

         WinSetWindowPos(hwndDlg,
                         HWND_TOP,
                         (lScreenX/2)-((swpDirLB.cx+2*SPACING+2*lDlgFrameX)/2),
                         (lScreenY/2)-((ulCurY+2*lDlgFrameY+lTitleBarY)/2),
                         swpDirLB.cx+2*SPACING+2*lDlgFrameX,
                         ulCurY+2*lDlgFrameY+lTitleBarY,
                         SWP_MOVE | SWP_SIZE);
         }
         break;
      case WM_CONTROL:
         {
         PFILEDLG pfiledlg;
         pfiledlg = (PFILEDLG)WinQueryWindowPtr(hwndDlg, QWL_USER);

         HPS           hps;
         SWP           swp;
         HWND          hwndST;
         RECTL         rectlString = {0,0,1000,1000};
         char          *ptr = NULL;
         int           iHalfLen;
         int           iLength;
         CHAR          szString[CCHMAXPATH];

         hwndST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT);
       
         strcpy(szString, pfiledlg->szFullFile);
         iLength = strlen(pfiledlg->szFullFile);
         /* If we are not just a drive */
         if (iLength > 3) {
           if (szString[iLength-1] == '\\') {
             szString[iLength-1] = '\0';
             iLength--;
           }
         }
       
         hps = WinGetPS(hwndST);
         WinQueryWindowPos(hwndST, &swp);
       
         WinDrawText(hps, iLength, szString,
                          &rectlString, 0, 0, 
                          DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS);
         while(rectlString.xRight > swp.cx)
         {
           iHalfLen = iLength / 2;
           if(iHalfLen == 2)
             break;
       
           ptr = szString + iHalfLen;
           memmove(ptr - 1, ptr, strlen(ptr) + 1);
           szString[iHalfLen - 2] = '.';
           szString[iHalfLen - 1] = '.';
           szString[iHalfLen]     = '.';
           iLength = strlen(szString);
           rectlString.xLeft = rectlString.yBottom = 0;
           rectlString.xRight = rectlString.yTop = 1000;
           WinDrawText(hps, iLength, szString,
                       &rectlString, 0, 0, 
                       DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS);
         }
       
         WinReleasePS(hps);
         WinSetWindowText(hwndST, szString);
         }
         break;
   }      
   return WinDefFileDlgProc(hwndDlg, msg, mp1, mp2);
}
  /* Message processing for our PM Window class */
  MRESULT EXPENTRY  Message_Process( HWND    handle,
                                     ULONG   mess,
                                     MPARAM  parm1,
                                     MPARAM  parm2 )
  {
     static HDC     screen_dc;
     static HPS     screen_ps;
     static BOOL    minimized;

     SIZEL   sizl;
     SWP     swp;

     grPMSurface*  surface;

    /* get the handle to the window's surface -- note that this */
    /* value will be null when the window is created            */
    surface = (grPMSurface*)WinQueryWindowPtr( handle, QWL_USER );
    if (!surface)
    {
      surface = the_surface;
      WinSetWindowPtr( handle, QWL_USER, surface );
    }

    switch( mess )
    {
    case WM_DESTROY:
      /* warn the main thread to quit if it didn't know */
      surface->event.type = gr_event_key;
      surface->event.key  = grKeyEsc;
      DosPostEventSem( surface->event_lock );
      break;

    case WM_CREATE:
      /* set original magnification */
      minimized = FALSE;

      /* create Device Context and Presentation Space for screen. */
      screen_dc = WinOpenWindowDC( handle );
      screen_ps = GpiCreatePS( surface->anchor,
                               screen_dc,
                               &sizl,
                               PU_PELS | GPIT_MICRO |
                               GPIA_ASSOC | GPIF_DEFAULT );
      /* take the input focus */
      WinFocusChange( HWND_DESKTOP, handle, 0L );
      LOG(( "screen_dc and screen_ps have been created\n" ));

      /* To permit F9, F10 and others to pass through to the application */
      if (TRUE != WinSetAccelTable (surface->anchor, 0, surface->frame_window))
      {
        printf( "Error - failed to clear accel table\n");
      }
      break;

    case WM_MINMAXFRAME:
      /* to update minimized if changed */
      swp = *((PSWP) parm1);
      if ( swp.fl & SWP_MINIMIZE )
        minimized = TRUE;
      if ( swp.fl & SWP_RESTORE )
        minimized = FALSE;
      return WinDefWindowProc( handle, mess, parm1, parm2 );
      break;

    case WM_ERASEBACKGROUND:
    case WM_PAINT:
      /* copy the memory image of the screen out to the real screen */
      LOCK( surface->image_lock );
      WinBeginPaint( handle, screen_ps, NULL );

      /* main image and magnified picture */
      GpiBitBlt( screen_ps,
                 surface->image_ps,
                 4L,
                 surface->blit_points,
                 ROP_SRCCOPY, BBO_AND );

      WinEndPaint( screen_ps );
      UNLOCK( surface->image_lock );
      break;

    case WM_HELP:  /* this really is a F1 Keypress !! */
      surface->event.key = grKeyF1;
      goto Do_Key_Event;

    case WM_CHAR:
      if ( CHARMSG( &mess )->fs & KC_KEYUP )
        break;

      /* look for a specific vkey */
      {
        int          count = sizeof( key_translators )/sizeof( key_translators[0] );
        Translator*  trans = key_translators;
        Translator*  limit = trans + count;

        for ( ; trans < limit; trans++ )
          if ( CHARMSG(&mess)->vkey == trans->os2key )
          {
            surface->event.key = trans->grkey;
            goto Do_Key_Event;
          }
      }

      /* otherwise, simply record the character code */
      if ( (CHARMSG( &mess )->fs & KC_CHAR) == 0 )
        break;

      surface->event.key = CHARMSG(&mess)->chr;

    Do_Key_Event:
      surface->event.type = gr_event_key;
      DosPostEventSem( surface->event_lock );
      break;

    default:
      return WinDefWindowProc( handle, mess, parm1, parm2 );
    }

    return (MRESULT) FALSE;
  }
示例#5
0
文件: kva.c 项目: fabsther/vlc-mort
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 );
    MRESULT result = ( MRESULT )TRUE;

    if ( !vd )
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );

    vout_display_sys_t * sys = vd->sys;
    RECTL rcl;
    SWP   swp;

    if ( sys->is_mouse_hidden &&
            ((msg >= WM_MOUSEFIRST    && msg <= WM_MOUSELAST) ||
             (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) ||
             msg == WM_MOUSELEAVE))
    {
        WinShowPointer(HWND_DESKTOP, TRUE);
        sys->is_mouse_hidden = false;
    }

    switch( msg )
    {
    /* the user wants to close the window */
    case WM_CLOSE:
        vout_display_SendEventClose(vd);
        result = 0;
        break;

    case WM_MOUSEMOVE :
    {
        SHORT i_mouse_x = SHORT1FROMMP( mp1 );
        SHORT i_mouse_y = SHORT2FROMMP( mp1 );
        RECTL movie_rect;
        int   i_movie_width, i_movie_height;
        int   i_src_width, i_src_height;

        /* Get a current movie area */
        kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect );
        i_movie_width = movie_rect.xRight - movie_rect.xLeft;
        i_movie_height = movie_rect.yTop - movie_rect.yBottom;

        i_src_width =  sys->kvas.rclSrcRect.xRight -
                       sys->kvas.rclSrcRect.xLeft;
        i_src_height = sys->kvas.rclSrcRect.yBottom -
                       sys->kvas.rclSrcRect.yTop;

        int x = ( i_mouse_x - movie_rect.xLeft ) *
                i_src_width / i_movie_width +
                sys->kvas.rclSrcRect.xLeft;
        int y = ( i_mouse_y - movie_rect.yBottom ) *
                i_src_height / i_movie_height;

        /* Invert Y coordinate and add y offset */
        y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;;

        vout_display_SendEventMouseMoved(vd, x, y);

        result = WinDefWindowProc( hwnd, msg, mp1,mp2 );
        break;
    }

    case WM_BUTTON1DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT );
        break;

    case WM_BUTTON2DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT );
        break;

    case WM_BUTTON3DOWN :
        MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER );
        break;

    case WM_BUTTON1UP :
        MouseReleased( vd, MOUSE_BUTTON_LEFT );
        break;

    case WM_BUTTON2UP :
        MouseReleased( vd, MOUSE_BUTTON_RIGHT );
        break;

    case WM_BUTTON3UP :
        MouseReleased( vd, MOUSE_BUTTON_CENTER );
        break;

    case WM_BUTTON1DBLCLK :
        vout_display_SendEventMouseDoubleClick(vd);
        break;

    case WM_TRANSLATEACCEL :
        /* We have no accelerator table at all */
        result = ( MRESULT )FALSE;
        break;

    case WM_CHAR :
    {
        USHORT i_flags = SHORT1FROMMP( mp1 );
        USHORT i_ch    = SHORT1FROMMP( mp2 );
        USHORT i_vk    = SHORT2FROMMP( mp2 );
        int    i_key   = 0;

        /* If embedded window, let the parent process keys */
        if( sys->parent_window )
        {
            WinPostMsg( sys->parent, msg, mp1, mp2 );
            break;
        }

        if( !( i_flags & KC_KEYUP ))
        {
            if( i_flags & KC_VIRTUALKEY )
                /* convert the key if possible */
                i_key = ConvertKey( i_vk );
            else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch ))
                i_key = tolower( i_ch );

            if( i_key )
            {
                if( i_flags & KC_SHIFT )
                    i_key |= KEY_MODIFIER_SHIFT;

                if( i_flags & KC_CTRL )
                    i_key |= KEY_MODIFIER_CTRL;

                if( i_flags & KC_ALT )
                    i_key |= KEY_MODIFIER_ALT;

                vout_display_SendEventKey(vd, i_key);
            }
        }
        break;
    }

    /* Process Manage() call */
    case WM_VLC_MANAGE :
        break;

    /* Fullscreen change */
    case WM_VLC_FULLSCREEN_CHANGE :
        if( LONGFROMMP( mp1 ))
        {
            WinQueryWindowPos( sys->frame, &swp );
            sys->client_rect.xLeft   = swp.x;
            sys->client_rect.yBottom = swp.y;
            sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
            sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
            WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );

            rcl.xLeft   = 0;
            rcl.yBottom = 0;
            rcl.xRight  = sys->i_screen_width;
            rcl.yTop    = sys->i_screen_height;
        }
        else
            rcl = sys->client_rect;

        WinCalcFrameRect( sys->frame, &rcl, FALSE );

        WinSetWindowPos( sys->frame, HWND_TOP,
                         rcl.xLeft, rcl.yBottom,
                         rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                         SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW |
                         SWP_ACTIVATE );
        break;

    /* Size change */
    case WM_VLC_SIZE_CHANGE :
        rcl.xLeft   = 0;
        rcl.yBottom = 0;
        rcl.xRight  = LONGFROMMP( mp1 );
        rcl.yTop    = LONGFROMMP( mp2 );
        WinCalcFrameRect( sys->frame, &rcl, FALSE );

        WinSetWindowPos( sys->frame, NULLHANDLE,
                         0, 0,
                         rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                         SWP_SIZE );

        WinQueryWindowPos( sys->frame, &swp );
        sys->client_rect.xLeft   = swp.x;
        sys->client_rect.yBottom = swp.y;
        sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
        sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
        WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );
        break;

    default :
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    }

    /* If embedded window, we need to change our window size according to a
     * parent window size */
    if( sys->parent_window )
    {
        WinQueryWindowRect( sys->parent, &rcl );

        if( rcl.xLeft   != sys->parent_rect.xLeft   ||
                rcl.yBottom != sys->parent_rect.yBottom ||
                rcl.xRight  != sys->parent_rect.xRight  ||
                rcl.yTop    != sys->parent_rect.yTop)
        {
            sys->parent_rect = rcl;

            WinCalcFrameRect( sys->frame, &rcl, FALSE );

            WinSetWindowPos( sys->frame, NULLHANDLE,
                             rcl.xLeft, rcl.yBottom,
                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                             SWP_SIZE | SWP_MOVE );
        }
    }

    return result;
}
示例#6
0
 static void timer(HWND hwnd)
 {
    ICQFRAME *cfg  = WinQueryWindowPtr(hwnd,0);
    int      xMove = 0;
    int      yMove = 0;
    SWP      swp;
    ULONG    flag  = 0;
    POINTL   p     = { cfg->xMouse, cfg->yMouse };

    if( ((USHORT) cfg->xMouse) == 0xFFFF || ((USHORT)cfg->yMouse) == 0xFFFF)
       return;

    WinMapWindowPoints(hwnd, HWND_DESKTOP, &p, 1);

    hwnd = WinQueryWindow(hwnd,QW_PARENT);

    WinQueryWindowPos(hwnd, &swp);

    if(cfg->xPos != 0xFFFF)
    {
       if(cfg->flags & ICQFRAME_FLAG_MOVEX)
       {
          xMove  = p.x-cfg->xPos;
          swp.x += xMove;
          flag  |= SWP_MOVE;
       }
       else
       {
          xMove  = cfg->xPos - p.x;
       }

       if(cfg->flags & ICQFRAME_FLAG_SETCX)
       {
          swp.cx -= xMove;
          flag   |= SWP_SIZE;
       }

       cfg->xPos  = p.x;

    }

    if(cfg->yPos != 0xFFFF)
    {
       if(cfg->flags & ICQFRAME_FLAG_MOVEY)
       {
          yMove  = p.y - cfg->yPos;
          swp.y += yMove;
          flag  |= SWP_MOVE;
       }
       else
       {
          yMove  = cfg->yPos - p.y;
       }

       if(cfg->flags & ICQFRAME_FLAG_SETCY)
       {
          swp.cy -= yMove;
          flag   |= SWP_SIZE;
       }

       cfg->yPos  = p.y;

    }

    if(flag)
       WinSetWindowPos(hwnd, 0, swp.x, swp.y, swp.cx, swp.cy, flag);

    cfg->xMouse =
    cfg->yMouse = 0xFFFF;

 }
示例#7
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_wmChar(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
USHORT  fsFlags = SHORT1FROMMP(mp1);
UCHAR   ucVkey  = CHAR3FROMMP(mp2);
UCHAR   ucChar  = CHAR1FROMMP(mp2);
UCHAR   ucScancode = CHAR4FROMMP(mp1);

HIA     *hia    = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);

USHORT ckey;

//  printf("HIA:: WM_CHAR\n");

    if (fsFlags & KC_KEYUP) return 0L;

    if( hia->isHanjaKey != NULL )
    {
        if( hia->isHanjaKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            if( hia->inbuf->newpos != HIABUF_NONE )
            {
                HANCHAR hch = SHORT1FROMMR( WinSendMsg( hwnd, HIAM_QUERYWORKINGHCH, 0, 0 ));
                HANCHAR hj;

                hj = hjselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, hch );
                if( hj != HCH_SINGLE_SPACE )
                    hch = hj;

                WinSendMsg( hwnd, HIAM_CANCELBUF, 0, 0 );
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(hch));

                //WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
                //HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, MPFROMLONG( TRUE ));
            }
            else
                HIA_NotifyToConnected( hia, HIAN_HGHJCONVERT, 0);

            return MRFROMLONG( TRUE );
        }
    }

    if( hia->isSpecialCharKey != NULL )
    {
        if( hia->isSpecialCharKey( fsFlags, ucScancode, ucVkey, ucChar ))
        {
            SCSELINFO scselInfo = { -1, -1, -1 };

            WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

            scselDlg( HWND_DESKTOP, hia->responseTo->hwnd, NULLHANDLE, &scselInfo );
            if( scselInfo.hch != HCH_SINGLE_SPACE )
            {
                HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROMSHORT(scselInfo.hch));
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROMSHORT(scselInfo.hch));
            }

            return MRFROMLONG( TRUE );
        }
    }

    if (fsFlags & KC_VIRTUALKEY)
        {
        switch (ucVkey) {
        case VK_SPACE:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_SHIFTONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEHANMODE,0L,0L);
            else if (FKC_CTRLONLY(fsFlags))
                WinSendMsg(hwnd,HIAM_CHANGEKBDTYPE,0L,0L);
            else if (FKC_NONE(fsFlags))
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(' ',0));
            return MRFROMLONG(TRUE);    // consumed
            break;
        case VK_TAB:
            WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT('\t',0));
                return MPFROMLONG(TRUE);    // consumed
                } else {
                return MPFROMLONG(FALSE);
                }
            break;
        case VK_HOME:
        case VK_END:
        case VK_LEFT:
        case VK_UP:
        case VK_DOWN:
        case VK_PAGEUP:
        case VK_PAGEDOWN:
        case VK_PAGEDOWN + 0x90:
        case VK_DELETE:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;  // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);
            break;
        case VK_ENTER:
        case VK_NEWLINE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            return MPFROMLONG(FALSE);   // not consumed
            break;
        case VK_RIGHT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);   // NOT consumed
                }
            break;
        case VK_BACKSPACE:
            if (hia->inbuf->newpos != HIABUF_NONE)
                {
                WinSendMsg(hwnd,HIAM_CANCELKEY,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_INSERT:
            if ((fsFlags & KC_CHAR) && (FKC_NONE(fsFlags))) break;   // considering keypad
            if (hia->inbuf->newpos != HIABUF_NONE)
                WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
            if (FKC_NONE(fsFlags))
                {
                WinSendMsg(hwnd,HIAM_CHANGEINSERTMODE,0L,0L);
                return MRFROMLONG(TRUE);
                } else {
                return MRFROMLONG(FALSE);
                }
            break;

        case VK_ESC :
            WinSendMsg(hwnd,HIAM_CANCELBUF,0L,0L);

            return FALSE;

        case VK_SHIFT :
        case VK_CTRL :
        case VK_ALT :
            return FALSE;
        }   // switch

        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );

        return FALSE;
        } // Virtualkey

    if(( fsFlags & ( KC_CTRL | KC_ALT )) || (ucChar < 32) || (ucChar > 127))
    {
        WinSendMsg( hwnd, HIAM_COMPLETEHCH, 0, 0 );
        return FALSE;
    }

    if (hia->hanmode == HCH_ENG)
        {
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    if ((hia_iskeypadkey(ucScancode))&&(fsFlags & KC_CHAR))
        {
        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(ucChar,0));
        return MRFROMLONG(TRUE);
        }

    ucChar = hia_transkey( fsFlags, ucScancode, ucChar );

    if (WinGetKeyState(HWND_DESKTOP,VK_CAPSLOCK))
        {
        if (fsFlags & KC_SHIFT)
            {
            ucChar = toupper(ucChar);
            } else {
            ucChar = tolower(ucChar);
            }
        }
    ckey = hia_convertkey(hia->kbdtype,ucChar);
    {
    HANCHAR completedHch;
    HANCHAR workingHch;
    if (ckey & 0x80)    // if hangul key
        {
        ULONG oldbufState = hia->inbuf->newpos;
        if (hia->kbdtype == HAN_KBD_2)
            completedHch = HIAAutomata2(hia,ckey);
            else
            completedHch = HIAAutomata3(hia,ckey);
        workingHch = SHORT1FROMMR(WinSendMsg(hwnd,HIAM_QUERYWORKINGHCH,0L,0L));

        if (completedHch)       // if hch completed
            {
            HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(completedHch,workingHch));
            HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(completedHch,workingHch));
            if (workingHch)     // begin composition of new hch
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,MPFROM2SHORT(completedHch,workingHch));

            } else {    // if hch not completed

            if (workingHch)     // if exist composing hch
            if (oldbufState)
                HIA_NotifyToConnected(hia,HIAN_COMPO_STEP,
                    MPFROM2SHORT(0,workingHch));
                else
                HIA_NotifyToConnected(hia,HIAN_COMPO_BEGIN,
                    MPFROM2SHORT(0,workingHch));
            }

        return MRFROMLONG(TRUE);    // consumed

        } else {  // !@#$%^&*() ,etc

        WinSendMsg(hwnd,HIAM_COMPLETEHCH,0L,0L);
        HIA_NotifyToConnected(hia,HIAN_INSERTHCH,
            MPFROM2SHORT(ckey,0));
        return MRFROMLONG(TRUE);    // consumed

        }
        }
    return MRFROMLONG(FALSE);    // not consumed
}
示例#8
0
MRESULT EXPENTRY stlrTitleBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   PSTLRFRAME p;
   /* -------------------------------------------------------------------
    window creation :
    store the handle of the owner window, the initial titlebar size,
    convert the title substituting \r\n with 1 space, update the titlebar
    font
   ------------------------------------------------------------------- */
   if (msg == WM_CREATE) {
      // if this is a global exception window, if the window ID is not
      // FID_TITLEBAR or if the owner window is not a frame, go to the
      // default system titlebar procedure
      if (!pd.ppib
          || (((PCREATESTRUCT)mp2)->id != FID_TITLEBAR)
          || !_isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner))
         goto defaultTitlebarProcedure;
      // get the frame data
      p = (PSTLRFRAME)WinQueryWindowPtr(((PCREATESTRUCT)mp2)->hwndOwner,
                                        g.cd.frame.cbData);
//      /*-*/ dbgPrintf5("*** pd.ppib:%08x, id: %04x, isOwnerFrame: %d, p: %08x\n",
//                       pd.ppib, ((PCREATESTRUCT)mp2)->id,
//                       _isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner), p);
      // if the frame window is a win32frame initialize the frame data now
      if (!p
          || ((p == FL_WIN32FRAME)
              && (NULL
                  == (p = _initWin32Frame(((PCREATESTRUCT)mp2)->hwndOwner)))))
         goto defaultTitlebarProcedure;
      // memorizza handle frame window
      WinSetWindowPtr(hwnd, g.cd.tbar.cbData, p);
      p->hTBar = hwnd;
      if (((PCREATESTRUCT)mp2)->pszText)
         p->cchTxt = psznconvcpy(p->achTxt, ((PCREATESTRUCT)mp2)->pszText, 260);
      p->wrclTitle.x = ((PCREATESTRUCT)mp2)->x;
      p->wrclTitle.y = ((PCREATESTRUCT)mp2)->y;
      p->wrclTitle.cx = ((PCREATESTRUCT)mp2)->cx;
      p->wrclTitle.cy = ((PCREATESTRUCT)mp2)->cy;
      // cambia font secondo preferenze
      if (o.tb.on && !(o.gen.disabled || pd.we.tbar))
         _setPPFont(hwnd, o.tb.achFont);

   /* -------------------------------------------------------------------
    hiliting/unhiliting of the titlebar :
    store the handle of the owner window, the initial titlebar size,
    convert the title substituting \r\n with 1 space, update the titlebar
    font
   ------------------------------------------------------------------- */
   } else if (msg == TBM_SETHILITE) {
      if (_getFrameData(hwnd, p)) {
         p->is.tbhilited = (BOOL)mp1;
         if (!o.gen.disabled && o.tb.on && !pd.we.tbar) {
            if (o.tb.ovrPP
                || (p->is.tbhilited && !p->is.tbactpp)
                || !(p->is.tbhilited || p->is.tbictpp)) {
               if (WinIsWindowShowing(hwnd)) {
                  p->hps = WinGetPS(hwnd);
                  DrawTitlebar(p);
                  WinReleasePS(p->hps);
               } /* endif */
               return (MRESULT)TRUE;
            // Š solo apparentemente ridondante, in realt… Š necessario quando
            // non Š ovrPP ed Š presente solo PP att. o inatt.
            } else if (!(p->is.tbactpp && p->is.tbictpp)) {
               repaintWindow(hwnd);
            } /* endif */
         } /* endif */
      } /* endif */

   /* -------------------------------------------------------------------
    titlebar font/color changed
    - if the font changed repaint the window
    - if any color changed reset the presparm presence flag
   ------------------------------------------------------------------- */
   } else if (msg == WM_PRESPARAMCHANGED) {
      if (!pd.we.tbar && _getFrameData(hwnd, p)) {
         ULONG ul;
         switch ((LONG)mp1) {
            case PP_FONTNAMESIZE:
               p->cyfont = 0;
               if (o.gen.disabled) break;
               if (WinIsWindowShowing(hwnd)) repaintWindow(hwnd);
               return (MRESULT)FALSE;
            case PP_ACTIVETEXTBGNDCOLOR:
            case PP_ACTIVETEXTBGNDCOLORINDEX:
            case PP_ACTIVECOLOR:
            case PP_ACTIVECOLORINDEX:
               p->is.tbactpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0;
               break;
            case PP_INACTIVETEXTBGNDCOLOR:
            case PP_INACTIVETEXTBGNDCOLORINDEX:
            case PP_INACTIVECOLOR:
            case PP_INACTIVECOLORINDEX:
               p->is.tbictpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0;
               break;
         } /* endswitch */
      } /* endif */

   /* -------------------------------------------------------------------
    the titlebar text changed. If this is a Win-OS/2 window set the
    window words to 0 so that the enhancements are skipped, otherwise
    store the new text.
   ------------------------------------------------------------------- */
   } else if (msg == WM_SETWINDOWPARAMS) {
      if (!pd.we.tbar && _getFrameData(hwnd, p)) {
         // unsubclass winOS2 windows titlebars
         if (p->is.winos2) {
            _resetDefaultProc(hwnd);
//            WinSetWindowULong(hwnd, g.cd.tbar.cbData, 0);
         } else {
            if ((PWNDPARAMS)mp1 &&
                (((PWNDPARAMS)mp1)->fsStatus & WPM_TEXT) &&
                ((PWNDPARAMS)mp1)->pszText) {
               p->cchTxt = psznconvcpy(p->achTxt, ((PWNDPARAMS)mp1)->pszText, 260);
               p->cyfont = 0;
            } /* endif */
         } /* endif */
      } /* endif */

   /* -------------------------------------------------------------------
    titlebar size/position changed : store new size and position
   ------------------------------------------------------------------- */
   } else if (msg == WM_WINDOWPOSCHANGED) {
      if ((((PSWP)mp1)->fl & (SWP_SIZE | SWP_MOVE))
          && _getFrameData(hwnd, p)) {
         p->wrclTitle.x = ((PSWP)mp1)->x;
         p->wrclTitle.y = ((PSWP)mp1)->y;
         p->wrclTitle.cx = ((PSWP)mp1)->cx;
         p->wrclTitle.cy = ((PSWP)mp1)->cy;
      } /* endif */

// **************************************************************************
// these messages are processed only if Styler/2 is not disabled:

   } else if (!o.gen.disabled) {

   /* -------------------------------------------------------------------
    check if this is the roll-the-window mouse event :
   ------------------------------------------------------------------- */
      if ((msg == o.roll.moumsg) && (SHORT2FROMMP(mp2) == o.roll.moukbd)) {
         if (!pd.we.wroll
             && o.roll.mou
             && _getFrameData(hwnd, p)
             && !p->is.win32
             && (o.roll.on || p->is.RLon)) {
            toggleRollCmd(p->hwnd, p);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the hide-titlebar mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.tbh.moumsg) && (SHORT2FROMMP(mp2) == o.tbh.moukbd)) {
         if (!pd.we.tbarhide
             && o.tbh.mou
             && _getFrameData(hwnd, p)
             && !p->is.win32
      // opzione titlehide attiva e non dialogo o disattivazione titlehide
             && ((o.tbh.on && !(p->is.dialog && o.tbh.noDlg)) || p->is.titleHide)) {
            toggleTitleBarHidingCmd(p->hwnd, p);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the change-Zorder mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.sizpos.ZordMoumsg)
                 && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) {
         if (!pd.we.sizemove
             && o.sizpos.Zmove
             && _getFrameData(hwnd, p)) {
            _stlrMsgPost(p->hwnd, STLR_ZORDACTIV, SW2_SFMOVETOBOTTOM);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the snap-to-screen-edge mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.sizpos.snapMoumsg)
                 && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)) {
         if (!pd.we.sizemove
             && o.sizpos.snap
             && _getFrameData(hwnd, p)) {
            // get the rectangle of the window and of its parent
            RECTL r, rParent;
            WinQueryWindowRect(p->hwnd, &r);
            WinQueryWindowRect(_winParent(p->hwnd), &rParent);
            // click on the left side of the titlebar
            if (MOUSEX(mp1) < (p->wrclTitle.cx / 3)) {
               r.xLeft = -p->ptBrd.x;
            // click on the right side of the titlebar
            } else if (MOUSEX(mp1) > (p->wrclTitle.cx * 2 / 3)) {
               r.xLeft = rParent.xRight - r.xRight + p->ptBrd.x;
            // click on the (horizontal) middle of the titlebar
            } else {
               r.xLeft = (rParent.xRight - r.xRight) / 2;
            } /* endif */
            // click on the bottom of the titlebar
            if (MOUSEY(mp1) < (g.sys.cyTbar / 3)) {
               r.yBottom = -p->ptBrd.y;
            // click on the top of the titlebar
            } else if (MOUSEY(mp1) > (g.sys.cyTbar * 2 / 3)) {
               r.yBottom = rParent.yTop - r.yTop + p->ptBrd.y;
            // click on the (vertical) middle of the titlebar
            } else {
               r.yBottom = (rParent.yTop - r.yTop) / 2;
            } /* endif */
            WinSetWindowPos(p->hwnd, 0, r.xLeft, r.yBottom, 0, 0,
                            SWP_MOVE | SWP_NOADJUST);
         } /* endif */

   /* -------------------------------------------------------------------
    enhanced window painting
   ------------------------------------------------------------------- */
      } else if (msg == WM_PAINT) {
         if (!pd.we.tbar
             && o.tb.on
             && _getFrameData(hwnd, p)
             && (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp)
                 || !(p->is.tbhilited || p->is.tbictpp))) {
            p->hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
            DrawTitlebar(p);
            WinEndPaint(p->hps);
            return (MRESULT)FALSE;
         } /* endif */

   /* -------------------------------------------------------------------
    override the default window tracking :
   ------------------------------------------------------------------- */
      } else if ((msg == WM_BUTTON1DOWN) || (msg == WM_BUTTON2DOWN)) {
         if (_getFrameData(hwnd, p)) {
            // override window motion by titlebar drag :
            // store the current mouse position (mp1)
            // the window motion will start only when the mouse will move
            g.tbdrag.mpPos = mp1;
            // if the window is not already moving store which mouse button
            // has to be released to stop the titlebar drag
            if (!g.tbdrag.hwnd) g.tbdrag.msg = ++msg;
            // store the handle of the titlebar (mouse motion events are not
            // processed when this is NULLHANDLE)
            g.tbdrag.hwnd = hwnd;
            // cattura i msg successivi del mouse
            WinSetCapture(HWND_DESKTOP, hwnd);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    terminate window motion through titlebar drag events :
   ------------------------------------------------------------------- */
      } else if ((msg == WM_BUTTON1UP) || (msg == WM_BUTTON2UP)) {
         if ((g.tbdrag.hwnd == hwnd)
              && (g.tbdrag.msg == msg)
              && _getFrameData(hwnd, p)) {
            HWND hwndParent;
            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
            g.tbdrag.msg = 0;
            g.tbdrag.hwnd = NULLHANDLE;
            // if the Ctrl key is not pressed and the window is not yet active
            // end the window is a size-move feature exception or the event
            // is not related to the Z-order motion feature or the snap-to-
            // parent-edge feature activate the window bringing it to the top
            if (!(SHORT2FROMMP(mp2) & KC_CTRL)
                && (g.hwnd.active != p->hwnd)
                && (pd.we.sizemove
                    || (!(o.sizpos.Zmove
                          && (msg == (o.sizpos.ZordMoumsg - 0x3a1))
                          && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd))
                        && (!(o.sizpos.snap
                          && (msg == (o.sizpos.snapMoumsg - 0x3a1))
                          && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd))))))
               WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0,
                               SWP_ACTIVATE | SWP_ZORDER);
         } /* endif */

   /* -------------------------------------------------------------------
    open the system menu on the titlebar :
   ------------------------------------------------------------------- */
      } else if (msg == WM_CONTEXTMENU) {
         if (!pd.we.tbar
             && o.tb.menu
             && _getFrameData(hwnd, p)) {
            // if this is the titlebar of a WPS folder simulate a context
            // menu event on the client window
            if (p->is.folder) {
               p->hClient = WinWindowFromID(p->hwnd, FID_CLIENT);
               WinPostMsg(p->hClient, WM_CONTEXTMENU,
                          (MPARAM)0x7fff7fff, MPVOID);
            // otherwise get the handle of the system menu and bring it to
            // the top via WinPopupMenu()
            } else if (p->hSMenu) {
               POINTL ptl;
               WinQueryPointerPos(g.hwnd.desktop, &ptl);
               g.cd.menu.pfnwp(p->hSMenu, MM_QUERYITEM,
                               (MPARAM)SC_SYSMENU, MPFROMP(&p->mi));
               g.hwnd.sysMenu = p->mi.hwndSubMenu;
               WinPopupMenu(g.hwnd.desktop, p->hSMenu, g.hwnd.sysMenu,
                            ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN |
                            PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1);
            } /* endif */
         } /* endif */
         return (MRESULT)TRUE;

   /* -------------------------------------------------------------------
    trap WM_MOUSEMOVE to implement various features :
    - do not move maximized windows
   ------------------------------------------------------------------- */
      } else if (msg == WM_MOUSEMOVE) {
         // if mouse button 1 or 2 were pressed and then the mouse position
         // changed
         if ((g.tbdrag.hwnd == hwnd)
             && (g.tbdrag.mpPos != mp1)
             && _getFrameData(hwnd, p)) {
            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
            g.tbdrag.hwnd = NULLHANDLE;
            g.tbdrag.msg = 0;
            // if this is a maximized window and the don't-move-max-window
            // feature is set ignore the event
            if (o.maxwin.nomove
                && p->is.max
                && !(pd.we.maxwin || p->is.shield || p->is.ovrdnomovemax))
               return (MRESULT)TRUE;
            WinSendMsg(p->hwnd, WM_TRACKFRAME, (MPARAM)TF_MOVE, g.tbdrag.mpPos);
            // ???????????????????????????????
            // this is needed because the next WM_BUTTONxUP is captured by
            // the WM_TRACKFRAME processing
//            if (!(SHORT2FROMMP(mp2) & KC_CTRL))
//               WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
            return (MRESULT)TRUE;
         } else if (g.is.onctrl != OCTLTBAR) {
            g.is.onctrl = OCTLTBAR;
            // ??????????????? this should be redundant
//            _resetHideMouTimer();
         } /* endif */
      } /* endif */
   // -------------------------------------------------------------------
   } /* endif */

defaultTitlebarProcedure:
   return g.cd.tbar.pfnwp(hwnd, msg, mp1, mp2);
}
示例#9
0
/*----------------------------------------------------------------------*/
MRESULT EXPENTRY DMLBSubclassListboxProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
/*----------------------------------------------------------------------*/
/* This window procedure is used to subclass a standard PM listbox      */
/* control.  This procedure will intercept certain mouse events on the  */
/* listbox to implement direct-manipulation functions.                  */
/*----------------------------------------------------------------------*/
{
SHORT    Item;          /* Listbox item number                          */
DMLBData  *InstData;     /* This instance-specific data (per listbox)    */

   /* The lisbox window pointer is to our instance data. */

   InstData = WinQueryWindowPtr(hwnd, QWL_USER);
     
   switch (msg) {
      /* Since this is just a subclass setup after the listbox window */
      /* is created, we never get a WM_CREATE message here.           */

      case WM_DESTROY:
           /* The listbox window is being destroyed.  Cleanup any     */
           /* resources we have allocated in this subclass.           */
           if (InstData->DragMIcon != NULLHANDLE) {
             WinDestroyPointer(InstData->DragMIcon);
             WinDestroyPointer(InstData->DragCIcon);
             WinDestroyPointer(InstData->NorthIcon);
             WinDestroyPointer(InstData->SouthIcon);
             WinDestroyPointer(InstData->DragNoDrp);
             WinDestroyPointer(InstData->DeletIcon);
             InstData->DragMIcon = NULLHANDLE;
           }
           /* Cleanup other resources */
           if (InstData->Dragging) {
             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);
           }
           /* Release instance data */
           free(InstData);
           WinSetWindowPtr(hwnd, 0L, NULL);
           break;

      case WM_TIMER:
           /* We get timer messages during dragging to implement */
           /* auto-scrolling of listbox when pointer is placed   */
           /* north or south of the listbox while dragging.      */

           if (!InstData->Dragging)  /* Ignore if not dragging   */
             break;

           if (SHORT1FROMMP(mp1)==DRAG_TIMERID) {
             switch (InstData->PrevLocation) { // Last known location of the pointer
               case POINT_INSIDE:
               case POINT_OUTSIDE:
                 /* Do nothing */
                 break;

               case POINT_NORTH:
                 /* Scroll up one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if ((Item != LIT_NONE) && (Item != 0))
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item-1), 0L);
                 break;

               case POINT_SOUTH:
                 /* Scroll down one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if (Item != LIT_NONE)
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item+1), 0L);
                 break;
             } /* switch on PrevLocation */
             return 0;
           }
           break;

      case WM_CONTEXTMENU: {
           SHORT CursorIndx, Max;

           /* User requested context menu... notify our owner.          */

           /* First find out what item the pointer is over.             */
           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max))
             CursorIndx = LIT_NONE;

           /* Tell our owner about it */
           return WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                      MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_CONTEXT),
                      MPFROMSHORT(CursorIndx));
           }
 
      case WM_MOUSEMOVE:
           /* Monitor the position of the mouse relative to the listbox */
           /* so we can set the pointer icon correctly and note the     */
           /* position for use during WM_TIMER processing.              */

           if (!InstData->Dragging)   /* Ignore if not dragging */
             break;

           DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));

           /* Set pointer icon appropriate for location */
           if (InstData->DragMIcon == NULLHANDLE) {
             // Load all the pointers (one time only)
             InstData->DragMIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGMOVE);
             InstData->DragCIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGCOPY);
             InstData->DragNoDrp= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGNONE);
             InstData->NorthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGNORTH);
             InstData->SouthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGSOUTH);
             InstData->DeletIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGDEL);
           }
           switch (InstData->PrevLocation) {
             case POINT_INSIDE:
               switch (InstData->TargetDropMode) {
               case DROPMODE_MOVE:
                 WinSetPointer(HWND_DESKTOP, InstData->DragMIcon); // Use MOVE pointer 
                 break;
               case DROPMODE_COPY:
                 WinSetPointer(HWND_DESKTOP, InstData->DragCIcon); // Use COPY pointer
                 break;
               case DROPMODE_DELETE:
                 WinSetPointer(HWND_DESKTOP, InstData->DeletIcon); // Use DELETE pointer
                 break;
               }
               break;
             case POINT_OUTSIDE:
               WinSetPointer(HWND_DESKTOP, InstData->DragNoDrp);   // No-drop pointer
               break;
             case POINT_NORTH:
               WinSetPointer(HWND_DESKTOP, InstData->NorthIcon);   // Scroll-up pointer
               break;
             case POINT_SOUTH:
               WinSetPointer(HWND_DESKTOP, InstData->SouthIcon);   // Scroll-down poineter
               break;
           }
 
           return (MRESULT)TRUE;  /* Note we processed the message */

      case WM_BEGINDRAG:
           {
           SHORT  Max;
           SHORT i, CursorIndx, hit;

           /* User started dragging with the pointer on our window */

           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );

           /* If we are currently dragging, cancel it (should not happen) */
 
           if ( InstData->Dragging ) {
             InstData->Dragging = FALSE;
             WinSetCapture( HWND_DESKTOP, NULLHANDLE );
             return (MRESULT)FALSE;
           }

           /* Get index of item under the mouse pointer and check */
           /* for reasonable numeric bounds.                      */
 
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max)) {
             DosBeep( 440L, 50L );  // Don't allow drag if not on a listbox item
             return (MRESULT)FALSE;
           }

           /* Since we currently support dragging only a single item, */
           /* de-select all items and just select the one under the   */
           /* pointer.  To support multiple-drag we would probably    */
           /* need to notify the owner so they could set the selection*/
           /* status of all items to be dragged (which may or may not */
           /* include the item under the pointer).                    */

           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPVOID);
           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(CursorIndx), MPFROMSHORT(TRUE));

           /* Note we are now dragging and capture the pointer. */
 
           InstData->Dragging = TRUE;
           WinSetCapture( HWND_DESKTOP, hwnd );
           InstData->PrevLocation = POINT_INSIDE;
           WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID, WinQuerySysValue(HWND_DESKTOP, SV_SCROLLRATE));
           return (MRESULT)TRUE;
           break;
           }
 
      case WM_ENDDRAG:
            {
            SHORT DropIndx, CurrIndx;
            SHORT SourceMax, TargetMax;      /* Num of items in source/target listbox */
            char  *CopyText;                 /* Text to be copied/moved */
            USHORT CopyTextLen;              /* Length of text */
            void   *CopyHand;                /* Handle of item to be copied/moved */
            BOOL  SameList = FALSE;          /* Source and target are same listbox */
 
            if (!InstData->Dragging)         /* Ignore if we are not dragging */
              return (MRESULT)FALSE;
 
            /* Clear dragging indicators and release pointer */

            InstData->Dragging = FALSE;
            WinSetCapture( HWND_DESKTOP, NULLHANDLE );
            WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);

            /* See if what is under the pointer will accept the drop */
            DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
            if (InstData->PrevLocation != POINT_INSIDE)
              return (MRESULT)TRUE;  /* Ignore drop outside a good listbox */

            if (hwnd == InstData->TargetHwnd)  // Source and target are same listbox
              SameList = TRUE;

            SourceMax = (SHORT)WinSendMsg(hwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;
            TargetMax = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;

            /* Get drop point and original selected point */

            DropIndx = DMLBLocateListboxItem(InstData->TargetHwnd, hwnd, SHORT2FROMMP(mp1), LLI_INSERTPOINT);
            CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);

            /* Prevent move onto same item as source, in same listbox           */
            /* being careful of DropIndx > SourceMax when drop after last item. */
            if ((InstData->TargetDropMode==DROPMODE_MOVE) &&
                (SameList) &&
                ((min(DropIndx,SourceMax) == CurrIndx) || (DropIndx == CurrIndx+1))) {
              DosBeep( 700L, 50L );  /* Don't drop before or after original */
              return (MRESULT)TRUE;
            }

            /* Make a copy of original to insert */

            CopyTextLen = (SHORT)WinSendMsg(hwnd,LM_QUERYITEMTEXTLENGTH,MPFROMSHORT(CurrIndx), 0L) + 1;
            CopyText = malloc(CopyTextLen);
            WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(CurrIndx, CopyTextLen), MPFROMP(CopyText));
            CopyHand = WinSendMsg(hwnd, LM_QUERYITEMHANDLE, MPFROMSHORT(CurrIndx), 0L);

            /* Insert before insertion point, or at end of list */
            if (DropIndx > TargetMax)
              DropIndx = LIT_END;

            /* Disable update during insert/delete for smoother visual and */
            /* prevent ownerdraw from occuring before new handles are set. */

            WinEnableWindowUpdate(hwnd, FALSE);
            WinEnableWindowUpdate(InstData->TargetHwnd, FALSE);
            
            /* Insert into target list */
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              DropIndx = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_INSERTITEM, MPFROMSHORT(DropIndx), MPFROMP(CopyText));
              WinSendMsg(InstData->TargetHwnd, LM_SETITEMHANDLE, MPFROMSHORT(DropIndx), MPFROMP(CopyHand));
            }
            free(CopyText);

            /* Tell owner of originating listbox what we are doing.  We must notify */
            /* the owner before we delete items because they may keep dynamic data  */
            /* in the item handles that has to be freed.  The item in question is   */
            /* the currently selected item in the listbox.                          */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                 if (!SameList)
                   WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE_MOVE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
              case DROPMODE_DELETE:
                 WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
            }

            /* If this is a move, delete original.  If it is in the same  */
            /* listbox as target, get new index since it may have         */
            /* changed due to inserted copy.                              */

            if ((InstData->TargetDropMode == DROPMODE_MOVE) || (InstData->TargetDropMode == DROPMODE_DELETE)) {
              CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);
              WinSendMsg(hwnd, LM_DELETEITEM, MPFROMSHORT(CurrIndx), 0L);
            }

            /* Select the newly inserted item.  If the old copy was             */
            /* above it in the same list, then the item number has changed by 1 */

            if ((DropIndx > CurrIndx) && (SameList) && (InstData->TargetDropMode==DROPMODE_MOVE))
              DropIndx--;
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(DropIndx), MPFROMSHORT(TRUE));
            }

            WinEnableWindowUpdate(hwnd, TRUE);
            WinEnableWindowUpdate(InstData->TargetHwnd, TRUE);

            /* Notify target of inserted items if necessary */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                if (SameList)
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_REORDERED),
                         MPFROMHWND(hwnd));
                else
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_MOVE),
                         MPFROMHWND(hwnd));
                break;
              case DROPMODE_COPY:
                WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_COPY),
                         MPFROMHWND(hwnd));
                break;
            }

            return (MRESULT)TRUE;
            }
 
      }
 
   /* Call previous window procedure to process this message */
   return ( (*(InstData->OldProcAddr)) ( hwnd, msg, mp1, mp2 )  );
   }
int ApplyPreviewBlock(HWND hwnd, char themeFile[], char szClass[], char szBase[], HINI hIni, int count)
{
    CBZSHARE *pCBZShare;
    CBZDATA *pCBZData;
    PLUGIN_LIST List;
    PAPPLYFN pApplyFn;
    PINITFN  pInitFn;
    char szError[CCHMAXPATH];
    char szProfile[CCHMAXPATH + 1];
    char szFile[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH + 1];
    char *tempPtr;
    int i,j;

    // get it for writing, so let's hurry
    if (DosGetNamedSharedMem((PPVOID) & pCBZShare, CBZ_SHARE, PAG_READ)
            != NO_ERROR)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed to Get Shared Memory", 0UL);
        return count;
    }

    if ((pCBZData = WinQueryWindowPtr(hwnd, pCBZShare->ulDataOffset)) == NULL)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Window Data", szFile, 0UL);
        DosFreeMem(pCBZShare);
        return count;
    }
    DosFreeMem(pCBZShare);


    //update the shared memory.
    if (strcmp(szClass, "TITLEBAR") == 0)
        pCBZData->sTitlebarIndex = count;
    else if (strcmp(szClass, "FRAME") == 0)
        pCBZData->sFrameBackgroundIndex = count;
    else if (strcmp(szClass, "FRAMEBRDR") == 0)
        pCBZData->sFrameBorderIndex = count;
    else if (strcmp(szClass, "PUSHBUTTON") == 0)
        pCBZData->sPushButtonIndex = count;
    else if (strcmp(szClass, "RADIOBUTTON") == 0)
        pCBZData->sRadioButtonIndex = count;
    else if (strcmp(szClass, "CHECKBOX") == 0)
        pCBZData->sCheckBoxIndex = count;
    else if (strcmp(szClass, "MINMAX") == 0)
        pCBZData->sMinMaxIndex = count;
    else if (strcmp(szClass, "MENU") == 0)
        pCBZData->sMenuIndex = count;


    if (!runParser(themeFile, szClass, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyBlock", szError, 0UL);
        return count;
    }

    if (List.cbPlugins <= 0)
        return count;


    pCBZData->cbPlugins = count + List.cbPlugins;

    if (List.cbPlugins > 0)
    {
        if (strcmp(szClass, "TITLEBAR") == 0)
            pCBZData->bTitlebarEnabled = TRUE;
        else if (strcmp(szClass, "FRAME") == 0)
            pCBZData->bFrameBackgroundEnabled = TRUE;
        else if (strcmp(szClass, "FRAMEBRDR") == 0)
            pCBZData->bFrameBorderEnabled = TRUE;
        else if (strcmp(szClass, "PUSHBUTTON") == 0)
            pCBZData->bPushButtonEnabled = TRUE;
        else if (strcmp(szClass, "RADIOBUTTON") == 0)
            pCBZData->bRadioButtonEnabled = TRUE;
        else if (strcmp(szClass, "CHECKBOX") == 0)
            pCBZData->bCheckBoxEnabled = TRUE;
        else if (strcmp(szClass, "MINMAX") == 0)
            pCBZData->bMinMaxEnabled = TRUE;
        else if (strcmp(szClass, "MENU") == 0)
            pCBZData->bMenuEnabled = TRUE;
    }
    else
    {
        if (strcmp(szClass, "TITLEBAR") == 0)
            pCBZData->bTitlebarEnabled = FALSE;
        else if (strcmp(szClass, "FRAME") == 0)
            pCBZData->bFrameBackgroundEnabled = FALSE;
        else if (strcmp(szClass, "FRAMEBRDR") == 0)
            pCBZData->bFrameBorderEnabled = FALSE;
        else if (strcmp(szClass, "PUSHBUTTON") == 0)
            pCBZData->bPushButtonEnabled = FALSE;
        else if (strcmp(szClass, "RADIOBUTTON") == 0)
            pCBZData->bRadioButtonEnabled = FALSE;
        else if (strcmp(szClass, "CHECKBOX") == 0)
            pCBZData->bCheckBoxEnabled = FALSE;
        else if (strcmp(szClass, "MINMAX") == 0)
            pCBZData->bMinMaxEnabled = FALSE;
        else if (strcmp(szClass, "MENU") == 0)
            pCBZData->bMenuEnabled = FALSE;
    }


    strcpy(szPluginBase, szBase);
    strcat(szPluginBase, "plugins\\");


    for (j = 0; j < List.cbPlugins; j++)
    {
        //copy plugin names to shared memory.
        strcpy(pCBZData->Plugins[count + j].szPluginDLL,
               List.pPluginAttributes[j].szPluginName);

        for (i = 0; i < List.pPluginAttributes[j].cbAttributes; i++)
        {
            //If there is a %CBZBaseDir% in the attribute, replace it with the basePath
            if (strstr(List.pPluginAttributes[j].keyValue[i].value, "%CBZBaseDir%") != NULL)
            {
                //%CBZBaseDir% must be at the start of the string
                //allocate space for the new string
                tempPtr = (char *) malloc(sizeof(char) * (strlen(szBase) + strlen(List.pPluginAttributes[j].keyValue[i].value) - strlen("%CBZBaseDir%") + 1));
                tempPtr[0] = '\0';
                strcat(tempPtr, szBase);
                sscanf(List.pPluginAttributes[j].keyValue[i].value, "%%CBZBaseDir%%\\%s", szProfile);
                strcat(tempPtr, szProfile);
                free(List.pPluginAttributes[j].keyValue[i].value);
                //replace the old string with the new string.
                List.pPluginAttributes[j].keyValue[i].value = tempPtr;
            }
        }

        //plugins might not be in LIBPATH, create full path here.
        _makepath(szFile, NULL, szPluginBase, List.pPluginAttributes[j].szPluginName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &(pCBZData->Plugins[count + j].hModDll)) == NO_ERROR)
        {

            //Query The Plugin's CBZPluginDataSize Function
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZInit",
                                 (PFN *) & (pInitFn)) != NO_ERROR)
            {
                //error in Plugin's initialization...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                continue;           //end this iteration..try next plugin.

            }
            //Call the Plugins Init function.
            if (!pInitFn(hIni, "", szClass, (PVOID *) & (pCBZData->Plugins[count + j].pData)))
            {
                //error in Plugin's initialization...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                continue;           //end this iteration..try next plugin.

            }

            //Query the Plugin's Window Procedure.
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZPluginWndProc",
                    (PFN *) & (pCBZData->Plugins[count + j].pPluginWndProc)) != NO_ERROR)
            {
                //error getting the Plugin's WndProc...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                DosFreeMem(pCBZData->Plugins[count + j].pData);
                continue;           //end this iteration...try next plugin.

            }

            //Query the address of the plugin's Render function.
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZPluginRender",
                   (PFN *) & (pCBZData->Plugins[count + j].pfnPluginRender)) != NO_ERROR)
            {
                //Error getting CBZPluginRender function!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                DosFreeMem(pCBZData->Plugins[count + j].pData);
                continue;           //end this iteration...try next plugin.

            }



            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
            {
                //check return code from this to make sure it was sucessful.. if not disable the plugin
                pApplyFn(szClass, (List.pPluginAttributes[j].keyValue),
                         List.pPluginAttributes[j].cbAttributes,
                         List.pPluginAttributes[j].enabledState,
                         pCBZData->Plugins[count + j].pData);
            }
            else
            {
                PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
            }
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyBlock", "Error Querying Plugin Module.. (Missing?)", 0UL);
            pCBZData->cbPlugins = j - 1;
            break;
            //disable it here
        }

    }


    i = List.cbPlugins;
    //delete all the attributes in the plugin/key/value list
    CBZFreePLUGIN_LIST(&List);
    return count + i;
}
示例#11
0
文件: hchlb.c 项目: komh/hanedit2
void refreshClient( HWND hwnd )
{
    PHCHLB hchlb = WinQueryWindowPtr( hwnd, 0 );

    WinSendMsg( hchlb->hwndClient, HCHLMC_REFRESH, 0, 0 );
}
BOOL _ApplyPreviewBlock(HWND hwnd, char themeFile[], char szCBZBase[], char szShare[], char szClass[], int index)
{
    PSFRAMESHARE *pFrameShare;
    PLUGIN_LIST List;
    HMODULE hMod;
    PAPPLYFN pApplyFn;
    PINITFN pInitFn;
    char szError[CCHMAXPATH];
    char szProfile[CCHMAXPATH + 1];
    char szFile[CCHMAXPATH + 1];
    char szSaveName[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH + 1];
    char *tempPtr;
    int i, j;
    PSTBDATA *pTBData;
    HINI hIni;
    PDESTROYFN pDestroyFn;
    ULONG ulDataOffset;

//    if (DosGetNamedSharedMem((PPVOID) & pFrameShare, PSFRAME_SHARE, PAG_READ) != NO_ERROR)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Shared Memory", szFile, 0UL);
        return FALSE;
    }
    ulDataOffset = pFrameShare->ulDataOffset + index * sizeof(void *);
    DosFreeMem(pFrameShare);

    if ((pTBData = WinQueryWindowPtr(hwnd, ulDataOffset)) == NULL)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Window Data", szFile, 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szFile,
                               CCHMAXPATH))
        return FALSE;
    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwnd), szFile)) == NULLHANDLE)
        return FALSE;

    // free plugin resources
    for (i = 0; i < pTBData->cbPlugins; i++)
    {
        //Query The Plugin's CBZInit Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZDestroy",
                             (PFN *) & (pDestroyFn)) == NO_ERROR)
        {
            //Call the plugins destroy function.
            pDestroyFn(pTBData->Plugins[i].pData);
        }

        if (pTBData->Plugins[i].hModDll != NULLHANDLE)
            DosFreeModule(pTBData->Plugins[i].hModDll);
    }

    if (!runParser(themeFile, szClass, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", szError, 0UL);
        PrfCloseProfile(hIni);
        return FALSE;
    }

    strcpy(szPluginBase, szCBZBase);
    strcat(szPluginBase, "plugins\\");

    //update the windows memory.
    pTBData->cbPlugins = List.cbPlugins;

    //fill in ptb2 structure.
    for (i = 0; i < (pTBData->cbPlugins); i++)
    {
        //Initialize to some initial values...
        pTBData->Plugins[i].bActiveEnabled = TRUE;
        pTBData->Plugins[i].bInactiveEnabled = TRUE;
        pTBData->Plugins[i].pData = NULL;
        pTBData->Plugins[i].cbData = 0;

        //copy plugin names to shared memory.
        strcpy(pTBData->Plugins[i].szPluginDLL,
               List.pPluginAttributes[i].szPluginName);

        _makepath(szFile, NULL, szPluginBase, pTBData->Plugins[i].szPluginDLL, "DLL");
        //Load the Plugin Module
        if (DosLoadModule(szError, sizeof(szError), szFile,
                          &(pTBData->Plugins[i].hModDll)) != NO_ERROR)
        {
            //Error loading the dll...disable this plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            continue;           //end this iteration...try next plugin.

        }

        //Query The Plugin's CBZPluginDataSize Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZInit",
                             (PFN *) & (pInitFn)) != NO_ERROR)
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }
        //Call the Plugins Init function.
        if (!pInitFn(hIni, "", szClass, (PVOID *) & (pTBData->Plugins[i].pData)))
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }

        //Query the Plugin's Window Procedure.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginWndProc",
                (PFN *) & (pTBData->Plugins[i].pPluginWndProc)) != NO_ERROR)
        {
            //error getting the Plugin's WndProc...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }

        //Query the address of the plugin's Render function.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginRender",
               (PFN *) & (pTBData->Plugins[i].pfnPluginRender)) != NO_ERROR)
        {
            //Error getting CBZPluginRender function!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }
    }                           //end active plugin for(..) loop

    for (j = 0; j < List.cbPlugins; j++)
    {

        for (i = 0; i < List.pPluginAttributes[j].cbAttributes; i++)
        {
            //If there is a %CBZBaseDir% in the attribute, replace it with the basePath
            if (strstr(List.pPluginAttributes[j].keyValue[i].value, "%CBZBaseDir%") != NULL)
            {
                //%CBZBaseDir% must be at the start of the string
                //allocate space for the new string
                tempPtr = (char *) malloc(sizeof(char) * (strlen(szCBZBase) + strlen(List.pPluginAttributes[j].keyValue[i].value) - strlen("%CBZBaseDir%") + 1));
                tempPtr[0] = '\0';
                strcat(tempPtr, szCBZBase);
                sscanf(List.pPluginAttributes[j].keyValue[i].value, "%%CBZBaseDir%%\\%s", szProfile);
                strcat(tempPtr, szProfile);
                free(List.pPluginAttributes[j].keyValue[i].value);
                //replace the old string with the new string.
                List.pPluginAttributes[j].keyValue[i].value = tempPtr;
            }
        }

        //plugins might not be in LIBPATH, create full path here.
        _makepath(szFile, NULL, szPluginBase, List.pPluginAttributes[j].szPluginName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &hMod) == NO_ERROR)
        {
            if (DosQueryProcAddr(hMod, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
            {
                if (pApplyFn == NULL)
                {
                    PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "pApplyFn is NULL!", 0UL);
                }

                //check return code from this to make sure it was sucessful.. if not disable the plugin
                pApplyFn(szClass, (List.pPluginAttributes[j].keyValue),
                         List.pPluginAttributes[j].cbAttributes,
                         List.pPluginAttributes[j].enabledState,
                         pTBData->Plugins[j].pData);
            }
            else
            {
                PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
            }
            DosFreeModule(hMod);
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Error Querying Plugin Module.. (Missing?)", 0UL);
            pTBData->cbPlugins = j - 1;
            break;
            //disable it here
        }

    }

    //delete all the attributes in the plugin/key/value list
    CBZFreePLUGIN_LIST(&List);

    PrfCloseProfile(hIni);
    return TRUE;
}
MRESULT EXPENTRY AirTrafficControlDlg (HWND hwnd, ULONG msg,
    MPARAM mp1, MPARAM mp2)
{
    PINST   pinst;

    pinst = (PINST) WinQueryWindowPtr(hwnd,QWL_USER);

    switch (msg)
    {
        case WM_INITDLG:
        {
            /*
             *  INITIALIZE APPLICATION
             */

            CNRINFO     ccinfo;         // Container info structure

            // Initialize instance data
            pinst = (PINST) calloc (1, sizeof *pinst);
            WinSetWindowPtr(hwnd,QWL_USER,pinst);
            pinst->hwndCnr = WinWindowFromID (hwnd, IDCNR_SAMPLE);
            pinst->hab     = WinQueryAnchorBlock (hwnd);
            pinst->hwndAircraftMenu =               // Load aircraft menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_AIRCRAFT);
            pinst->hwndContainerMenu =              // Load container menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_CONTAINER);
            pinst->CurrentView = IDMVIEW_RADAR;

            // Set container info to request owner background painting
            memset (&ccinfo, 0, sizeof ccinfo);
            ccinfo.cb = sizeof ccinfo;
            ccinfo.flWindowAttr = CA_OWNERPAINTBACKGROUND;
            WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                MPFROMLONG(CMA_FLWINDOWATTR));

            // Subclass container window to provide background painting
            pfnwpCnr = WinSubclassWindow (pinst->hwndCnr,
                CnrSubclassWndProc);
            assert (pfnwpCnr);

            // Insert the columns into the container
            InsertContainerColumns (pinst);

            // Insert the initial records into the container
            InsertContainerRecords (pinst);

            // Start a timer to control aircraft
            WinStartTimer (pinst->hab, hwnd,
                IDTIMER_ADJUSTAIRCRAFT, AIRCRAFT_ADJUST_FREQUENCY);

            // The container is ready for viewing
            WinShowWindow (pinst->hwndCnr, TRUE);

            SetUpControllerHandoffValueSet (hwnd);

            return 0;
        }

        case WM_TIMER:

            /*
             *  DO TIME-RELATED AIRCRAFT HANDLING
             */

            if (SHORT1FROMMP (mp1) == IDTIMER_ADJUSTAIRCRAFT)
            {
                PAPPCNRREC      pacrTraverse;

                // Loop through all container records
                for (pacrTraverse = FIRST_CNR_ITEM (pinst->hwndCnr);
                    pacrTraverse;
                    pacrTraverse = NEXT_CNR_ITEM(pinst->hwndCnr,pacrTraverse))
                {
                    BOOL        fInvalid = FALSE;

                    if (pinst->CurrentView == IDMVIEW_RADAR)
                    {
                        /* Erase the record from previous location. */
                        WinSendMsg (pinst->hwndCnr, CM_ERASERECORD,
                            MPFROMP(pacrTraverse), NULL);
                    }

                    // Maneuver the aircraft
                    if (ManeuverAircraft (pacrTraverse))
                    {
                        // Update aircraft text if necessary
                        SetRecordText (pacrTraverse);
                        fInvalid = TRUE;
                    }

                    if (fInvalid || pinst->CurrentView == IDMVIEW_RADAR)
                        /* Paint the record in its new position */
                        WinSendMsg (pinst->hwndCnr, CM_INVALIDATERECORD,
                            MPFROMP(&pacrTraverse),
                            MPFROMSHORT(1));
                }
            }
            else
                if (SHORT1FROMMP (mp1) == IDTIMER_DISPLAYTIMEDMSG)
                {
                    WinStopTimer (pinst->hab, hwnd,
                        IDTIMER_DISPLAYTIMEDMSG);
                    WinSetDlgItemText (hwnd, IDST_STATUSMESSAGES, "");
                }


            return 0;


        case WM_CONTROL:
            if (SHORT1FROMMP (mp1) == IDCNR_SAMPLE)
                switch (SHORT2FROMMP (mp1))
                {
                    case CN_CONTEXTMENU:
                    {
                        /*
                         *  MENU HANDLING
                         */

                        POINTL  ptlMouse;
                        HWND    hwndMenu;

                        WinQueryMsgPos (pinst->hab, &ptlMouse);

                        // Save pointer to record mouse is over, if any
                        pinst->pacrSelected = (PAPPCNRREC) mp2;

                        hwndMenu = pinst->pacrSelected ?
                            pinst->hwndAircraftMenu :
                            pinst->hwndContainerMenu;

                        // Display menu
                        WinPopupMenu (HWND_DESKTOP, hwnd, hwndMenu,
                            ptlMouse.x, ptlMouse.y, 0,
                            PU_HCONSTRAIN | PU_VCONSTRAIN |
                            PU_KEYBOARD | PU_MOUSEBUTTON1 |
                            PU_MOUSEBUTTON2 |
                            PU_MOUSEBUTTON3);
                        return 0;
                    }

                    case CN_INITDRAG:
                        ProcessInitDrag (
                            WinWindowFromID (hwnd, SHORT1FROMMP (mp1)),
                            ((PCNRDRAGINIT) (PVOIDFROMMP(mp2))));
                        return 0;

                    case CN_SCROLL:
                        WinInvalidateRect (pinst->hwndCnr, 0, 0);
                        return 0;
                }
            else

/*
 *  HANDLE WM_CONTROL MESSAGES FROM VALUE SET CONTROL
 */

                if (SHORT1FROMMP (mp1) == IDVS_CONTROLLERS)
                    switch (SHORT2FROMMP (mp1))
                    {
                        case VN_SELECT:
                            DisplayTimedMsg (pinst->hab, hwnd,
                                "Drag an airplane to one "
                                "of the controller icons to hand off to "
                                "another controller.", 8);

                            return 0;

                        case VN_DROP:
                        {
                            PVSDRAGINFO pvsdinfo = (PVSDRAGINFO)
                               PVOIDFROMMP (mp2);
                            PDRAGINFO   pdinfo = pvsdinfo->pDragInfo;
                            PDRAGITEM   pditem;
                            INT         iItem;
                            INT         cHandedOffAircraft = 0;
                            CHAR        szHandedOffAircraft [100];

                            *szHandedOffAircraft = 0;

                            assert (DrgAccessDraginfo(pdinfo));

                            for (iItem = 0; iItem < pdinfo->cditem; ++iItem)
                            {
                                PAPPCNRREC      pacr;

                                pditem =  DrgQueryDragitemPtr (pdinfo, iItem);

                                pacr = (PAPPCNRREC) pditem->ulItemID;

                                if (pdinfo->usOperation == DO_MOVE)
                                {
                                    WinSendMsg (pdinfo->hwndSource,
                                        CM_REMOVERECORD,
                                        MPFROMP(&pacr),
                                        MPFROM2SHORT (1, CMA_INVALIDATE));

                                    if (cHandedOffAircraft++)
                                        strcat (szHandedOffAircraft, ", ");

                                    strcat (szHandedOffAircraft,
                                        pacr->pszCallsign);
                                }
                            }

                            if (cHandedOffAircraft)
                            {
                                CHAR    szMsg [200];

                                sprintf (szMsg,
                                    "Aircraft %s %s been handed off "
                                    "to %s Sector controller.",
                                    szHandedOffAircraft,
                                    cHandedOffAircraft > 1 ?
                                        "have" : "has",
                                    pvsdinfo->usColumn == 1 ?
                                        "West" : "East");

                                DisplayTimedMsg (pinst->hab, hwnd,
                                    szMsg, 8);
                            }

                            DrgFreeDraginfo (pdinfo);
                            WinAlarm (HWND_DESKTOP, WA_NOTE);
                            return 0;
                        }
                    }

            return 0;


        case WM_COMMAND:

            /*
             *  COMMAND HANDLING
             */

            switch (SHORT1FROMMP (mp1))
            {
                case IDMAIRCRAFT_CONTROLINSTRUCT:   // Issue instruction
                {
                    // Present "Control Aircraft" dialog
                    WinDlgBox (HWND_DESKTOP, hwnd,
                        ControlInstructionDlg, 0,
                        IDDLG_CONTROLAIRCRAFT, pinst);
                    return 0;
                }

                case IDMVIEW_RADAR:
                case IDMVIEW_NAME:
                case IDMVIEW_TREE:
                case IDMVIEW_DETAILS:
                case IDMVIEW_TEXT:
                {
                    static const ULONG  aViews [] =
                        { CV_ICON, CV_NAME, CV_TREE, CV_DETAIL, CV_TEXT };

                    CNRINFO ccinfo;
                    memset (&ccinfo, 0, sizeof ccinfo);
                    ccinfo.cb = sizeof ccinfo;
                    ccinfo.flWindowAttr = CA_DETAILSVIEWTITLES |
                        CA_TITLESEPARATOR | CA_TREELINE |
                        CA_OWNERPAINTBACKGROUND |
                        aViews [SHORT1FROMMP (mp1) - IDMVIEW_BASE];
                    WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                        MPFROMLONG(CMA_FLWINDOWATTR));
                    pinst->CurrentView = SHORT1FROMMP (mp1);

                    WinInvalidateRect (pinst->hwndCnr, 0, 0);
                    return 0;
                }
            }

            return WinDefDlgProc (hwnd, msg, mp1, mp2);

        default:
            return WinDefDlgProc (hwnd, msg, mp1, mp2);
    }
}
static MRESULT EXPENTRY CnrSubclassWndProc
(
    HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2
)
{
    if (msg == CM_PAINTBACKGROUND)
    {
        POWNERBACKGROUND    pownbckg = (POWNERBACKGROUND) mp1;
        RECTL               rclCnr;
        PINST               pinstMain;

        pinstMain = (PINST) WinQueryWindowPtr
            (WinQueryWindow (hwnd, QW_OWNER), QWL_USER);

        if (pinstMain->CurrentView != IDMVIEW_RADAR)
            return FALSE;

        WinQueryWindowRect (hwnd, &rclCnr);

        /*
         *  The radar screen is drawn once into a bitmap and
         *  subsequently GpiBitBlt'd onto the screen
         */

        if (! pinstMain->hbmRadar)
        {
            RECTL               rclRunway;
            LONG                cxRunway;
            LONG                cyRunway;
            ARCPARAMS           arcp;           // arc parameters
            POINTL              ptlScreenMidpoint;
            POINTL              ptlMarkerMidpoint;
            INT                 RadiusMultiplier;

            CreateMemoryPS (pinstMain, pownbckg->hps, &rclCnr);
            pinstMain->hbmRadar =
                CreateBitmap (pinstMain->hpsMemRadar, &rclCnr);

            WinFillRect (pinstMain->hpsMemRadar, &rclCnr,
                CLR_DARKGREEN);

            ptlScreenMidpoint.x = rclCnr.xRight / 2;
            ptlScreenMidpoint.y = rclCnr.yTop / 2;


            /*
             * Draw runway
             */

            cxRunway          = rclCnr.xRight / 60;
            cyRunway          = rclCnr.yTop / 10;
            rclRunway.xLeft   = ptlScreenMidpoint.x - cxRunway / 2;
            rclRunway.xRight  = rclRunway.xLeft + cxRunway;
            rclRunway.yBottom = ptlScreenMidpoint.y - cyRunway / 2;
            rclRunway.yTop    = rclRunway.yBottom + cyRunway;
            WinFillRect (pinstMain->hpsMemRadar, &rclRunway, CLR_WHITE);


            /*
             * Draw approach outer marker (3 elipses)
             */

            ptlMarkerMidpoint.x = ptlScreenMidpoint.x;
            ptlMarkerMidpoint.y = ptlScreenMidpoint.y - rclCnr.yTop / 6;
            GpiMove (pinstMain->hpsMemRadar, &ptlMarkerMidpoint);

            arcp.lP = rclCnr.xRight / 20;
            arcp.lQ = rclCnr.yTop / 80;
            arcp.lR = arcp.lS = 0L;
            GpiSetArcParams(pinstMain->hpsMemRadar,&arcp);
            GpiSetColor (pinstMain->hpsMemRadar, CLR_WHITE);
            GpiFullArc (pinstMain->hpsMemRadar, DRO_OUTLINE, MAKEFIXED(1,0));

            arcp.lP =
            arcp.lQ = rclCnr.yTop / 60;
            arcp.lR = arcp.lS = 0L;
            GpiSetArcParams(pinstMain->hpsMemRadar,&arcp);
            GpiSetColor (pinstMain->hpsMemRadar, CLR_WHITE);
            GpiFullArc (pinstMain->hpsMemRadar, DRO_OUTLINE, MAKEFIXED(1,0));

            arcp.lP =
            arcp.lQ = 1;
            arcp.lR = arcp.lS = 0L;
            GpiSetArcParams(pinstMain->hpsMemRadar,&arcp);
            GpiSetColor (pinstMain->hpsMemRadar, CLR_WHITE);
            GpiFullArc (pinstMain->hpsMemRadar, DRO_OUTLINE, MAKEFIXED(1,0));


            /*
             * Draw distance rings concentric circles
             */

            GpiMove (pinstMain->hpsMemRadar, &ptlScreenMidpoint);
            arcp.lP = arcp.lQ = min (rclCnr.xRight, rclCnr.yTop) / 9;
            arcp.lR = arcp.lS = 0L;
            GpiSetArcParams(pinstMain->hpsMemRadar,&arcp);

            GpiSetColor (pinstMain->hpsMemRadar, CLR_BLACK);

            for (RadiusMultiplier = 1; RadiusMultiplier <= 4; ++RadiusMultiplier)
                GpiFullArc(pinstMain->hpsMemRadar,DRO_OUTLINE,
                    MAKEFIXED(RadiusMultiplier,0));
        }

        DrawBitmap (pinstMain, pownbckg->hps, &pownbckg->rclBackground);

        return (MRESULT) TRUE;
    }
    else
        return pfnwpCnr (hwnd, msg, mp1, mp2);
}
示例#15
0
 MRESULT EXPENTRY icqFrameWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
    switch(msg)
    {
    case WM_DDE_INITIATEACK:
       return (MRESULT) icqDDEInitiateAck(hwnd, (HWND)mp1, (PDDEINIT)mp2);

    case WM_DDE_DATA:
       DBGMessage("WM_DDE_DATA");
       icqDDEData(hwnd, (PDDESTRUCT) mp2);
       break;

    case WM_CLOSE:
       DBGMessage("WM_CLOSE");
       close(hwnd);
       break;

    case WM_CREATE:
       icqskin_cfgWindow(hwnd,ICQFRAME,0);
       break;

    case WM_DESTROY:
       destroy(hwnd);
       break;

    case WM_ERASEBACKGROUND:
       erase(hwnd,(HPS) mp1, (PRECTL) mp2);
       break;

    case WM_SIZE:
       resize(hwnd,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       broadcast(hwnd,WMICQ_AUTOSIZE,0,0);
       break;

    case WM_PAINT:
       paint(hwnd);
       break;

    case WM_SETICON:
       WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),msg,mp1,mp2);
       break;

    case WM_COMMAND:
       action(hwnd,SHORT1FROMMP(mp1), SHORT1FROMMP(mp2));
       break;

    case WM_PRESPARAMCHANGED:
       ppchanged(hwnd,LONGFROMMP(mp1));
       break;

    case WM_SETWINDOWPARAMS:
       return setparm(hwnd, PVOIDFROMMP(mp1), mp2);

    case WMICQ_SETNAME:
//       strncpy( ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name, (const char *) mp1, 19);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name = (const char *) mp1;
       break;

    case WMICQ_SETICQHANDLE:
       DBGTracex(mp1);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq = (HICQ) mp1;
       break;

    case WMICQ_GETICQHANDLE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq;

    case WMICQ_SETBUTTONTBL:
       setbuttons(hwnd,(const struct icqButtonTable *) mp1, (int) mp2);
       break;

    case WMICQ_QUERYPALLETE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal;

    case WMICQ_EVENT:  // MP1 = type,code,user  MP2 = parm
       event(hwnd,CHAR3FROMMP(mp1),CHAR4FROMMP(mp1),SHORT1FROMMP(mp1),(ULONG) mp2);
       break;

    case WMICQ_SELECTPAL:
       icqskin_loadPallete( (HPS) mp1, 0, ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal);
       break;

    case 0x041E:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case 0x041F:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case WM_BEGINDRAG:
       return beginDrag(hwnd, (POINTS *) &mp1);

    case WM_ENDDRAG:
       return endDrag(hwnd);

    case WM_TIMER:
       timer(hwnd);
       break;

#ifdef SKINNED_GUI
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->bg;
#else
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) NO_IMAGE;
#endif

    case WM_OWNERPOSCHANGE:
       DBGMessage("WM_OWNERPOSCHANGE");
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WM_MOUSEMOVE:
       if(WinQueryCapture(HWND_DESKTOP) == hwnd);
          saveMouse(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1));
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WMICQ_CLEAR:
       clearSkin( (ICQFRAME *) WinQueryWindowPtr(hwnd,0));
       break;

    case WMICQ_LOADSKIN:
       loadSkin(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_SKINCHILDS:
       loadSkin4Childs(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_RESTORE:
       restoreWindow(hwnd,(const char *) mp1,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       break;

    case WMICQ_STORE:
       storeWindow(hwnd,(const char *) mp1);
       break;

    case WMICQ_CONFIGURE:
       configure(hwnd,(int) mp1);
       break;

    case WMICQ_SETMSGCHILD:
       createchild(hwnd, (const MSGCHILD *) mp1, SHORT1FROMMP(mp2));
       break;

    case WMICQ_SKINELEMENT:
       skinElement(hwnd,(HWND) mp1, (const char **) mp2);
       break;

    case WMICQ_DRAWCONTENTS:
       break;

    case WMICQ_AUTOSIZE:
       autoSize(hwnd);
       break;

    case WMICQ_SIZEBUTTONS:
       return (MRESULT) sizeButtonBar(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),(const USHORT *) mp2);

    case WMICQ_INVALIDATE:
       DBGMessage("WMICQ_INVALIDATE");
       WinInvalidateRect(hwnd,NULL,TRUE);
       break;

    /*---[ SysTray ]--------------------------------------------*/

    case WM_BUTTON2CLICK | 0x2000:
       icqShowPopupMenu(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq, 0, ICQMNU_MODES, 0, 0);
       return (MRESULT) TRUE;

    case WM_BUTTON1CLICK | 0x2000:
       openMessage(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    case WM_TRAYEXIT:	// When tray exits/crashes, it posts WM_TRAYEXIT (0xCD20) to all tray windows.
       icqDisableSysTray(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    /*---[ Default window processing ]--------------------------*/

    default:
       return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return 0;
 }
示例#16
0
extern MRESULT APIENTRY Dde_Processor ( HWND Server, ULONG Msg, MPARAM mp1, MPARAM mp2 ) {

   switch ( Msg ) {

      case WM_CREATE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) mp1 ;
         WinSetWindowPtr ( Server, QWL_USER, Parms ) ;
         return ( 0 ) ; }

      case WM_DESTROY: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         Parms->Topic->Terminate ( Server, Parms->Client, FALSE ) ;
         return ( 0 ) ; }

      case WM_DDE_REQUEST: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Request ( Server, Client, Item ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_POKE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         int Format = int ( Request->usFormat ) ;
         PVOID Data = PVOID ( DDES_PABDATA ( Request ) ) ;
         int Size = int ( Request->cbData ) ;
         Parms->Topic->Poke ( Server, Client, Item, Format, Data, Size ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_ADVISE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Advise ( Server, Client, Item, ! ( Request->fsStatus & DDE_FNODATA ) ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_UNADVISE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Unadvise ( Server, Client, Item ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_EXECUTE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         int Format = int ( Request->usFormat ) ;
         PVOID Data = PVOID ( DDES_PABDATA ( Request ) ) ;
         int Size = int ( Request->cbData ) ;
         Parms->Topic->Execute ( Server, Client, Item, Format, Data, Size ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_TERMINATE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         Parms->Topic->Terminate ( Server, Parms->Client, TRUE ) ;
         return ( 0 ) ; }

   } /* endswitch */

   return ( WinDefWindowProc ( Server, Msg, mp1, mp2 ) ) ;
}
示例#17
0
 static void saveMouse(HWND hwnd, short x, short y)
 {
    ICQFRAME *cfg  = WinQueryWindowPtr(hwnd,0);
    cfg->xMouse = x;
    cfg->yMouse = y;
 }
BOOL CandyBarZFrameBorderPaintProc(HWND hwnd, RECTL * rect, HPS hpsFrame, short sState)
{
    CBZDATA     *pCBZData;
    CBZSHARE    *pCBZShare;
    PSPAINT     *pPaint;
    TEMPPAINT   *pFramePaint;
    BOOL        rc;
    int         i;
    ULONG       ulDataOffset;

    if (DosGetNamedSharedMem((PPVOID) & pCBZShare, CBZ_SHARE,  PAG_READ) != NO_ERROR)
    {
        return (FALSE);
    }
    ulDataOffset = pCBZShare->ulDataOffset;
    DosFreeMem(pCBZShare);

    // get window data
    if ((pCBZData = WinQueryWindowPtr(CandyBarZGetTopLevelFrameHWND(hwnd), ulDataOffset)) == NULL
            || !pCBZData->bFrameBorderEnabled  )
    {
        return (FALSE);
    }

    if (pCBZData->sFrameBorderIndex >= pCBZData->sPushButtonIndex)
    {
        return (FALSE);
    }

    // alloc paint struct
    if (DosAllocMem((PPVOID) & pFramePaint,
                    sizeof(TEMPPAINT),
                    PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
    {
        return (FALSE);
    }
    memset(pFramePaint, 0, sizeof(TEMPPAINT));

    pFramePaint->hab = WinQueryAnchorBlock(hwnd);

    // alloc paint struct
    if (DosAllocMem((PPVOID) & pPaint,
                    sizeof(PSPAINT),
                    PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
    {
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    memset(pPaint, 0, sizeof(PSPAINT));

    //Text plugin needs this for quering presentation parameters.
    pPaint->hwnd = hwnd;

    // entire window
    pPaint->rectlWindow = pPaint->rectlUpdate = *rect;

    // get PS
    pPaint->hpsWin = hpsFrame;

    // we will blt and draw gradient text into the hps associated with this dc
    if ((pFramePaint->hdc = DevOpenDC(pFramePaint->hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE))
            == NULLHANDLE)
    {
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    // create hps2 for hdc2.  hps for hdc depends on size of bitmap, so it's not created until
    // we know if it's active or not.  create for size of window, then we blt only portion
    // needed
    pFramePaint->slHPS.cx = pPaint->rectlWindow.xRight;
    pFramePaint->slHPS.cy = pPaint->rectlWindow.yTop;

    if ((pPaint->hps = GpiCreatePS(pFramePaint->hab,
                                   pFramePaint->hdc,
                                   &(pFramePaint->slHPS),
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC))
            == NULLHANDLE)
    {
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }

    pFramePaint->bif2.cbFix = sizeof(BITMAPINFOHEADER2);
    pFramePaint->bif2.cx = pPaint->rectlWindow.xRight;
    pFramePaint->bif2.cy = pPaint->rectlWindow.yTop;
    pFramePaint->bif2.cBitCount = 24;
    pFramePaint->bif2.cPlanes = 1;
    if ((pFramePaint->hbmTemp = GpiCreateBitmap(pPaint->hps,  // create bitmap
                                 (PBITMAPINFOHEADER2) & (pFramePaint->bif2),
                                                (ULONG) 0,
                                                (PSZ) NULL,
                       (PBITMAPINFO2) & (pFramePaint->bif2))) == NULLHANDLE)
    {
        GpiDestroyPS(pPaint->hps);
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    if (GpiSetBitmap(pPaint->hps, pFramePaint->hbmTemp) == HBM_ERROR)
    {
        GpiDeleteBitmap(pFramePaint->hbmTemp);
        GpiDestroyPS(pPaint->hps);
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }

    // set color table into rgb mode.  otherwise colors between 0 and
    // 15 are interpreted as indexes
    GpiCreateLogColorTable(pPaint->hps, 0, LCOLF_RGB, 0, 0, NULL);

    {
        //fill ps with default bg color...
        ULONG attrFound;
        long lColor;
        if ( (WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, &attrFound, sizeof(attrFound),
                                                &lColor, QPF_PURERGBCOLOR)) == 0 )
           lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
        // fill with default color
        WinFillRect(pPaint->hps, &(pPaint->rectlUpdate), lColor);
    }

    // call Plugins Paint Procedures here
    for (i = pCBZData->sFrameBorderIndex; i < pCBZData->sPushButtonIndex; i++)
    {
        if ( !(pCBZData->Plugins[i].pfnPluginRender(pPaint, pCBZData->Plugins[i].pData, sState)) )
        {
            GpiSetBitmap(pPaint->hps, NULLHANDLE);
            GpiDeleteBitmap(pFramePaint->hbmTemp);
            GpiDestroyPS(pPaint->hps);
            DevCloseDC(pFramePaint->hdc);
            DosFreeMem(pPaint);
            DosFreeMem(pFramePaint);
            return (FALSE);
        }
    }


    if ((rc = BltToWindow(pPaint)) == TRUE)
    {
        //paint sucessful, validate the window
//        WinQueryWindowRect(hwnd, &(pPaint->rectlUpdate));
        WinValidateRect(hwnd, &(pPaint->rectlUpdate), FALSE);
    }
    GpiSetBitmap(pPaint->hps, NULLHANDLE);
    GpiDeleteBitmap(pFramePaint->hbmTemp);
    GpiDestroyPS(pPaint->hps);
    DevCloseDC(pFramePaint->hdc);
    DosFreeMem(pPaint);
    DosFreeMem(pFramePaint);

    return (rc);
}
示例#19
0
 static void skinElement(HWND hwnd, HWND h, const char **vlr)
 {
    ICQFRAME *cfg    = WinQueryWindowPtr(hwnd,0);
    skinChild(h, cfg, vlr[0], vlr[1], vlr[2], (SKINFILESECTION *) vlr[3]);
 }
示例#20
0
//A Dlg procedure if the plugin has selectable settings.
MRESULT EXPENTRY CBZPluginSetupDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  short sControlId;
    PLUGINSHARE *pPluginData;
    FILEDLG filedlg;
    HWND hwndDlg;

    switch (msg)
    {
        case WM_INITDLG:
        {
            if ((pPluginData = (PLUGINSHARE *) mp2) == NULL)
            {
                //Error msg..
                WinDismissDlg(hwnd, DID_ERROR);
                return (MRFROMLONG(FALSE));
            }
            WinSetWindowPtr(hwnd, QWL_USER, pPluginData);  // store window words

            WinSendMsg(WinWindowFromID(hwnd, EFID_IMAGE), EM_SETTEXTLIMIT, (MPARAM) CCHMAXPATH, (MPARAM) 0);

            WinSetWindowText(WinWindowFromID(hwnd, EFID_IMAGE), pPluginData->szImageFile);

            /* This is temprary. At the moment only all or no frame control may be drawn */
            WinCheckButton(hwnd, CBID_CLOSEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_MINIMIZEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_MAXIMIZEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_RESTOREENABLED, TRUE);
            WinCheckButton(hwnd, CBID_HIDEENABLED, TRUE);

            WinEnableWindow(WinWindowFromID(hwnd,CBID_CLOSEENABLED ), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_MINIMIZEENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_MAXIMIZEENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_RESTOREENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_HIDEENABLED), FALSE);

        }
        break;

        case WM_COMMAND:
        {
            sControlId = COMMANDMSG(&msg)->cmd;

            switch (sControlId)
            {
                case PBID_IMAGE:
                {

                    //popup file change dialog!
                    memset(&filedlg, 0, sizeof(FILEDLG));  // init filedlg struct

                    filedlg.cbSize = sizeof(FILEDLG);
                    filedlg.fl = FDS_OPEN_DIALOG;
                    filedlg.pszTitle = "Choose an image";
                    strcpy(filedlg.szFullFile, "*.*");

                    if ((hwndDlg = WinFileDlg(HWND_DESKTOP, hwnd, &filedlg)) == NULLHANDLE)
                    {
                        return (FALSE);
                    }

                    if (filedlg.lReturn != DID_OK)  // selected one

                    {
                        break;
                    }

                    WinSetWindowText(WinWindowFromID(hwnd, EFID_IMAGE), filedlg.szFullFile);

                }
                break;


                case PBID_OK:
                {
                    if ((pPluginData = (PLUGINSHARE *) WinQueryWindowPtr(hwnd, QWL_USER)) == NULL)
                    {
                        //error message..
                        break;
                    }

                    WinQueryWindowText(WinWindowFromID(hwnd, EFID_IMAGE), CCHMAXPATH, pPluginData->szImageFile);

                    //update!
                    WinDismissDlg(hwnd, PBID_OK);
                }
                break;

                case PBID_CANCEL:
                {
                    //don't update shared Memory!
                    WinDismissDlg(hwnd, PBID_CANCEL);
                }
                break;
            }

            return ((MPARAM) 0);
        }
        break;

        case WM_CONTROL:
        {
            switch (SHORT1FROMMP(mp1))
            {

            }
            return ((MRESULT) 0);
        }
        break;

    }
    return (WinDefDlgProc(hwnd, msg, mp1, mp2));
}
示例#21
0
文件: hin.c 项目: komh/hanedit2
MRESULT hia_usermQuerySpecialCharKeyCheckProc( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);

    return MRFROMP( hia->isSpecialCharKey );
}
示例#22
0
MRESULT	EXPENTRY PrnSetupDlgProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR szPrinter[CCHMAXPATH];	   /* Printer Name Holder		*/
PPRN pprn;			   /* Printer List Pointer		*/
register INT i,	n;		   /* Loop Counters			*/

switch ( msg )
   {
   case	WM_INITDLG :
		       /* Save the pointer to user style information	*/
		       /* within the dialog's reserved memory           */

       WinSetWindowPtr(hWnd, QWL_USER, (PVOID)(pprn = (PPRN)mp2));

		       /* Go through the queue list and	add each of the	*/
		       /* queue	entries	to the list box	from which the	*/
		       /* user can select a printer to use and/or	*/
		       /* configure					*/

       for ( i = 0; i <	pprn->cQueues; i++ )
	   {
		       /* Insert item and store	index			*/

	   WinSendDlgItemMsg(hWnd, LB_PRINTERS,	LM_SETITEMHANDLE,
			     MPFROMSHORT(n = (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_INSERTITEM,
									       MPFROMSHORT(LIT_SORTASCENDING),
									       MPFROMP(strcat(strcat(strcpy(szPrinter,
										       pprn->pquei[i].pszName),	": "),
										       pprn->pquei[i].pszDriverName))))),
			     MPFROMP(i));

		       /* If the default printer, save the name	to set	*/
		       /* selection					*/

	   if (	i == pprn->iQueue )
	       WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_SELECTITEM, MPFROMSHORT(n), MPFROMSHORT(TRUE));
	   }
       CenterDlg(hWnd);
       break;
		       /* Process list box selections			*/
   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Printer entry	selected			*/

	   case	LN_SELECT :
	       WinEnableWindow(WinWindowFromID(hWnd, DID_SETUP), TRUE);
	       WinEnableWindow(WinWindowFromID(hWnd, DID_OK),	 TRUE);
	       break;
	   }
       break;

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	DID_OK :
		       /* Get selection	from the list box		*/

	       pprn = (PPRN)WinQueryWindowPtr(hWnd, QWL_USER);

		       /* Get printer handle				*/

	       pprn->iQueue = (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_PRINTERS, LM_QUERYITEMHANDLE,
								MPFROMLONG(WinSendDlgItemMsg(hWnd, LB_PRINTERS,
											     LM_QUERYSELECTION,
											     0L, 0L)),
								0L));
	       WinDismissDlg(hWnd, TRUE);
	       break;

	   case	DID_SETUP :

		       /* Get printer handle				*/

	       PrnQueryJobProperties((PPRN)WinQueryWindowPtr(hWnd, QWL_USER),
				     (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd,
								       LB_PRINTERS,
								       LM_QUERYITEMHANDLE,
								       MPFROMLONG(WinSendDlgItemMsg(hWnd,
												    LB_PRINTERS,
												    LM_QUERYSELECTION,
												    0L,	0L)),
								       0L)));
	       break;

	   case	DID_CANCEL :
	       WinDismissDlg(hWnd, FALSE);
	       break;
	   }
       break;
		       /* Close	received, exit dialog			*/
   case	WM_CLOSE :
       WinDismissDlg(hWnd, FALSE);
       break;

   default :
       return(WinDefDlgProc(hWnd, msg, mp1, mp2));
   }
		       /* Pass through unhandled messages		*/
return(0L);
}
示例#23
0
文件: kva.c 项目: fabsther/vlc-mort
static MRESULT EXPENTRY MyFrameWndProc( HWND hwnd, ULONG msg, MPARAM mp1,
                                        MPARAM mp2 )
{
    vout_display_t *vd = WinQueryWindowPtr( hwnd, 0 );
    vout_display_sys_t *sys = vd->sys;

    switch( msg )
    {
    case WM_QUERYTRACKINFO :
    {
        PTRACKINFO pti = ( PTRACKINFO )mp2;
        RECTL      rcl;

        sys->p_old_frame( hwnd, msg, mp1, mp2 );

        pti->rclBoundary.xLeft   = 0;
        pti->rclBoundary.yBottom = 0;
        pti->rclBoundary.xRight  = sys->i_screen_width;
        pti->rclBoundary.yTop    = sys->i_screen_height;

        WinCalcFrameRect( hwnd, &pti->rclBoundary, FALSE );

        pti->ptlMaxTrackSize.x = pti->rclBoundary.xRight -
                                 pti->rclBoundary.xLeft;
        pti->ptlMaxTrackSize.y = pti->rclBoundary.yTop -
                                 pti->rclBoundary.yBottom;

        rcl.xLeft   = 0;
        rcl.yBottom = 0;
        rcl.xRight  = sys->kvas.szlSrcSize.cx + 1;
        rcl.yTop    = sys->kvas.szlSrcSize.cy + 1;

        WinCalcFrameRect( hwnd, &rcl, FALSE );

        pti->ptlMinTrackSize.x = rcl.xRight - rcl.xLeft;
        pti->ptlMinTrackSize.y = rcl.yTop - rcl.yBottom;

        return MRFROMLONG( TRUE );
    }

    case WM_ADJUSTWINDOWPOS :
    {
        PSWP  pswp = ( PSWP )mp1;
        RECTL rcl;

        if( pswp->fl & SWP_SIZE )
        {
            rcl.xLeft   = pswp->x;
            rcl.yBottom = pswp->y;
            rcl.xRight  = rcl.xLeft + pswp->cx;
            rcl.yTop    = rcl.yBottom + pswp->cy;

            WinCalcFrameRect( hwnd, &rcl, TRUE );

            if( rcl.xRight - rcl.xLeft <= sys->kvas.szlSrcSize.cx )
                rcl.xRight = rcl.xLeft + ( sys->kvas.szlSrcSize.cx + 1 );

            if( rcl.yTop - rcl.yBottom <= sys->kvas.szlSrcSize.cy )
                rcl.yTop = rcl.yBottom + ( sys->kvas.szlSrcSize.cy + 1 );

            if( rcl.xRight - rcl.xLeft > sys->i_screen_width )
            {
                rcl.xLeft  = 0;
                rcl.xRight = sys->i_screen_width;
            }

            if( rcl.yTop - rcl.yBottom > sys->i_screen_height )
            {
                rcl.yBottom = 0;
                rcl.yTop    = sys->i_screen_height;
            }

            WinCalcFrameRect( hwnd, &rcl, FALSE );

            if( pswp->x != rcl.xLeft || pswp->y != rcl.yBottom )
                pswp->fl |= SWP_MOVE;

            pswp->x = rcl.xLeft;
            pswp->y = rcl.yBottom;

            pswp->cx = rcl.xRight - rcl.xLeft;
            pswp->cy = rcl.yTop - rcl.yBottom;
        }

        break;
    }
    }

    return sys->p_old_frame( hwnd, msg, mp1, mp2 );
}
示例#24
0
//A Dlg procedure if the plugin has selectable settings.
MRESULT EXPENTRY CBZPluginSetupDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    short sControlId;
    PLUGINSHARE *pPluginData;
    HOBJECT  hObject;

    switch (msg)
    {
        case WM_INITDLG:
        {
            short sInsertItem;/*to insert in ListBox*/
            CHAR	*szLineStyles [] =
                  {"dotted","short-dashed","dash-dot",
                  "double-dotted","long-dashed","dash-double-dot",
                  "solid","invisible","alternate pels" };

            if ((pPluginData = (PLUGINSHARE *) mp2) == NULL)
            {
                //Error message..
                WinDismissDlg(hwnd, DID_ERROR);
                return (MRFROMLONG(FALSE));
            }
            WinSetWindowPtr(hwnd, QWL_USER, pPluginData);  // store window words

            WinSetPresParam(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR),
                            PP_BACKGROUNDCOLOR,
                            (ULONG) sizeof(pPluginData->lActiveLineColor),
                            (PVOID) & (pPluginData->lActiveLineColor));
            WinSetPresParam(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR),
                            PP_BACKGROUNDCOLOR,
                            (ULONG) sizeof(pPluginData->lActiveShadowColor),
                            (PVOID) & (pPluginData->lActiveShadowColor));
            WinSetPresParam(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR),
                            PP_BACKGROUNDCOLOR,
                            (ULONG) sizeof(pPluginData->lInactiveLineColor),
                            (PVOID) & (pPluginData->lInactiveLineColor));
            WinSetPresParam(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR),
                            PP_BACKGROUNDCOLOR,
                          (ULONG) sizeof(pPluginData->lInactiveShadowColor),
                            (PVOID) & (pPluginData->lInactiveShadowColor));

            if (pPluginData->bActiveEnabled)
            {
                WinCheckButton(hwnd, CBID_ACTIVEENABLED, TRUE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR), TRUE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR), TRUE);
            }
            else
            {
                WinCheckButton(hwnd, CBID_ACTIVEENABLED, FALSE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR), FALSE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR), FALSE);
            }
            if (pPluginData->bInactiveEnabled)
            {
                WinCheckButton(hwnd, CBID_INACTIVEENABLED, TRUE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR), TRUE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR), TRUE);
            }
            else
            {
                WinCheckButton(hwnd, CBID_INACTIVEENABLED, FALSE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR), FALSE);
                WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR), FALSE);
            }
            /*there are 9 line styles*/
            for (sInsertItem=0; sInsertItem < 9; sInsertItem++)
            {
            WinSendDlgItemMsg (hwnd, LBID_LINESTYLE, LM_INSERTITEM, MPFROMSHORT (LIT_END), szLineStyles [sInsertItem]);
            }
            WinSendDlgItemMsg (hwnd, LBID_LINESTYLE, LM_SELECTITEM, MPFROMSHORT(pPluginData->lLineStyle-1), MPFROMSHORT(TRUE));

        }
        break;

        case WM_COMMAND:
        {
            sControlId = COMMANDMSG(&msg)->cmd;

            switch (sControlId)
            {
                case PBID_ACTIVELINECOLOR:
                case PBID_ACTIVESHADOWCOLOR:
                case PBID_INACTIVELINECOLOR:
                case PBID_INACTIVESHADOWCOLOR:
                {
                  // Open the colorpalette 
                  hObject=WinQueryObject("<WP_HIRESCLRPAL>");
                  if((hObject=WinQueryObject("<WP_HIRESCLRPAL>"))!=NULLHANDLE) {
                    WinOpenObject(hObject, OPEN_DEFAULT ,TRUE);
                  }
                  else {//Error, can't open the palette
                    /*  Show an error msg.						   */
                    WinMessageBox(HWND_DESKTOP,
                                  hwnd,         
                                  "Can't open color palette",          
                                  "Gradient plugin",                      
                                  12345,            /* Window ID */
                                  MB_OK |
                                  MB_MOVEABLE |
                                  MB_ICONEXCLAMATION |
                                  MB_DEFBUTTON1);                  /* Style     */
                  }
                  
                  /*    long lColor;
                        
                        if (sControlId == PBID_ACTIVELINECOLOR)
                        {
                        if (CBZGetColor(hwnd, &lColor))
                        {
                        WinSetPresParam(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR),
                        PP_BACKGROUNDCOLOR,
                        (ULONG) sizeof(lColor),
                        (PVOID) &lColor );
                        }
                        }
                        else if (sControlId == PBID_ACTIVESHADOWCOLOR)
                        {
                        if (CBZGetColor(hwnd, &lColor))
                        {
                        WinSetPresParam(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR),
                        PP_BACKGROUNDCOLOR,
                        (ULONG) sizeof(lColor),
                        (PVOID) &lColor );
                        }
                        }
                        else if (sControlId == PBID_INACTIVELINECOLOR)
                        {
                        if (CBZGetColor(hwnd, &lColor))
                        {
                        WinSetPresParam(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR),
                        PP_BACKGROUNDCOLOR,
                        (ULONG) sizeof(lColor),
                        (PVOID) &lColor );
                        }
                        }
                        else if (sControlId == PBID_INACTIVESHADOWCOLOR)
                        {
                        if (CBZGetColor(hwnd, &lColor))
                        {
                        WinSetPresParam(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR),
                        PP_BACKGROUNDCOLOR,
                        (ULONG) sizeof(lColor),
                        (PVOID) &lColor );
                        }
                        }*/
                }
                break;
                
                case PBID_OK:
                {
                    ULONG attrFound;

                    if ((pPluginData = (PLUGINSHARE *) WinQueryWindowPtr(hwnd, QWL_USER)) == NULL)
                    {
                        //error message here.
                        break;
                    }

                    WinQueryPresParam(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR),
                                        PP_BACKGROUNDCOLOR, 0,
                                        &attrFound, sizeof(attrFound),
                                        &(pPluginData->lActiveLineColor), QPF_PURERGBCOLOR);


                    WinQueryPresParam(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR),
                                        PP_BACKGROUNDCOLOR, 0,
                                        &attrFound, sizeof(attrFound),
                                        &(pPluginData->lActiveShadowColor), QPF_PURERGBCOLOR);

                    WinQueryPresParam(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR),
                                        PP_BACKGROUNDCOLOR, 0,
                                        &attrFound, sizeof(attrFound),
                                        &(pPluginData->lInactiveLineColor), QPF_PURERGBCOLOR);

                    WinQueryPresParam(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR),
                                        PP_BACKGROUNDCOLOR, 0,
                                        &attrFound, sizeof(attrFound),
                                        &(pPluginData->lInactiveShadowColor), QPF_PURERGBCOLOR);


                    if ( WinQueryButtonCheckstate(hwnd, CBID_ACTIVEENABLED) )
                        pPluginData->bActiveEnabled = TRUE;
                    else
                        pPluginData->bActiveEnabled = FALSE;

                    if ( WinQueryButtonCheckstate(hwnd, CBID_INACTIVEENABLED) )
                        pPluginData->bInactiveEnabled = TRUE;
                    else
                        pPluginData->bInactiveEnabled = FALSE;
                    
	                 pPluginData->lLineStyle = 1 + (LONG) WinSendDlgItemMsg (hwnd, LBID_LINESTYLE, LM_QUERYSELECTION, (MPARAM) 0, NULL);

                    //update!
                    WinDismissDlg(hwnd, PBID_OK);
                }
                break;

                case PBID_CANCEL:
                {
                    //don't update shared Memory!
                    WinDismissDlg(hwnd, PBID_CANCEL);
                }
                break;
            }
            return ((MPARAM) 0);
        }
        break;

        case WM_CONTROL:
        {
            switch (SHORT1FROMMP(mp1))
            {
                case CBID_ACTIVEENABLED:
                {
                    // if Enabled
                    if (!WinQueryButtonCheckstate(hwnd, CBID_ACTIVEENABLED))
                    {
                        // check button
                        WinCheckButton(hwnd, CBID_ACTIVEENABLED, TRUE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR), TRUE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR), TRUE);
                    }
                    else
                    {
                        // uncheck button
                        WinCheckButton(hwnd, CBID_ACTIVEENABLED, FALSE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVELINECOLOR), FALSE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_ACTIVESHADOWCOLOR), FALSE);
                    }
                }
                break;

                case CBID_INACTIVEENABLED:
                {
                    // if Enabled
                    if (!WinQueryButtonCheckstate(hwnd, CBID_INACTIVEENABLED))
                    {
                        // check button
                        WinCheckButton(hwnd, CBID_INACTIVEENABLED, TRUE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR), TRUE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR), TRUE);
                    }
                    else
                    {
                        // uncheck button
                        WinCheckButton(hwnd, CBID_INACTIVEENABLED, FALSE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVELINECOLOR), FALSE);
                        WinEnableWindow(WinWindowFromID(hwnd, PBID_INACTIVESHADOWCOLOR), FALSE);
                    }
                }
                break;
            }
            return ((MRESULT) 0);
        }
        break;

    }
    return (WinDefDlgProc(hwnd, msg, mp1, mp2));
}
示例#25
0
//************************************************************************************************
// The allmighty StartupThread
//************************************************************************************************
void _Optlink StartupThread(void *pArg)
{
   AnchorBlock    ab;
   MessageQueue   mq(ab);
   PINITDATA      pinit = (PINITDATA)pArg;
   int            i;
   USHORT         usDeviceIndex = 0;     // default use default deviceindex
   USHORT         usVolume = 75;         // default 75% volume
   ULONG          ulError = 0;           // mci error
   MCI_OPEN_PARMS mciOpenParms;
   BOOL           fDeviceOpen = FALSE;

   //*********************************************************************************************
   // Set the lowest posible priority to make us systemfriendly
   //*********************************************************************************************
   DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, PRTYD_MINIMUM, 0);


   //*********************************************************************************************
   // Clear some evetual garbage, just in case....
   //*********************************************************************************************
   WinSetWindowPtr(pinit->hWnd, QWP_PLAYLIST, NULL);
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, NULL);
   WinSetWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES, 0);
   WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, 0);
   WinSetWindowULong(pinit->hWnd, QWL_LOOP, 0);   // do not loop by default


   //*********************************************************************************************
   // Parse the commandline
   //*********************************************************************************************
   for(i = 1; i < pinit->argc; i++)
   {
      switch(pinit->argv[i][0])
      {
         case '/':
         case '-':
            switch(pinit->argv[i][1])
            {
               case 'i':
               case 'I':
                  usDeviceIndex = (USHORT)atoi(&pinit->argv[i][2]);
                  break;

               case 'l':
               case 'L':
                  WinSetWindowULong(pinit->hWnd, QWL_LOOP, 1);
                  break;

               case 'v':
               case 'V':
                  usVolume = (USHORT)atoi(&pinit->argv[i][2]);
                  break;
            }
            break;

         default:
            AddToPlaylist(pinit->hWnd, pinit->argv[i]);
            break;
      }
   }

   // make sure we're at the first entry of the playlist
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, WinQueryWindowPtr(pinit->hWnd, QWP_PLAYLIST));


   //*********************************************************************************************
   // open the waveaudio device
   //*********************************************************************************************
   memset((void*)&mciOpenParms, 0, sizeof(mciOpenParms));

   mciOpenParms.pszDeviceType = (PSZ)MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO, usDeviceIndex);
   ulError = mciSendCommand((USHORT)0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE_ID, (PVOID)&mciOpenParms, 0);

   if(LOUSHORT(ulError) == MCIERR_SUCCESS)
   {
      fDeviceOpen = TRUE;
      WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, mciOpenParms.usDeviceID);
   }

   if((fDeviceOpen == TRUE) && (WinQueryWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES) != 0))
   {
      MCI_SET_PARMS        msp;

      msp.ulLevel = usVolume;
      msp.ulAudio = MCI_SET_AUDIO_ALL;
      ulError = mciSendCommand(mciOpenParms.usDeviceID, MCI_SET, MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME, (PVOID)&msp, 0);

      if(LOUSHORT(ulError) == MCIERR_SUCCESS)
      {
         WinSendMsg(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMSHORT(usVolume));
         WinEnableWindow(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), TRUE);
      }

      if((BOOL)WinSendMsg(pinit->hWnd, WMU_LOAD, NULL, NULL))
      {
         WinSendMsg(pinit->hWnd, WMU_PLAY, NULL, NULL);
      }
   }


   //*********************************************************************************************
   // free the initdata buffer
   //*********************************************************************************************
   delete pinit;

   // show the window
   SWP   swp;
   ULONG pulBufferMax = sizeof(swp);
   if(PrfQueryProfileData(HINI_USERPROFILE, "WavePlayer", "WindowPosition", (PVOID)&swp, &pulBufferMax))
      WinSetWindowPos(WinQueryWindow(pinit->hWnd, QW_PARENT), HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_SHOW | SWP_MOVE | SWP_SIZE);
   else
      WinShowWindow(WinQueryWindow(pinit->hWnd, QW_PARENT), TRUE);

   // bye, bye!
   _endthread();
}
示例#26
0
 static void close(HWND hwnd)
 {
    HWND             frame = WinQueryWindow(hwnd,QW_PARENT);
    ICQFRAME         *cfg  = WinQueryWindowPtr(hwnd,0);
    SKINDATA         *skn;
    ICQMSGDIALOG     *msg  = NULL;
    ICQCONFIGDIALOG  *cgw  = NULL;

//    if(!cfg || cfg->sz != sizeof(ICQFRAME) || !cfg->icq)

    if(!(cfg && cfg->sz >= sizeof(ICQFRAME) && cfg->icq) )
    {
       DBGTracex(cfg);
       DBGTrace(cfg->sz);
       DBGTracex(cfg->icq);

       DBGMessage("***** ERROR CLOSING FRAME WINDOW *****");

       WinPostMsg(hwnd,WM_QUIT,0,0);
       return;
    }

    DBGMessage(cfg->name);
    if(*cfg->name)
       icqStoreWindow(frame, cfg->icq, 0, cfg->name);

    skn = icqskin_getDataBlock(cfg->icq);

    if(hwnd == skn->mainWindow)
    {
       if(skn->TrayServer)
          WinPostMsg(skn->TrayServer,WM_TRAYDELME,(MPARAM) skn->mainWindow,0);

       DBGMessage("Closing configuration windows");

       while(skn->firstCfgWin && skn->firstCfgWin != cgw)
       {
          cgw = skn->firstCfgWin;
          WinSendMsg(cgw->hwnd,WM_CLOSE,0,0);
       }
       DBGTracex(skn->firstCfgWin);

       DBGMessage("Closing message Windows");

       while(skn->firstMsgWin && skn->firstMsgWin != msg)
       {
          msg = skn->firstMsgWin;
          WinSendMsg(msg->hwnd,WM_CLOSE,0,0);
       }
       DBGTracex(skn->firstMsgWin);

       DBGMessage("Closing main Window");

       WinPostMsg(hwnd,WM_QUIT,0,0);
       return;
    }

    DBGMessage("Closing child window");

    WinDestroyWindow(frame);

 }
示例#27
0
MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    if (msg == WM_CREATE) {
        WinSetWindowPtr(hwnd, QWL_USER, PVOIDFROMMP(mp1));
    } else {
        ToolBarData *td = (ToolBarData *)WinQueryWindowPtr(hwnd, QWL_USER);
        ToolBarItem *items = td->pItems;

        switch (msg) {
        case WM_DESTROY:
            free(td);
            free(items);
            break;

        case WM_PAINT:
        {
            HPS hps;
            RECTL rcl;
            POINTL ptl;
            SWP swp;
            int xpos, ypos, item;

            WinQueryWindowPos(hwnd, &swp);

            hps = WinBeginPaint(hwnd, 0, &rcl);

            /* top outside 3D border */
            if (rcl.yBottom < 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.x = rcl.xLeft;
                ptl.y = 0;
                GpiMove(hps, &ptl);
                ptl.x = Min(rcl.xRight, swp.cx - 2);
                GpiLine(hps, &ptl);
            }

            /* bottom outside 3D border */
            if (rcl.yTop >= swp.cy - 1 - 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.x = Max(rcl.xLeft, 1);
                ptl.y = swp.cy - 1;
                GpiMove(hps, &ptl);
                ptl.x = rcl.xRight;
                GpiLine(hps, &ptl);
            }

            /* 3D corners */
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = 0;
            ptl.y = 0;
            GpiSetPel(hps, &ptl);
            ptl.x = swp.cx - 1;
            ptl.y = swp.cy - 1;
            GpiSetPel(hps, &ptl);

            /* bottom space */
            if (rcl.yBottom < TYBORDER - 1) {
                for (ptl.y = 1; ptl.y < TYBORDER - 2; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* top space */
            if (rcl.yTop >= swp.cy - TYBORDER + 2) {
                for (ptl.y = swp.cy - TYBORDER + 2; ptl.y < swp.cy - 1; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* left outside 3D border */
            if (rcl.xLeft < 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.y = Max(1, rcl.yBottom);
                ptl.x = 0;
                GpiMove(hps, &ptl);
                ptl.y = rcl.yTop;
                GpiLine(hps, &ptl);
            }

            /* right outside 3D border */
            if (rcl.xRight >= swp.cx - 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.y = rcl.yBottom;
                ptl.x = swp.cx - 1;
                GpiMove(hps, &ptl);
                ptl.y = Min(swp.cy - 2, rcl.yTop);
                GpiLine(hps, &ptl);
            }

            /* left border */
            if (rcl.xLeft < TXBORDER - 2) {
                GpiSetColor(hps, CLR_PALEGRAY);
                for (ptl.x = 1; ptl.x < TXBORDER - 2; ptl.x++) {
                    ptl.y = Max(1, rcl.yBottom);
                    GpiMove(hps, &ptl);
                    ptl.y = Min(swp.cy - 2, rcl.yTop);
                    GpiLine(hps, &ptl);
                }
            }

            /* draw toolbar items */
            xpos = TXBORDER;
            ypos = TYBORDER;

            for (item = 0; item < td->ulCount; item++) {
                if (items[item].ulType == tiBITMAP) {
                    if (rcl.xRight >= xpos - 2 && rcl.xLeft <= xpos + TXICON + 1) {
                        GpiSetColor(hps, CLR_BLACK);
                        ptl.x = xpos - 2;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXICON + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
                        if (item == td->ulDepressed && (items[item].ulFlags & tfDEPRESSED)) {
                            ptl.x = xpos + 1;
                            ptl.y = ypos - 1;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_DARKGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON;
                            GpiLine(hps, &ptl);
                            ptl.y--;
                            GpiMove(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                        } else {
                            ptl.x = xpos;
                            ptl.y = ypos;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiSetPel(hps, &ptl);
                            GpiSetColor(hps, CLR_WHITE);
                            ptl.y++;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON - 1;
                            GpiLine(hps, &ptl);
                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x++;
                            GpiSetPel(hps, &ptl);
                            ptl.y--;
                            GpiSetColor(hps, CLR_DARKGRAY);
                            GpiMove(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                        }
                    }
                    xpos += TXICON + 3;
                } else if (items[item].ulType == tiSEPARATOR) {
                    if (rcl.xRight >= xpos - 1 && rcl.xLeft <= xpos + TXSEPARATOR + 1) {
                        GpiSetColor(hps, CLR_PALEGRAY);
                        ptl.x = xpos - 1;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXSEPARATOR + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_FILL, &ptl, 0, 0);
                    }
                    xpos += TXSEPARATOR + 3;
                }
            }
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = xpos - 1;
            ptl.y = ypos - 2;
            GpiMove(hps, &ptl);
            ptl.x = swp.cx - 2;
            ptl.y = swp.cy - TYBORDER + 1;
            GpiBox(hps, DRO_FILL, &ptl, 0, 0);

            WinEndPaint(hps);
        }
        break;

        case WM_ADJUSTWINDOWPOS:
        {
            PSWP pswp = (PSWP)PVOIDFROMMP(mp1);
            pswp->cy = TYBORDER + TYICON + TYBORDER;
        }
        break;

        case WM_BUTTON1DOWN:
        case WM_BUTTON1DBLCLK:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                        rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                        td->pItems[item].ulType == tiBITMAP &&
                        (td->pItems[item].ulFlags & tfDISABLED) == 0)
                {
                    td->ulDepressed = item;
                    td->pItems[item].ulFlags |= tfDEPRESSED;
                    WinInvalidateRect(hwnd, &rcl, FALSE);
                    WinSetCapture(HWND_DESKTOP, hwnd);
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_MOUSEMOVE:
        {
            STARTFUNC("ToolBarProc[WM_MOUSEMOVE]");
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            LOG << "Depressed: " << td-> ulDepressed << ENDLINE;
            for (item = 0; item < td->ulCount; item++) {
                LOG << "Checking item " << item << ENDLINE;
                LOG << "  pItem -> " << (void*)(td->pItems + item) << ENDLINE;
                if (item == td->ulDepressed) {
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y)
                    {
                        if ((td->pItems[item].ulFlags & tfDEPRESSED) == 0) {
                            td->pItems[item].ulFlags |= tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    } else {
                        if (td->pItems[item].ulFlags & tfDEPRESSED) {
                            td->pItems[item].ulFlags &= ~tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    }
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_BUTTON1UP:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (item == td->ulDepressed) {
                    WinSetCapture(HWND_DESKTOP, (HWND)0);
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                            td->pItems[item].ulFlags & tfDEPRESSED)
                    {
                        td->pItems[item].ulFlags &= ~tfDEPRESSED;
                        WinInvalidateRect(hwnd, &rcl, FALSE);

                        // message
                        WinPostMsg(WinQueryWindow(hwnd, QW_OWNER), WM_COMMAND, MPFROM2SHORT(td->pItems[item].ulCommand, 0), MPFROM2SHORT(CMDSRC_OTHER, TRUE));

                        break;
                    }
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
            td->ulDepressed = -1;
        }
        break;
        }
    }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
示例#28
0
 static MRESULT beginDrag(HWND hwnd, POINTS *p)
 {
    ICQFRAME *cfg = WinQueryWindowPtr(hwnd,0);
    RECTL    rcl;
    POINTL   ptl  = { p->x, p->y };

    CHKPoint();
    DBGTrace(p->x);
    DBGTrace(p->y);

    cfg->xPos =
    cfg->yPos = 0xFFFF;

    WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1);

    WinQueryWindowRect(hwnd, &rcl);
    rcl.xRight -= rcl.xLeft;
    rcl.yTop   -= rcl.yBottom;

    DBGTrace(rcl.xRight);
    DBGTrace(rcl.yTop);

    if(p->y > (rcl.yTop - TOP_MARGIN) && (p->x < (rcl.xRight - RIGHT_MARGIN)) && (p->x > LEFT_MARGIN) )
    {
       DBGMessage("Drag window");
       cfg->yPos   = ptl.y;
       cfg->xPos   = ptl.x;
       cfg->flags |= ICQFRAME_FLAG_MOVEX|ICQFRAME_FLAG_MOVEY;
    }
    else
    {
       if(p->x < LEFT_MARGIN)
       {
          cfg->xPos   = ptl.x;
          cfg->flags |= ICQFRAME_FLAG_SETCX|ICQFRAME_FLAG_MOVEX;
          CHKPoint();
       }

       if(p->x > (rcl.xRight - RIGHT_MARGIN))
       {
          CHKPoint();
          cfg->xPos   = ptl.x;
          cfg->flags |= ICQFRAME_FLAG_SETCX;
       }

       if(p->y < BOTTOM_MARGIN)
       {
          CHKPoint();
          cfg->yPos   = ptl.y;
          cfg->flags |= ICQFRAME_FLAG_SETCY|ICQFRAME_FLAG_MOVEY;
       }

       if(p->y > (rcl.yTop - TOP_MARGIN))
       {
          CHKPoint();
          cfg->yPos   = ptl.y;
          cfg->flags |= ICQFRAME_FLAG_SETCY;
       }
    }

    DBGTracex(cfg->xPos);
    DBGTracex(cfg->yPos);

    if(cfg->xPos != 0xFFFF || cfg->yPos != 0xFFFF)
    {
       DBGTrace(cfg->xPos)
       DBGTrace(cfg->yPos);
       WinSetCapture(HWND_DESKTOP, hwnd);
       cfg->timer = WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 50);

       DBGTracex(cfg->timer);

       if(!cfg->timer)
       {
          DBGMessage("Error starting timer");
          icqWriteSysLog(cfg->icq,PROJECT,"Failure starting size timer");
       }
    }

    return (MRESULT) TRUE;
 }
示例#29
0
static MRESULT EXPENTRY PSListProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   PPRINTSETUP pPrintSetup = WinQueryWindowPtr(hwnd, QWL_USER);
   HWND hwndListbox;
   int i, index;
   char *psz;
   PPRQINFO3 pqi;

   switch(msg)
   {
      case WM_INITDLG:
         pPrintSetup = (PPRINTSETUP) mp2;
         WinSetWindowPtr(hwnd, QWL_USER, pPrintSetup);

         // fill listbox with print queues
         hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );

         for( i = 0; i < pPrintSetup->cQueues; i++ )
         {
           // Display printer comment if possible, else use queue name for display.
           psz = *pPrintSetup->pQueueInfo[i].pszComment ? pPrintSetup->pQueueInfo[i].pszComment : pPrintSetup->pQueueInfo[i].pszName;

           index = (LONG) WinSendMsg( hwndListbox, LM_INSERTITEM, (MPARAM)LIT_END, (MPARAM)psz );

           if( 0 == strcmp( pPrintSetup->pQueueInfo[i].pszName, pPrintSetup->szPreferredQueue ))
           {
             // Hilight preferred queue.
             WinSendMsg( hwndListbox, LM_SELECTITEM, (MPARAM)index, (MPARAM)TRUE );
           }
         }
         if (pPrintSetup->cQueues)
            WinEnableControl(hwnd, IDD_PS_LIST+3, TRUE);
         break;

      case WM_COMMAND:
         switch(SHORT1FROMMP(mp1))
         {
            case IDD_PS_LIST+3:
               hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );
               ConfigurePrinter(hwndListbox, pPrintSetup);
               return (MRESULT) FALSE;

            default:
               return (MRESULT) FALSE;
         }

      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == IDD_PS_LIST+2 &&
             SHORT2FROMMP(mp1) == LN_ENTER)
            ConfigurePrinter((HWND) mp2, pPrintSetup);
         break;

      case WM_DESTROY:
         hwndListbox = WinWindowFromID( hwnd, IDD_PS_LIST+2 );

         index = (LONG) WinSendMsg( hwndListbox, LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0 );
         if (index != LIT_NONE)
         {
            pqi = &pPrintSetup->pQueueInfo[ index ];

            if (pPrintSetup->pDriverData)
               free(pPrintSetup->pDriverData);
            pPrintSetup->pDriverData = malloc(pqi->pDriverData->cb);
            memcpy(pPrintSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb);

            // New preferred queue. Modify the one in the PRINTERSETUP structure.
            strcpy( pPrintSetup->szPreferredQueue, pqi->pszName );
            pPrintSetup->bDirty = TRUE;
         }
         break;

      default:
         break;
   }
   return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
/*
 *
 *  BrowseWndProc
 *
 *  DESCRIPTION:
 *
 *    Processes messages for the Browse-O-Matic client window.
 *
 */
MRESULT EXPENTRY BrowseWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch( msg){

      case WM_CREATE:
         {
            CHAR          pszTitle[ MAX_TITLE_LENGTH];
            PBROWSEDATA   pWindowData;

            pWindowData = (PBROWSEDATA)mp1;
            WinSetWindowPtr( hwnd, QWL_USER, pWindowData);

            /*******************/
            /* Load the object */
            /*******************/
            _LoadObject( pWindowData->somSelf,
                        pWindowData->pszObjectName, &pWindowData->ulFileLength,
                                   &pWindowData->pBuffer, &pWindowData->pLines,
                                             &pWindowData->usNumberOfTextLines,
                                          &pWindowData->usNumberOfTextColumns);

            _GetLinesAndColumns( pWindowData->somSelf, pWindowData->bDisplay,
                        &pWindowData->sTotalLines, &pWindowData->sTotalColumns,
                                             pWindowData->usNumberOfTextLines,
                                            pWindowData->usNumberOfTextColumns,
                                                    pWindowData->ulFileLength);

            /*********************************************/
            /* Get the window handle for the scroll bars */
            /*********************************************/
            pWindowData->hwndVscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_VERTSCROLL);
            pWindowData->hwndHscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_HORZSCROLL);

            /*************************/
            /* Save font information */
            /*************************/
            WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);

            /*****************/
            /* Get the focus */
            /*****************/
            WinSetFocus( HWND_DESKTOP, hwnd);

            /*****************************************************/
            /* Create the title for the Browse-O-Matic title bar */
            /*****************************************************/
            if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
               sprintf( pszTitle, "Object: %s    (%d Bytes)",
                        pWindowData->pszObjectName, pWindowData->ulFileLength);
            else
               sprintf( pszTitle, "Object: %s    (%hd Lines)",
                         pWindowData->pszObjectName, pWindowData->sTotalLines);

            /************************************************/
            /* Register the current open view of the object */
            /************************************************/
            _wpAddToObjUseList( pWindowData->somSelf, &(pWindowData->UseItem));
            _wpRegisterView( pWindowData->somSelf, WinQueryWindow( hwnd,
                                                         QW_PARENT), pszTitle);
         }
         break;

      case WM_CLOSE:
         {
            HWND        hwndFrame;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
            hwndFrame = WinQueryWindow( hwnd, QW_PARENT);

            /*****************************************************/
            /* Save the window info - size, location, and fonts. */
            /*****************************************************/
            WinStoreWindowPos( APPL_NAME, pWindowData->pszApplKey, hwndFrame);

            /**********************************************************/
            /* Free the window data and unload the file system object */
            /**********************************************************/
            if( pWindowData){
               if( pWindowData->pszObjectName)
                  _wpFreeMem( pWindowData->somSelf,
                                           ( PBYTE)pWindowData->pszObjectName);
               _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData);
            }

            _UnloadObject( pWindowData->somSelf, pWindowData->pBuffer,
                                                          pWindowData->pLines);

            _wpDeleteFromObjUseList( pWindowData->somSelf,
                                                        &pWindowData->UseItem);
            /*******************/
            /* Kill the window */
            /*******************/
            WinPostMsg( hwnd, WM_QUIT, 0, 0 );
            WinDestroyWindow( hwndFrame);
         }
         break;

      /*******************************************************************/
      /* The font characteristics have changed. This happens when a font */
      /* from the font palette is dropped on the client window.          */
      /*******************************************************************/
      case WM_PRESPARAMCHANGED:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            if( (ULONG)mp1 == PP_FONTNAMESIZE){

               /***********************************************/
               /* Get the new font information and redraw the */
               /* window with the new font/font size.         */
               /***********************************************/
               WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);
               WinSendMsg( hwnd, WM_SIZE, 0, MPFROM2SHORT(
                       pWindowData->sClientWidth, pWindowData->sClientHeight));
            }
         }
         break;

      case WM_SIZE:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            /***************************************/
            /* Save client window size information */
            /***************************************/
            pWindowData->sClientWidth = SHORT1FROMMP( mp2);
            pWindowData->sClientHeight = SHORT2FROMMP( mp2);
            pWindowData->sPageHeight = pWindowData->sClientHeight/
                                                      pWindowData->sCharHeight;
            pWindowData->sPageWidth = pWindowData->sClientWidth  /
                                                       pWindowData->sCharWidth;

            /**************************************/
            /* Set the ranges for the scroll bars */
            /**************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETSCROLLBAR,
                         (MPARAM)pWindowData->sCurrentLine, MPFROM2SHORT( 0,
                         pWindowData->sTotalLines - pWindowData->sPageHeight));
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETSCROLLBAR,
                        (MPARAM)pWindowData->sCurrentColumn, MPFROM2SHORT( 0,
                        pWindowData->sTotalColumns - pWindowData->sPageWidth));

            /*************************************/
            /* Set scroll bar thumb control size */
            /*************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETTHUMBSIZE,
                                        MPFROM2SHORT( pWindowData->sPageHeight,
                                        pWindowData->sTotalLines), (MPARAM) 0);
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETTHUMBSIZE,
                                      MPFROM2SHORT( pWindowData->sPageWidth,
                                      pWindowData->sTotalColumns), (MPARAM) 0);

            /************************************************************/
            /* If the all the lines and/or columns can fit in the new   */
            /* sized window, set the sCurrentLine and/or sCurrentColumn */
            /* to the top/right side.                                   */
            /************************************************************/
            if( pWindowData->sPageHeight >= pWindowData->sTotalLines)
               pWindowData->sCurrentLine = 0;

            if( pWindowData->sPageWidth >= pWindowData->sTotalColumns)
               pWindowData->sCurrentColumn = 0;

            /********************************************/
            /* Repaint window with new size information */
            /********************************************/
            WinInvalidateRect( hwnd, NULL, FALSE);
         }
         return( 0);

      case WM_PAINT:
         {
            HPS         hps;
            CHAR        pszText[255];
            UINT        nLength = 0;
            RECTL       rect;
            POINTL      point;
            SHORT       sLine;
            SHORT       sTopLine;
            SHORT       sBottomLine;
            SHORT       sLinesFromTop;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinBeginPaint( hwnd, NULLHANDLE, &rect);

            /*******************************************/
            /* Clear the area that needs to be redrawn */
            /*******************************************/
            GpiErase( hps);

            /********************************/
            /* Determine first clipped line */
            /********************************/
            sLinesFromTop = ( pWindowData->sClientHeight - rect.yTop) /
                                                      pWindowData->sCharHeight;
            rect.yTop = pWindowData->sClientHeight -
                                   ( pWindowData->sCharHeight * sLinesFromTop);

            /***************************************************************/
            /* Determine the first position to write at. NOTE: PM handles  */
            /* clipping for point.x < 0. Any characters written before the */
            /* the first column or after the last column are clipped.      */
            /***************************************************************/
            point.y = rect.yTop - pWindowData->sCharHeight +
                                                   pWindowData->sCharDescender;
            point.x = pWindowData->sCurrentColumn*pWindowData->sCharWidth * -1;

            /***********************************************/
            /* Determine the top and bottom lines to write */
            /***********************************************/
            sTopLine    = rect.yTop    / pWindowData->sCharHeight;
            sBottomLine = rect.yBottom / pWindowData->sCharHeight;

            /*********************************************************/
            /* Make sure that we aren't trying to display more lines */
            /* then are available.                                   */
            /*********************************************************/
            if( pWindowData->sPageHeight - sBottomLine + 1 >
                          pWindowData->sTotalLines - pWindowData->sCurrentLine)
               sBottomLine=pWindowData->sPageHeight-(pWindowData->sTotalLines -
                                                pWindowData->sCurrentLine) + 1;

            /********************************/
            /* Redraw the invalid rectangle */
            /********************************/
            for( sLine = sTopLine; sLine >= sBottomLine; sLine--){

               /*******************************************/
               /* Get the line of text or hex information */
               /* that we are going to write.             */
               /*******************************************/
               if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
                  nLength = _GetHexLine( pWindowData->somSelf,
                     pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                           +1, pWindowData->pBuffer, pWindowData->ulFileLength,
                                                                      pszText);
               else
                  nLength = _GetTextLine( pWindowData->somSelf,
                       pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                                             +1, pWindowData->pLines, pszText);

               /******************/
               /* Write the text */
               /******************/
               if( nLength != 0)
                  GpiCharStringAt( hps, &point, nLength, pszText);

               point.y -= pWindowData->sCharHeight;
            }

            WinEndPaint( hps);
         }
         return( 0);

      /*******************************************/
      /* Keyboard support for scrolling and help */
      /*******************************************/
      case WM_CHAR:

         /****************************************/
         /* Show general help if user selects F1 */
         /****************************************/
         if( CHARMSG( &msg)->vkey == VK_F1){
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
            _wpDisplayHelp( pWindowData->somSelf, PANEL_MAIN,
                            "browse.hlp");
            return 0;
         }

         if( (CHARMSG( &msg)->fs & KC_KEYUP))
            return 0;

         switch( CHARMSG( &msg)->vkey){

            case VK_UP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEUP));
               return 0;

            case VK_DOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEDOWN));
               return 0;

            case VK_RIGHT:
               /************************************************************/
               /* Ctrl-Right scrolls one page to the right. Right scrolls  */
               /* to the right.                                            */
               /************************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_PAGERIGHT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_LINERIGHT));
               return 0;

            case VK_LEFT:
               /*********************************************************/
               /* Ctrl-Left scrolls one page to the left. Left scrolls  */
               /* to the Left.                                          */
               /*********************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_PAGELEFT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_LINELEFT));
               return 0;

            case VK_PAGEUP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEUP));
               return 0;

            case VK_PAGEDOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEDOWN));
               return 0;

            case VK_HOME:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-Home positions at the first line, Home positions */
                  /* at the beginning of the current line.                 */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  return 0;
               }

            case VK_END:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-End positions at the last line, End positions at */
                  /* the end of the current line.                          */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT(
                           pWindowData->sTotalLines - pWindowData->sPageHeight,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                      MPFROMSHORT( pWindowData->sTotalLines -
                                                 pWindowData->sPageHeight), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT(
                          pWindowData->sTotalColumns - pWindowData->sPageWidth,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                      MPFROMSHORT( pWindowData->sTotalColumns -
                                                  pWindowData->sPageWidth), 0);
                  }
                  return 0;
               }
         }
         break;

      /******************/
      /* Scroll Up/Down */
      /******************/
      case WM_VSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine--;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight * -1,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine++;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine = max( 0,
                         pWindowData->sCurrentLine - pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine= min( pWindowData->sTotalLines -
                          pWindowData->sPageHeight, pWindowData->sCurrentLine +
                                                     pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current line if all the text fits in the   */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalLines > pWindowData->sPageHeight){
                     pWindowData->sCurrentLine = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;


      /*********************/
      /* Scroll Right/Left */
      /*********************/
      case WM_HSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                                              pWindowData->sCurrentColumn - 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                        (MPARAM)pWindowData->sCurrentColumn,0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth, 0, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns,
                                              pWindowData->sCurrentColumn + 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth * -1, 0,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                        pWindowData->sCurrentColumn - pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns
                       - pWindowData->sPageWidth, pWindowData->sCurrentColumn +
                                                      pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current column if all the text fits in the */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalColumns > pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;

      /*****************************/
      /* Get font size information */
      /*****************************/
      case IDL_SETFONTINFO:
         {
            HPS         hps;
            FONTMETRICS fm;
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinGetPS( hwnd);
            GpiQueryFontMetrics( hps, sizeof( fm), &fm);
            WinReleasePS( hps);

            /***********************************************************/
            /* The character width is average of the average uppercase */
            /* and average lower case widths.                          */
            /***********************************************************/
            pWindowData->sCharWidth     = (SHORT)fm.lMaxCharInc;
            pWindowData->sCharHeight    = (SHORT)fm.lMaxBaselineExt;
            pWindowData->sCharDescender = (SHORT)fm.lMaxDescender;
         }
         return( 0);

      /*********************************************/
      /* Display no help available message to user */
      /*********************************************/
      case HM_HELPSUBITEM_NOT_FOUND:
         return( ( MRESULT)FALSE);

      /**************************************/
      /* Return name of help for keys panel */
      /**************************************/
      case HM_QUERY_KEYS_HELP:
         return( ( MRESULT)PANEL_HELPKEYS);
   }

   /********************************************************/
   /* Let the default window procedure process the message */
   /********************************************************/
   return( WinDefWindowProc( hwnd, msg, mp1, mp2));
}