Annotation of pmsdk/samples/newcard/pmbind.h, revision 1.1.1.1

1.1       root        1: #define  INCL_DOS
                      2: #define  INCL_WIN
                      3: #define  INCL_GPI
                      4: #include "os2.h"
                      5: #include "pmbind1.h"
                      6: 
                      7: 
                      8: /*********************************************************************/
                      9: /*  Windows/PM Cardfile Shared Code                                  */
                     10: /*                                                                   */
                     11: /*  (c) Copyright Microsoft Corp. 1987,1988 - All Rights Reserved    */
                     12: /*********************************************************************/
                     13: 
                     14: 
                     15: /*********************************************************************/
                     16: /* Internal variables used by binding system.                        */
                     17: /*********************************************************************/
                     18: 
                     19: extern HAB     hAB;              /* Holds the anchor block handle */
                     20: extern HMQ     hMQ;              /* Holds the message queue handle */
                     21: extern int     temp;             /* Temp Var, used for many mappings */
                     22: extern POINTL  Point;            /* Temp Var, used for many mappings */
                     23: extern WPOINT  pt;               /* Temp Var, used for many mappings */
                     24: extern HHEAP   hLocalHeap;       /* Holds the cardfile's local heap */
                     25: extern int     WinHeight;        /* Holds the current translate value */
                     26: extern int     b_CharHeight;     /* Character height, default is 0 */
                     27: extern WRECT   TempRect;         /* Temp Var, used for many mappings */
                     28: extern PWRECT  lTempRect;        /* Temp Var, used for many mappings */
                     29: extern HWND    hwndTemp;         /* Temp Var, used for many mappings */
                     30: extern POINTL  PointArray[];     /* Temp Var, used for many mappings */
                     31: 
                     32: 
                     33: 
                     34: /*********************************************************************/
                     35: /* Internal functions called by binding system.                      */
                     36: /*********************************************************************/
                     37: 
                     38: int   FAR PASCAL  lstrlen( PSZ );
                     39: PSZ   FAR PASCAL  lstrcpy( PSZ, PSZ );
                     40: PSZ   FAR PASCAL  lstrcat( PSZ, PSZ );
                     41: PSZ   FAR PASCAL  lmemcpy( PSZ, PSZ, unsigned );
                     42: int   CheckScrollBars( HWND, unsigned, int );
                     43: 
                     44: 
                     45: /*********************************************************************/
                     46: /* Internal defines accessed only in binding system                  */
                     47: /*********************************************************************/
                     48: 
                     49: /* These resolve type conflicts with the MPARAM type */
                     50: 
                     51: #define  NewSendMsg( a, b, c, d )   \
                     52:             LONGFROMMR( WinSendMsg( a, b, MPFROMLONG(c), MPFROMLONG(d) ))
                     53: 
                     54: #define  NewSendDlgItemMsg( a, b, c, d, e ) \
                     55:             LONGFROMMR(WinSendDlgItemMsg( a, b, c, \
                     56:                                           MPFROMLONG(d), MPFROMLONG(e) ))
                     57: 
                     58: #define  NewDefWindowProc( a, b, c, d )   \
                     59:       LONGFROMMR( WinDefWindowProc( a, b, MPFROMLONG(c), MPFROMLONG(d) ))
                     60: 
                     61: 
                     62: /*********************************************************************/
                     63: /* Exeternal functions available to the application                  */
                     64: /*********************************************************************/
                     65: 
                     66: int      DlgDirList( HWND, PSZ, unsigned, unsigned, unsigned );
                     67: unsigned DlgDirSelect( HWND, PSZ, unsigned );
                     68: int      OpenFile( PSZ, LPOFSTRUCT, WORD );
                     69: 
                     70: 
                     71: /********************************************************************/
                     72: /* Various symbol defines                                           */
                     73: /********************************************************************/
                     74: 
                     75: 
                     76: /* Message box id's */
                     77: 
                     78: #define  IDOK              MBID_OK
                     79: #define  IDCANCEL          MBID_CANCEL
                     80: #define  IDABORT           MBID_ABORT
                     81: #define  IDRETRY           MBID_RETRY
                     82: #define  IDIGNORE          MBID_IGNORE
                     83: #define  IDYES             MBID_YES
                     84: #define  IDNO              MBID_NO
                     85: 
                     86: /* Scroll bar notification messages */
                     87: 
                     88: #define  SB_THUMBTRACK     SB_SLIDERTRACK
                     89: #define  SB_THUMBPOSITION  SB_SLIDERPOSITION
                     90: 
                     91: 
                     92: /* Window styles (CreateWindow mapping)       */
                     93: 
                     94: #define  WS_HSCROLL       FCF_HORZSCROLL
                     95: #define  WS_VSCROLL       FCF_VERTSCROLL
                     96: 
                     97: /* At last check, FCF_STANDARD included: title bar, sys menu, min-max, */
                     98: /*  and sizeborder.  */
                     99: 
                    100: #define  WS_TILEDWINDOW    FCF_STANDARD
                    101: 
                    102: /* GetWindowLong indices */
                    103: 
                    104: #define  GWL_WNDPROC      QWP_PFNWP
                    105: 
                    106: /* Mix Modes, raster ops */
                    107: 
                    108: #define  R2_NOTXORPEN      FM_NOTXORSRC
                    109: 
                    110: #define  TRANSPARENT       FM_LEAVEALONE
                    111: #define  OPAQUE            FM_OVERPAINT
                    112: 
                    113: #define  WHITENESS         ROP_ONE
                    114: 
                    115: /* Cursors.  Use POINTER_FLAG to indicate     */
                    116: /*  that a PM constant is a system pointer    */
                    117: /*  When calling Cursor functions, strip off  */
                    118: /*  flag.                                     */
                    119: 
                    120: #define  POINTER_FLAG      0x4000
                    121: #define  POINTER_MASK      ~POINTER_FLAG
                    122: 
                    123: #define  IDC_ARROW         SPTR_ARROW | POINTER_FLAG
                    124: #define  IDC_WAIT          SPTR_WAIT | POINTER_FLAG
                    125: 
                    126: /* Menu flags */
                    127: 
                    128: #define  MF_CHECKED        MIA_CHECKED
                    129: #define  MF_UNCHECKED      0
                    130: 
                    131: #define  MF_ENABLED        0
                    132: #define  MF_GRAYED         MIA_DISABLED
                    133: 
                    134: /* Scroll bar id's */
                    135: 
                    136: #define  SB_HORZ           FID_HORZSCROLL
                    137: #define  SB_VERT           FID_VERTSCROLL
                    138: 
                    139: /* Show Window commands */
                    140: 
                    141: #define  SHOW_OPENWINDOW   TRUE
                    142: #define  HIDE_WINDOW       FALSE
                    143: 
                    144: /* GetSysColor constant */
                    145: 
                    146: #define  COLOR_WINDOW      SYSCLR_WINDOW
                    147: 
                    148: /* Virtual Keys */
                    149: 
                    150: #define  VK_NEXT          VK_PAGEDOWN
                    151: #define  VK_PRIOR         VK_PAGEUP
                    152: #define  VK_LBUTTON        VK_BUTTON1
                    153: 
                    154: 
                    155: /********************************************************************/
                    156: /* Messages                                                         */
                    157: /********************************************************************/
                    158: 
                    159: #define  WM_KEYFIRST       WM_CHAR
                    160: #define  WM_KEYLAST        WM_CHAR
                    161: 
                    162: #define  WM_INITDIALOG     WM_INITDLG
                    163: 
                    164: #define  WM_LBUTTONUP      WM_BUTTON1UP
                    165: #define  WM_LBUTTONDOWN    WM_BUTTON1DOWN
                    166: #define  WM_LBUTTONDBLCLK  WM_BUTTON1DBLCLK
                    167: 
                    168: /* This message is will cause problems if applications try to use */
                    169: /* it in the same way as the Windows message.  Should probably  */
                    170: /* take it out. */
                    171: 
                    172: #define  WM_ERASEBKGND     WM_ERASEBACKGROUND
                    173: 
                    174: #define  WM_CUT            EM_CUT
                    175: #define  WM_COPY           EM_COPY
                    176: #define  WM_PASTE          EM_PASTE
                    177: 
                    178: #define  EM_LIMITTEXT      EM_SETTEXTLIMIT
                    179: #define  EM_GETMODIFY      EM_QUERYCHANGED
                    180: #define  EM_GETSEL         EM_QUERYSEL
                    181: 
                    182: #define  LBN_SELCHANGE     LN_SELECT
                    183: #define  LBN_DBLCLK        LN_ENTER
                    184: 
                    185: 
                    186: 
                    187: /********************************************************************/
                    188: /* General Utility Defines                                          */
                    189: /********************************************************************/
                    190: 
                    191: #define  BLUE_COLOR    CLR_BLUE
                    192: #define  RED_COLOR     CLR_RED
                    193: #define  WHITE_COLOR   CLR_WHITE
                    194: #define  BLACK_COLOR   CLR_BLACK
                    195: 
                    196: /* Min/Max may not be in the PM include files  */
                    197: #ifndef  min
                    198: #define  min( x, y )             ((x) < (y) ? x : y )
                    199: #endif
                    200: 
                    201: #ifndef  max
                    202: #define  max( x, y )             ((x) > (y) ? x : y )
                    203: #endif
                    204: 
                    205: 
                    206: /********************************************************************/
                    207: /* Translations                                                     */
                    208: /********************************************************************/
                    209: 
                    210: 
                    211: /* The RGB format is reversed in PM */
                    212: 
                    213: #define  CONVERT_RGB( x )        ((((DWORD)(x) & 0xff) << 16) | \
                    214:                                    ((DWORD)(x) & 0x00ff00) | \
                    215:                                    ((DWORD)(x) >> 16))
                    216: 
                    217: 
                    218: /* This define sets up main to initialize and call WinMain */
                    219: 
                    220: #define  ENTRYPROCEDURE()  int cdecl main( void );  \
                    221:                            int cdecl main() {  \
                    222:                               hAB = WinInitialize( NULL ); \
                    223:                               INIT_APP(); \
                    224:                               WinMain( hAB, 0, "", SHOW_OPENWINDOW ); \
                    225:                               TERMINATE_APP(); \
                    226:                               WinTerminate( hAB ); \
                    227:                               return( 0 ); \
                    228:                            }
                    229: 
                    230: /* Create message queue, local heap.  Internal to pmbind.h */
                    231: 
                    232: #define  INIT_APP()        hMQ = WinCreateMsgQueue( hAB, 0 ); \
                    233:                            hLocalHeap = WinCreateHeap( 0, 0, 0,  \
                    234:                                                        0, 0, HM_MOVEABLE )
                    235: 
                    236: /* Destroy message queue, local heap.  Internal to pmbind.h */
                    237: 
                    238: #define  TERMINATE_APP()   WinDestroyHeap( hLocalHeap );    \
                    239:                            WinDestroyMsgQueue( hMQ )
                    240: 
                    241: /* Get frame from window */
                    242: 
                    243: #define  FRAME( a )              WinQueryWindow( a, QW_PARENT, FALSE )
                    244: 
                    245: 
                    246: /**********************************************************/
                    247: /* Defines used for coordinate transformations            */
                    248: /**********************************************************/
                    249: 
                    250: /* External defines */
                    251: 
                    252: #define  TRANSLATE_Y( x )        (WinHeight - x)
                    253: #define  TRANSLATE_RECT( x )     x.yTop = WinHeight - x.yTop; \
                    254:                                  x.yBottom = WinHeight - x.yBottom;
                    255: 
                    256: #define  SET_CHARHEIGHT( x )     b_CharHeight = x
                    257: 
                    258: #define  TRANSLATE_COORDS( x )   WinHeight = x
                    259: 
                    260: #define  MAKEPOINT( a )          (pt.x = LOUSHORT( a ), \
                    261:                                  pt.y = HIUSHORT( a ), pt)
                    262: 
                    263: /* Internal defines */
                    264: 
                    265: #define  TRANSY( y )             (WinHeight ? (WinHeight - (y)) : (y)) 
                    266: 
                    267: #define  STUFFPOINT( a, b )      Point.x = (long) a; \
                    268:                                  Point.y = (long) TRANSY(b)
                    269: 
                    270: 
                    271: /*********************************************************************/
                    272: /* Control Window Mappings                                           */
                    273: /*                                                                   */
                    274: /* Mappings:                                                         */
                    275: /*    GetMenu( hWnd )                                                */
                    276: /*    EnableMenuItem( hMenu, wId, fEnableOn )                        */
                    277: /*    CheckMenuItem( hMenu, wId, fCheckOn )                          */
                    278: /*    SROLL_RANGE( hWnd, wId, wPos, wHigh, wLow )                    */
                    279: /*    SetScrollPos( hWnd, wId, wPos, fRedraw )                       */
                    280: /*********************************************************************/
                    281: 
                    282: /*********/
                    283: /* Menus */
                    284: /*********/
                    285: 
                    286: #define  GetMenu( a )         WinWindowFromID( FRAME( a ), FID_MENU )
                    287: 
                    288: #define  EnableMenuItem( a, b, c )  NewSendMsg( a, MM_SETITEMATTR, \
                    289:                               MAKELONG( b, TRUE ), \
                    290:                               MAKELONG( MIA_DISABLED, c ) )
                    291: 
                    292: #define  CheckMenuItem( a, b, c )   NewSendMsg( a, MM_SETITEMATTR, \
                    293:                               MAKELONG( b, TRUE ), \
                    294:                               MAKELONG( MIA_CHECKED, c ) )
                    295: /***************/
                    296: /* Scroll Bars */
                    297: /***************/
                    298: 
                    299: /* Scroll_Range( hwnd, Id value, Pos, First, Last ) */
                    300: 
                    301: #define  SCROLL_RANGE( a, b, c, d, e ) { if \
                    302:       (CheckScrollBars( FRAME(a), b, d != e )) \
                    303:                 NewSendDlgItemMsg( FRAME(a), b, SBM_SETSCROLLBAR, \
                    304:                                    c, MAKELONG( d, e ) ); }
                    305: 
                    306: #define  SetScrollPos( a, b, c, d )    \
                    307:         NewSendDlgItemMsg( FRAME(a), b, SBM_SETPOS, \
                    308:                            c, 0 )
                    309: 
                    310: 
                    311: /*********************************************************************/
                    312: /* Window DC Mappings                                                */
                    313: /*                                                                   */
                    314: /*    In most cases that an IC should be created, the app. just      */
                    315: /* wants system font information.  In PM, just return PS of the      */
                    316: /* desktop.                                                          */
                    317: /*                                                                   */
                    318: /* Mappings:                                                         */
                    319: /*    GetDC( hWnd )                                                  */
                    320: /*    ReleaseDC( hDC )                                               */
                    321: /*    CreateIC( lpDriv, lpDevice, lpOutput, lpInit )                 */
                    322: /*    DeleteDC( hDC )                                                */
                    323: /*********************************************************************/
                    324: 
                    325: #define  GetDC( x )              WinGetPS( x )
                    326: #define  ReleaseDC( x, y )       WinReleasePS( (HPS) y )
                    327: #define  CreateIC( a, b, c, d )  WinGetPS( HWND_DESKTOP )
                    328: #define  DeleteDC( x )           WinReleasePS( (HPS) x )
                    329: 
                    330: 
                    331: 
                    332: 
                    333: /*********************************************************************/
                    334: /* Memory Management Mappings                                        */
                    335: /*                                                                   */
                    336: /*                                                                   */
                    337: /*    Here's a good chance to test the flexibility of this system.   */
                    338: /* GlobalAlloc maps to DosAllocSeg which creates a Global ID for     */
                    339: /* each call.  For applications making many global allocs of a       */
                    340: /* small size (like Cardfile), it's probably better to use           */
                    341: /* DosSubAlloc for some of these.                                    */
                    342: /*                                                                   */
                    343: /* Mappings:                                                         */
                    344: /*    LocalAlloc( wFlags, wSize )                                    */
                    345: /*    LocalFree( wBlock )                                            */
                    346: /*    GlobalAlloc( wFlags, wSize )                                   */
                    347: /*    GlobalReAlloc( wHandle, wSize, wFlags )                        */
                    348: /*    GlobalUnlock( wHandle );                                       */
                    349: /*    GlobalFree( wHandle );                                         */
                    350: /*    GlobalLock( wHandle );                                         */
                    351: /*********************************************************************/
                    352: 
                    353: #define  LocalAlloc( x, y )   WinAllocMem( hLocalHeap, y )
                    354: #define  LocalFree( x )       WinFreeMem( hLocalHeap, (char *) x, 0 )
                    355: 
                    356: #define  GlobalAlloc( x, y )  (DosAllocSeg( (unsigned) y, \
                    357:                                  (PSEL)&temp, 0 ), temp)
                    358: #define  GlobalReAlloc( Han, Size, x ) !DosReallocSeg( \
                    359:                                          (USHORT) Size, (SEL)Han )
                    360: #define  GlobalUnlock( x )       
                    361: #define  GlobalFree( x )      DosFreeSeg( (SEL) x )
                    362: #define  GlobalLock( x )      MAKEP( x, 0 )
                    363: 
                    364: 
                    365: 
                    366: /*********************************************************************/
                    367: /* Dialog Management Mappings                                        */
                    368: /*                                                                   */
                    369: /*    MAKEINTRESOURCE is not needed because PM resources are always  */
                    370: /* ints.  The mapping for GetDlgItemInt doesn't take lpfSuccess      */
                    371: /* into account.                                                     */
                    372: /*                                                                   */
                    373: /* Mappings:                                                         */
                    374: /*    MAKEINTRESOURCE( x )                                           */
                    375: /*    MessageBeep( wBeepType )                                       */
                    376: /*    MessageBox( hWnd, lpText, lpCaption, wType )                   */
                    377: /*    DialogBox( hInst, lpTemplate, hParent, lpFunc )                */
                    378: /*    EndDialog( hDlg, wResult )                                     */
                    379: /*    SendDlgItemMessage( hDlg, wId, wMsg, wParam, lParam )          */
                    380: /*    GetDlgItem( hDlg, wId )                                        */
                    381: /*    SetDlgItemText( hDlg, wId, lpBuf )                             */
                    382: /*    GetDlgItemText( hDlg, wId, lpBuf, wMax )                       */
                    383: /*    GetDlgItemInt( hDlg, wId, lpfSuccess, fSigned )                */
                    384: /*    SetDlgItemInt( hDlg, wId, wValue, fSigned )                    */
                    385: /*********************************************************************/
                    386: 
                    387: /*******************************/
                    388: /* Dialog Creation/Destruction */
                    389: /*******************************/
                    390: 
                    391: #define  MAKEINTRESOURCE( x )       x
                    392: #define  MessageBeep( a )           WinAlarm( HWND_DESKTOP, WA_WARNING )
                    393: #define  MessageBox( a, b, c, d )   WinMessageBox( HWND_DESKTOP, a, b, \
                    394:                                                    c, 0, d )
                    395: #define  DialogBox( a, b, c, d )    WinDlgBox( HWND_DESKTOP, c, d, \
                    396:                                                NULL, b, NULL )
                    397: #define  EndDialog( x, y )          WinDismissDlg( x, y )
                    398: 
                    399: /*******************/
                    400: /* Dialog messages */
                    401: /*******************/
                    402: 
                    403: #define  SendDlgItemMessage( a, b, c, d, e ) \
                    404:                   NewSendDlgItemMsg( a, b, c, d, e )
                    405: 
                    406: /***************************************/
                    407: /* Dialog: Setting/Getting information */
                    408: /***************************************/
                    409: 
                    410: #define  GetDlgItem( x, y )            WinWindowFromID( x, y )
                    411: 
                    412: #define  GetDlgItemText( a, b, c, d )  \
                    413:                   WinQueryDlgItemText( a, b , d, c )
                    414: 
                    415: #define  SetDlgItemText( x, y, z )     \
                    416:                   WinSetDlgItemText( x, y , z )
                    417: 
                    418: #define  GetDlgItemInt( a, b, c, d ) \
                    419:                ( WinQueryDlgItemShort( a, b, &temp, d ), temp )
                    420: 
                    421: #define  SetDlgItemInt( a, b, c, d )   WinSetDlgItemShort( a, b, c, d )
                    422: 
                    423: 
                    424: 
                    425: /*********************************************************************/
                    426: /* Rectangle Mappings                                                */
                    427: /*                                                                   */
                    428: /*    Application should call TRANSLATE_RECT after most SetRect's.   */
                    429: /*                                                                   */
                    430: /* Mappings:                                                         */
                    431: /*    SetRect( lpRect, left, top, right, bottom )                    */
                    432: /*    InflateRect( lpRect, dx, dy )                                  */
                    433: /*    PtInRect( lpRect, pt )                                         */
                    434: /*********************************************************************/
                    435: 
                    436: #define  SetRect( a, b, c, d, e )   WinSetRect( hAB, a, b, e, d, c )
                    437: #define  InflateRect( a, b, c )     WinInflateRect( hAB, a, b, c )
                    438: #define  PtInRect( a, b )           WinPtInRect( hAB, a, (PPOINTL) &b )
                    439: 
                    440: 
                    441: /*********************************************************************/
                    442: /* Window Attribute Mappings                                         */
                    443: /*                                                                   */
                    444: /*    GetWindowLong is available for a minimal number of indices.    */
                    445: /*                                                                   */
                    446: /* Mappings:                                                         */
                    447: /*    SetWindowText( hWnd, lpText )                                  */
                    448: /*    GetWindowText( hWnd, lpBuf, wMax )                             */
                    449: /*    GetWindowTextLength( hWnd )                                    */
                    450: /*    GetClientRect( hWnd, lpRect )                                  */
                    451: /*    GetWindowLong( hWnd, wIndex )                                  */
                    452: /*    SetWindowLong( hWnd, wIndex, lValue )                          */
                    453: /*********************************************************************/
                    454: 
                    455: #define  SetWindowText( x, y )      WinSetWindowText( x, y )
                    456: #define  GetWindowText( x, y, z )   WinQueryWindowText( x, z, y )
                    457: #define  GetWindowTextLength( a )   WinQueryWindowTextLength( a )   
                    458: #define  GetClientRect( x, y )      WinQueryWindowRect( x, y )
                    459: #define  GetWindowLong( a, b )      WinQueryWindowULong( a, b )
                    460: #define  SetWindowLong( a, b, c )   WinSetWindowULong( a, b, c )
                    461: 
                    462: 
                    463: 
                    464: 
                    465: /*********************************************************************/
                    466: /* Window Painting Mappings                                          */
                    467: /*                                                                   */
                    468: /*    For the time being, punt on the issues of brushes.  Treat      */
                    469: /* brushes as colors in PM version.  This should eventually be       */
                    470: /* changed to treat a brush as a pointer to some BUNDLESTRUCT        */
                    471: /*                                                                   */
                    472: /* Mappings:                                                         */
                    473: /*    BeginPaint( hWnd, lpPaintStruct )                              */
                    474: /*    EndPaint( hWnd, lpPaintStruct )                                */
                    475: /*    UpdateWindow( hWnd )                                           */
                    476: /*    InvalidateRect( hWnd, lpRect, fErase )                         */
                    477: /*    ShowWindow( hWnd, fShow )                                      */
                    478: /*    FillRect( hWnd, lpRect, hBrush )                               */
                    479: /*    InvertRect( hWnd, lpRect )                                     */
                    480: /*    FrameRect( hWnd, lpRect, hBrush )                              */
                    481: /*    ScrollWindow( hWnd, dx, dy, lpRect, lpClipRect )               */
                    482: /*********************************************************************/
                    483: 
                    484: 
                    485: /* The BeginPaint mapping utilizes the PAINTSTRUCT defined in  */
                    486: /* PmBind.h.  This is not valid for applications which own the */
                    487: /* PS. */
                    488: 
                    489: #define  BeginPaint( a, b )   \
                    490:      (b)->hdc = WinBeginPaint( a, (HPS) NULL, (PRECTL) &(b)->rcPaint )
                    491: 
                    492: #define  EndPaint( a, b )     WinEndPaint( (b)->hdc )
                    493: 
                    494: 
                    495: #define  UpdateWindow( x )    WinUpdateWindow( x )
                    496: #define  InvalidateRect( x, y, z )  WinInvalidateRect( x, y, TRUE )
                    497: #define  ShowWindow( x, y )   WinShowWindow( x, y )
                    498: 
                    499: #define  FillRect( x, y, z )  WinFillRect( x, y, z )
                    500: #define  InvertRect( a, b )   WinInvertRect( a, b )
                    501: 
                    502: /* Assume with is 5 units for PM mapping */
                    503: #define  FrameRect( a, b, c ) \
                    504:       WinDrawBorder( a, b, 1, 1, c, 0L, DB_PATCOPY )
                    505: 
                    506: #define  ScrollWindow( a, b, c, d, e ) \
                    507:      WinScrollWindow( a, b, - c, d, e, NULL, NULL, SW_INVALIDATERGN )
                    508: 
                    509: 
                    510: /*********************************************************************/
                    511: /* Window Manipulation Mappings                                      */
                    512: /*                                                                   */
                    513: /*    CreateWindow only works for the Main Window!  When creating    */
                    514: /* child windows, use separate compilation.  None of these           */
                    515: /* routines operate automatically on the frame.  In the source       */
                    516: /* code, use the frame macro (I think ScrollWindow is the only       */
                    517: /* routine which retrieves the frame window automatically).          */
                    518: /*                                                                   */
                    519: /* Mappings:                                                         */
                    520: /*    CreateWindow( lpClass, lpCaption, dwStyle, x, y, width, height,*/
                    521: /*                  hParent, hMenu, hInst, lpParam )                 */
                    522: /*    DestroyWindow( hWnd )                                          */
                    523: /*    MoveWindow( hWnd, x, y, Width, Height, fRePaint )              */
                    524: /*    GetFocus()                                                     */
                    525: /*    SetFocus( hWnd )                                               */
                    526: /*    IsWindowEnabled( hWnd )                                        */
                    527: /*    EnableWindow( hWnd, fEnable )                                  */
                    528: /*********************************************************************/
                    529: 
                    530: #define  CreateWindow( a, b, c, d, e, f, g, h, i, j, k ) \
                    531:      (ctlData=c, \
                    532:      WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE | FS_ICON, \
                    533:                         &ctlData, a, b, 0L, NULL, 1, \
                    534:                         (HWND FAR *) &hwndTemp ), \
                    535:       hwndTemp )
                    536: 
                    537: #define  DestroyWindow( a )   WinDestroyWindow( a )
                    538: 
                    539: #define  MoveWindow( a, b, c, d, e, f ) \
                    540:       WinSetWindowPos( a, NULL, b, TRANSY(c) - e, d, \
                    541:                        e, SWP_SIZE | SWP_MOVE )
                    542: 
                    543: 
                    544: #define  GetFocus()           WinQueryFocus( HWND_DESKTOP, FALSE )
                    545: #define  SetFocus( x )        WinSetFocus( hAB, x )
                    546: 
                    547: 
                    548: #define  IsWindowEnabled( a )          WinIsWindowEnabled( a )
                    549: #define  EnableWindow( a, b )          WinEnableWindow( a, b )
                    550: 
                    551: 
                    552: 
                    553: /*********************************************************************/
                    554: /* Ansi Mappings                                                     */
                    555: /*                                                                   */
                    556: /*    Another chance to prove the system flexibility!  These         */
                    557: /* functions will eventually accept call the functions with the      */
                    558: /* code pages.                                                       */
                    559: /*                                                                   */
                    560: /* Mappings:                                                         */
                    561: /*    AnsiNext( lpStr )                                              */
                    562: /*    AnsiPrev( lpStr )                                              */
                    563: /*    AnsiUpper( lpStr )                                             */
                    564: /*    ANSICHARUP( lpStr ) - (High word is 0)                         */
                    565: /*********************************************************************/
                    566: 
                    567: #define  LOWERCHAR( a )    ( (a <= 'z') && (a >= 'a') )
                    568: 
                    569: #define  AnsiNext( a )     (a + 1)
                    570: #define  AnsiPrev( a, b )  (b - 1)
                    571: #define  AnsiUpper( Str )  \
                    572:    { for (temp = 0; (Str)[temp]; temp++ ) \
                    573:          if (LOWERCHAR((Str)[temp]))   \
                    574:               (Str)[temp] = (Str)[temp] & 0xdf; }
                    575: 
                    576: #define  ANSICHARUP( a )   ( ((BYTE)((DWORD)(a))) & 0xdf)
                    577: 
                    578: 
                    579: 
                    580: /*********************************************************************/
                    581: /* Clipboard Mappings                                                */
                    582: /*                                                                   */
                    583: /* Mappings:                                                         */
                    584: /*    EnumClipbrdFmts( wFormat )                                     */
                    585: /*    OpenClipboard( hWnd )                                          */
                    586: /*    CloseClipboard( hWnd )                                         */
                    587: /*    EnumClipboardFormats( hWnd )                                   */
                    588: /*********************************************************************/
                    589: 
                    590: #define  EnumClipbrdFmts( x )          WinEnumClipbrdFmts( hAB, x )
                    591: #define  OpenClipboard( a )            WinOpenClipbrd( hAB )
                    592: #define  CloseClipboard()              WinCloseClipbrd( hAB )
                    593: #define  EnumClipboardFormats( a )  WinEnumClipbrdFmts( hAB, a )
                    594: 
                    595: 
                    596: 
                    597: /*********************************************************************/
                    598: /* Messaging Mappings                                                */
                    599: /*                                                                   */
                    600: /*    The accelerator mapping may need to be changed.                */
                    601: /*                                                                   */
                    602: /* Mappings:                                                         */
                    603: /*    SendMessage( hWnd, wMsg, wParam, lParam )                      */
                    604: /*    GetMessage( lpMsg, hWnd, wMin, wMax )                          */
                    605: /*    DispatchMessage( lpMsg )                                       */
                    606: /*    TranslateAccelerator( hWnd, hAccel, lpMsg )                    */
                    607: /*    TranslateMessage( lpMsg )                                      */
                    608: /*    PeekMessage( lpMsg, hWnd, wMin, wMax, fRemove )                */
                    609: /*********************************************************************/
                    610: 
                    611: #define  SendMessage( a, b, c, d )  \
                    612:                NewSendMsg( a, b, c, d )
                    613: 
                    614: #define  GetMessage( a, b, c, d )   WinGetMsg( hAB, a, b, c, d )
                    615: #define  DispatchMessage( a )       WinDispatchMsg( hAB, a )
                    616: #define  TranslateAccelerator( a, b, c )  FALSE
                    617: #define  TranslateMessage( a )      
                    618: 
                    619: #define  PeekMessage( a, b, c, d, e ) \
                    620:     WinPeekMsg( hAB, a, b, c, d, e ? PM_REMOVE : PM_NOREMOVE )
                    621: 
                    622: 
                    623: /*********************************************************************/
                    624: /* Cursor Mappings                                                   */
                    625: /*                                                                   */
                    626: /*    The LoadCursor mapping must distinguish between the system     */
                    627: /* pointer and a resource.  Therefore, the constants used for the    */
                    628: /* system pointers include a bit, POINTER_FLAG.  If this is found    */
                    629: /* in the index, it is masked off and the system pointer is          */
                    630: /* retrieved.  This method runs the risk of collision of             */
                    631: /* POINTER_FLAG with the constants used for the system pointers      */
                    632: /* (they may change) as well as the values in the user resource      */
                    633: /* file.                                                             */
                    634: /*                                                                   */
                    635: /* Mappings:                                                         */
                    636: /*    SetCapture( hWnd )                                             */
                    637: /*    ReleaseCapture( hWnd )                                         */
                    638: /*    SetCursor( hCurs )                                             */
                    639: /*    LoadCursor( hCurs )                                            */
                    640: /*********************************************************************/
                    641: 
                    642: #define  SetCapture( a )   WinSetCapture( hAB, a )
                    643: #define  ReleaseCapture()  WinSetCapture( hAB, NULL )
                    644: 
                    645: #define  SetCursor( a )    WinSetPointer( HWND_DESKTOP, a )
                    646: #define  LoadCursor( a, b ) \
                    647:    ( b & POINTER_FLAG ? \
                    648:     WinQuerySysPointer( HWND_DESKTOP, b & ~POINTER_MASK, TRUE ) : \
                    649:     WinLoadPointer( HWND_DESKTOP, NULL, b ) )
                    650: 
                    651: 
                    652: /*********************************************************************/
                    653: /* Misc Mappings                                                     */
                    654: /*********************************************************************/
                    655: 
                    656: 
                    657: 
                    658: #define  LoadString( a, b, c, d )  \
                    659:             WinLoadString( hAB, NULL, b, (SHORT) d, c )
                    660: 
                    661: #define  DefWindowProc( a, b, c, d )   NewDefWindowProc( a, b, c, d )
                    662: 
                    663: /* Originally, there was a problem is GpiCharStringAt was called   */
                    664: /*  with 0 chars to write.  Hence the if statement. */
                    665: 
                    666: #define  TextOut( a, b, c, d, e )   \
                    667:       { if (e) { STUFFPOINT( b, c ); \
                    668:             Point.y -= b_CharHeight; \
                    669:             GpiCharStringAt( a, &Point, (LONG) e, d ); } }
                    670: 
                    671: #define  SetBkMode( a, b )             GpiSetBackMix( a, b )
                    672: 
                    673: #define  LoadAccelerators( a, b )      NULL
                    674: #define  LoadIcon( a, b )              NULL
                    675: 
                    676: /* For the time being, don't worry about this one  */
                    677: #define  GetTempFileName( a, b, c, d ) (lstrcpy( d, "cardfile.tmp" ), 1)
                    678: 
                    679: /* Neither of these functions is available or necessary in PM */
                    680: #define  MakeProcInstance( a, b )   (PFNWP) (a)
                    681: #define  GetInstanceData( a, b, c ) 
                    682: 
                    683: #define  MoveTo( a, b, c ) {STUFFPOINT( b, c ); GpiMove( a, &Point );}
                    684: #define  LineTo( a, b, c ) {STUFFPOINT( b, c ); GpiLine( a, &Point );}
                    685: 
                    686: #define  SetROP2( a, b )   GpiSetMix( a, b )
                    687: 
                    688: #define  PatBlt( a, b, c, d, e, f ) \
                    689:       { PointArray[0].x = b; \
                    690:         PointArray[0].y = TRANSY( c + e ); \
                    691:         PointArray[1].x = b + d; \
                    692:         PointArray[1].y = TRANSY( c ); \
                    693:         GpiBitBlt( a, a, 2L, PointArray, f, BLTMODE_NOSCALE ); }
                    694: 
                    695: #define  DPtoLP( a, b, c )    \
                    696:       GpiConvert( a, CVTC_DEVICE, CVTC_WORLD, (long) c, (PPOINTL) b );
                    697: 
                    698: /* Only a few of the fields in the TEXTMETRICS structure are mapped  */
                    699: /* onto the FONTMETRICS structure (see pmbind1.h) */
                    700: 
                    701: #define  GetTextMetrics( a, b )  \
                    702:       GpiQueryFontMetrics( a, (LONG) sizeof( FONTMETRICS ), b )
                    703: 
                    704: #define  CallWindowProc( a, b, c, d, e )  \
                    705:             LONGFROMMR(a( b, c, MPFROMLONG(d), MPFROMLONG(e) ))
                    706: 
                    707: #define  GetKeyState( a )       WinGetKeyState( HWND_DESKTOP, a )
                    708: 
                    709: #define  GetSysColor( a )        WinQuerySysColor( HWND_DESKTOP, a, 0L )
                    710: 
                    711: #define  CreateSolidBrush( a )   a
                    712: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.