home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bmp1.zip / ViewDlg.C < prev    next >
C/C++ Source or Header  |  1995-10-29  |  35KB  |  1,058 lines

  1. #pragma    title("View Bitmap  --  Version 1  --  (ViewDlg.C)")
  2. #pragma    subtitle("   View Dialogues - Interface Definitions")
  3.  
  4. #define    INCL_DEV           /* Include OS/2 Device Interface    */
  5. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  6. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  7.  
  8. #include <malloc.h>
  9. #include <os2.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13.  
  14. #include "appdefs.h"
  15. #include "viewbmp.h"
  16.  
  17. /* This    module contains    routines used to display the bitmap information    */
  18. /* contained within the    bitmap structures.                */
  19.  
  20. /* Filename:   ViewDlg.C                        */
  21.  
  22. /*  Version:   1                            */
  23. /*  Created:   1995-07-08                        */
  24. /*  Revised:   1995-10-29                        */
  25.  
  26. /* Routines:   MRESULT EXPENTRY    ViewBITMAPARRAYFILEHEADER2DlgProc(    */
  27. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  28. /*           MRESULT EXPENTRY    ViewBITMAPFILEHEADER2DlgProc(        */
  29. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  30. /*           MRESULT EXPENTRY    ViewBITMAPINFOHEADER2DlgProc(        */
  31. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  32. /*           MRESULT EXPENTRY    ViewBITMAPARRAYFILEHEADER2DlgProc(    */
  33. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  34. /*           MRESULT EXPENTRY    ViewBITMAPFILEHEADER2DlgProc(        */
  35. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  36. /*           MRESULT EXPENTRY    ViewBITMAPINFOHEADER2DlgProc(        */
  37. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  38. /*           static VOID SetTableValues(HWND hWnd);            */
  39. /*           static VOID QueryTableValues(HWND hWnd);            */
  40. /*           MRESULT EXPENTRY    ViewColourTableDlgProc(            */
  41. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  42. /*           MRESULT EXPENTRY    ViewSystemBitmapInfoDlgProc(        */
  43. /*               HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);    */
  44.  
  45.  
  46. /************************************************************************/
  47. /************************************************************************/
  48. /************************************************************************/
  49. /* DISCLAIMER OF WARRANTIES:                        */
  50. /* -------------------------                        */
  51. /* The following [enclosed] code is sample code    created    by IBM        */
  52. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  53. /* standard IBM    product    and is provided    to you solely for the purpose    */
  54. /* of assisting    you in the development of your applications.  The code    */
  55. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  56. /* Prominare shall be liable for any damages arising out of your    */
  57. /* use of the sample code, even    if they    have been advised of the    */
  58. /* possibility of such damages.                        */
  59. /************************************************************************/
  60. /************************************************************************/
  61. /************************************************************************/
  62. /*               D I S C L A I M E R                */
  63. /* This    code is    provided on an as is basis with    no implied support.    */
  64. /* It should be    considered freeware that cannot    be rebundled as        */
  65. /* part    of a larger "*ware" offering without our consent.        */
  66. /************************************************************************/
  67. /************************************************************************/
  68. /************************************************************************/
  69.  
  70. /* Copyright ╕ International Business Machines Corp., 1995.        */
  71. /* Copyright ╕ 1995  Prominare Inc.  All Rights    Reserved.        */
  72.  
  73. /* --------------------------------------------------------------------    */
  74.  
  75. RGB   *prgb;               /* RGB Pointer            */
  76. RGB2  *prgb2;               /* RGB Pointer            */
  77. PBYTE pbTable;               /* RGB Table    Pointer            */
  78. LONG  lVScrollPos;           /* Vertical Scroll Bar Position    */
  79.  
  80. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  81. #pragma    page( )
  82.  
  83. /* --- ViewBITMAPARRAYFILEHEADER2DlgProc --------------- [ Public ] ---    */
  84. /*                                    */
  85. /*     This function is    used to    process    the messages for the dialog    */
  86. /*     procedure.                            */
  87. /*                                    */
  88. /*     Upon Entry:                            */
  89. /*                                    */
  90. /*     HWND   hWnd; = Dialog Window Handle                */
  91. /*     ULONG  msg;  = PM Message                    */
  92. /*     MPARAM mp1;  = Message Parameter    1                */
  93. /*     MPARAM mp2;  = Message Parameter    2                */
  94. /*                                    */
  95. /*     Upon Exit:                            */
  96. /*                                    */
  97. /*     ViewBITMAPARRAYFILEHEADER2DlgProc = Message Handling Result    */
  98. /*                                    */
  99. /* --------------------------------------------------------------------    */
  100.  
  101. MRESULT    EXPENTRY ViewBITMAPARRAYFILEHEADER2DlgProc(HWND    hWnd, ULONG msg, MPARAM    mp1, MPARAM mp2)
  102.  
  103. {
  104. CHAR            szNumber[32];  /* Numeric Buffer        */
  105. PBITMAPARRAYFILEHEADER2    pbafh;       /* Bitmap Array File    Header Pointer    */
  106. PSZ            pszType;   /* Type String Pointer        */
  107. register INT i;               /* Index                */
  108.  
  109. switch ( msg )
  110.    {
  111.  
  112. /************************************************************************/
  113. /* Perform dialog initialization                    */
  114. /************************************************************************/
  115.  
  116.    case    WM_INITDLG :
  117.        pbafh = (PBITMAPARRAYFILEHEADER2)abm[i =    LONGFROMMP(mp2)].pb;
  118.        switch (    pbafh->usType )
  119.        {
  120.        case    BFT_ICON :
  121.            pszType = "BFT_ICON";
  122.            break;
  123.  
  124.       case BFT_BMAP    :
  125.            pszType = "BFT_BMAP";
  126.            break;
  127.  
  128.        case    BFT_POINTER :
  129.            pszType = "BFT_POINTER";
  130.            break;
  131.  
  132.        case    BFT_COLORICON :
  133.            pszType = "BFT_COLORICON";
  134.            break;
  135.  
  136.        case    BFT_COLORPOINTER :
  137.            pszType = "BFT_COLORPOINTER";
  138.            break;
  139.  
  140.        case    BFT_BITMAPARRAY    :
  141.            pszType = "BFT_BITMAPARRAY";
  142.            break;
  143.  
  144.        default :
  145.            pszType = "Unknown";
  146.            break;
  147.        }
  148.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)i, szNumber,    10));
  149.        WinSetDlgItemText(hWnd, IT_USTYPE,    pszType);
  150.        WinSetDlgItemText(hWnd, IT_CBSIZE,    _ltoa((LONG)pbafh->cbSize,    szNumber, 10));
  151.        WinSetDlgItemText(hWnd, IT_OFFNEXT,   _ltoa((LONG)pbafh->offNext, szNumber, 10));
  152.        WinSetDlgItemText(hWnd, IT_CXDISPLAY, _ltoa((LONG)pbafh->cxDisplay, szNumber, 10));
  153.        WinSetDlgItemText(hWnd, IT_CYDISPLAY, _ltoa((LONG)pbafh->cyDisplay, szNumber, 10));
  154.        break;
  155.  
  156. /************************************************************************/
  157. /* Process push    button selections                    */
  158. /************************************************************************/
  159.  
  160.    case    WM_COMMAND :
  161.        switch (    SHORT1FROMMP(mp1) )
  162.        {
  163.        case    DID_OK :
  164.            WinDismissDlg(hWnd, TRUE);
  165.            break;
  166.        }
  167.        break;
  168.  
  169. /************************************************************************/
  170. /* Close requested, exit dialogue                    */
  171. /************************************************************************/
  172.  
  173.    case    WM_CLOSE :
  174.        WinDismissDlg(hWnd, FALSE);
  175.        break;
  176.  
  177.             /* Pass    through    unhandled messages        */
  178.    default :
  179.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  180.    }
  181. return(0L);
  182. }
  183. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  184. #pragma    page( )
  185.  
  186. /* --- ViewBITMAPFILEHEADER2DlgProc -------------------- [ Public ] ---    */
  187. /*                                    */
  188. /*     This function is    used to    process    the messages for the dialog    */
  189. /*     procedure.                            */
  190. /*                                    */
  191. /*     Upon Entry:                            */
  192. /*                                    */
  193. /*     HWND   hWnd; = Dialog Window Handle                */
  194. /*     ULONG  msg;  = PM Message                    */
  195. /*     MPARAM mp1;  = Message Parameter    1                */
  196. /*     MPARAM mp2;  = Message Parameter    2                */
  197. /*                                    */
  198. /*     Upon Exit:                            */
  199. /*                                    */
  200. /*     ViewBITMAPFILEHEADER2DlgProc = Message Handling Result        */
  201. /*                                    */
  202. /* --------------------------------------------------------------------    */
  203.  
  204. MRESULT    EXPENTRY ViewBITMAPFILEHEADER2DlgProc(HWND hWnd, ULONG msg, MPARAM mp1,    MPARAM mp2)
  205.  
  206. {
  207. CHAR           szNumber[32];   /* Numeric Buffer            */
  208. PBITMAPFILEHEADER2 pbfh2;       /* Bitmap Array File    Header Pointer    */
  209. PSZ           pszType;       /* Type String Pointer        */
  210.  
  211. switch ( msg )
  212.    {
  213.  
  214. /************************************************************************/
  215. /* Perform dialog initialization                    */
  216. /************************************************************************/
  217.  
  218.    case    WM_INITDLG :
  219.        pbfh2 = (PBITMAPFILEHEADER2)PVOIDFROMMP(mp2);
  220.        switch (    pbfh2->usType )
  221.        {
  222.        case    BFT_ICON :
  223.            pszType = "BFT_ICON";
  224.            break;
  225.  
  226.       case BFT_BMAP    :
  227.            pszType = "BFT_BMAP";
  228.            break;
  229.  
  230.        case    BFT_POINTER :
  231.            pszType = "BFT_POINTER";
  232.            break;
  233.  
  234.        case    BFT_COLORICON :
  235.            pszType = "BFT_COLORICON";
  236.            break;
  237.  
  238.        case    BFT_COLORPOINTER :
  239.            pszType = "BFT_COLORPOINTER";
  240.            break;
  241.  
  242.        case    BFT_BITMAPARRAY    :
  243.            pszType = "BFT_BITMAPARRAY";
  244.            break;
  245.  
  246.        default :
  247.            pszType = "Unknown";
  248.            break;
  249.        }
  250.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)iBitmapSelected, szNumber, 10));
  251.        WinSetDlgItemText(hWnd, IT_USTYPE,   pszType);
  252.        WinSetDlgItemText(hWnd, IT_CBSIZE,   _ltoa((LONG)pbfh2->cbSize, szNumber, 10));
  253.        WinSetDlgItemText(hWnd, IT_XHOTSPOT, _ltoa((LONG)pbfh2->xHotspot, szNumber, 10));
  254.        WinSetDlgItemText(hWnd, IT_YHOTSPOT, _ltoa((LONG)pbfh2->yHotspot, szNumber, 10));
  255.        WinSetDlgItemText(hWnd, IT_OFFBITS,  _ltoa((LONG)pbfh2->offBits,    szNumber, 10));
  256.        break;
  257.  
  258. /************************************************************************/
  259. /* Process push    button selections                    */
  260. /************************************************************************/
  261.  
  262.    case    WM_COMMAND :
  263.        switch (    SHORT1FROMMP(mp1) )
  264.        {
  265.        case    DID_OK :
  266.            WinDismissDlg(hWnd, TRUE);
  267.            break;
  268.        }
  269.        break;
  270.  
  271. /************************************************************************/
  272. /* Close requested, exit dialogue                    */
  273. /************************************************************************/
  274.  
  275.    case    WM_CLOSE :
  276.        WinDismissDlg(hWnd, FALSE);
  277.        break;
  278.  
  279.             /* Pass    through    unhandled messages        */
  280.    default :
  281.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  282.    }
  283. return(0L);
  284. }
  285. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  286. #pragma    page( )
  287.  
  288. /* --- ViewBITMAPINFOHEADER2DlgProc -------------------- [ Public ] ---    */
  289. /*                                    */
  290. /*     This function is    used to    process    the messages for the dialog    */
  291. /*     procedure.                            */
  292. /*                                    */
  293. /*     Upon Entry:                            */
  294. /*                                    */
  295. /*     HWND   hWnd; = Dialog Window Handle                */
  296. /*     ULONG  msg;  = PM Message                    */
  297. /*     MPARAM mp1;  = Message Parameter    1                */
  298. /*     MPARAM mp2;  = Message Parameter    2                */
  299. /*                                    */
  300. /*     Upon Exit:                            */
  301. /*                                    */
  302. /*     ViewBITMAPINFOHEADER2DlgProc = Message Handling Result        */
  303. /*                                    */
  304. /* --------------------------------------------------------------------    */
  305.  
  306. MRESULT    EXPENTRY ViewBITMAPINFOHEADER2DlgProc(HWND hWnd, ULONG msg, MPARAM mp1,     MPARAM    mp2)
  307.  
  308. {
  309. CHAR           szNumber[32];   /* Numeric Buffer            */
  310. PBITMAPINFOHEADER2 pbmp2;       /* Bitmap Info Pointer        */
  311. PSZ           pszType;       /* Type String Pointer        */
  312.  
  313. switch ( msg )
  314.    {
  315.  
  316. /************************************************************************/
  317. /* Perform dialog initialization                    */
  318. /************************************************************************/
  319.  
  320.    case    WM_INITDLG :
  321.        pbmp2 = (PBITMAPINFOHEADER2)PVOIDFROMMP(mp2);
  322.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)iBitmapSelected, szNumber, 10));
  323.        WinSetDlgItemText(hWnd, IT_CBFIX,     _ltoa((LONG)pbmp2->cbFix, szNumber, 10));
  324.        WinSetDlgItemText(hWnd, IT_CX,         _ltoa((LONG)pbmp2->cx, szNumber, 10));
  325.        WinSetDlgItemText(hWnd, IT_CY,         _ltoa((LONG)pbmp2->cy, szNumber, 10));
  326.        WinSetDlgItemText(hWnd, IT_CPLANES,   _ltoa((LONG)pbmp2->cPlanes, szNumber, 10));
  327.        WinSetDlgItemText(hWnd, IT_CBITCOUNT, _ltoa((LONG)pbmp2->cBitCount, szNumber, 10));
  328.  
  329.        switch (    pbmp2->ulCompression )
  330.        {
  331.        case    BCA_UNCOMP :
  332.            pszType = "BCA_UNCOMP";
  333.            break;
  334.  
  335.        case    BCA_HUFFMAN1D :
  336.            pszType = "BCA_HUFFMAN1D";
  337.            break;
  338.  
  339.        case    BCA_RLE4 :
  340.            pszType = "BCA_RLE4";
  341.            break;
  342.  
  343.        case    BCA_RLE8 :
  344.            pszType = "BCA_RLE8";
  345.            break;
  346.  
  347.        case    BCA_RLE24 :
  348.            pszType = "BCA_RLE24";
  349.            break;
  350.  
  351.        default :
  352.            pszType = "Unknown";
  353.            break;
  354.        }
  355.        WinSetDlgItemText(hWnd, IT_ULCOMPRESSION, pszType);
  356.        WinSetDlgItemText(hWnd, IT_CBIMAGE,       _ltoa((LONG)pbmp2->cbImage, szNumber, 10));
  357.        WinSetDlgItemText(hWnd, IT_CXRESOLUTION,       _ltoa((LONG)pbmp2->cxResolution, szNumber, 10));
  358.        WinSetDlgItemText(hWnd, IT_CYRESOLUTION,       _ltoa((LONG)pbmp2->cyResolution, szNumber, 10));
  359.        WinSetDlgItemText(hWnd, IT_CCLRUSED,       _ltoa((LONG)pbmp2->cclrUsed,    szNumber, 10));
  360.        WinSetDlgItemText(hWnd, IT_CCLRIMPORTANT,   _ltoa((LONG)pbmp2->cclrImportant, szNumber, 10));
  361.  
  362.        switch (    pbmp2->usUnits )
  363.        {
  364.        case    BRU_METRIC :
  365.            pszType = "BRU_METRIC";
  366.            break;
  367.  
  368.        default :
  369.            pszType = "Unknown";
  370.            break;
  371.        }
  372.        WinSetDlgItemText(hWnd, IT_USUNITS,       pszType);
  373.        WinSetDlgItemText(hWnd, IT_USRESERVED,       _ltoa((LONG)pbmp2->usReserved, szNumber, 10));
  374.  
  375.        switch (    pbmp2->usRecording )
  376.        {
  377.        case    BRA_BOTTOMUP :
  378.            pszType = "BRA_BOTTOMUP";
  379.            break;
  380.  
  381.        default :
  382.            pszType = "Unknown";
  383.            break;
  384.        }
  385.        WinSetDlgItemText(hWnd, IT_USRECORDING,       pszType);
  386.        switch (    pbmp2->usRendering )
  387.        {
  388.        case    BRH_NOTHALFTONED :
  389.            pszType = "BRH_NOTHALFTONED";
  390.            break;
  391.  
  392.        case    BRH_ERRORDIFFUSION :
  393.            pszType = "BRH_ERRORDIFFUSION";
  394.            break;
  395.  
  396.        case    BRH_PANDA :
  397.            pszType = "BRH_PANDA";
  398.            break;
  399.  
  400.        case    BRH_SUPERCIRCLE    :
  401.            pszType = "BRH_SUPERCIRCLE";
  402.            break;
  403.  
  404.        default :
  405.            pszType = "Unknown";
  406.            break;
  407.        }
  408.        WinSetDlgItemText(hWnd, IT_USRENDERING,       pszType);
  409.        WinSetDlgItemText(hWnd, IT_CSIZE1,       _ltoa((LONG)pbmp2->cSize1, szNumber,    10));
  410.        WinSetDlgItemText(hWnd, IT_CSIZE2,       _ltoa((LONG)pbmp2->cSize2, szNumber,    10));
  411.        switch (    pbmp2->ulColorEncoding )
  412.        {
  413.        case    BCE_PALETTE :
  414.            pszType = "BCE_PALETTE";
  415.            break;
  416.  
  417.        case    BCE_RGB    :
  418.            pszType = "BCE_RGB";
  419.            break;
  420.  
  421.        case    BRH_PANDA :
  422.            pszType = "BRH_PANDA";
  423.            break;
  424.  
  425.        case    BRH_SUPERCIRCLE    :
  426.            pszType = "BRH_SUPERCIRCLE";
  427.            break;
  428.  
  429.        default :
  430.            pszType = "Unknown";
  431.            break;
  432.        }
  433.        WinSetDlgItemText(hWnd, IT_ULCOLORENCODING, pszType);
  434.        WinSetDlgItemText(hWnd, IT_ULIDENTIFIER,       _ltoa((LONG)pbmp2->ulIdentifier, szNumber, 10));
  435.        break;
  436.  
  437. /************************************************************************/
  438. /* Process push    button selections                    */
  439. /************************************************************************/
  440.  
  441.    case    WM_COMMAND :
  442.        switch (    SHORT1FROMMP(mp1) )
  443.        {
  444.        case    DID_OK :
  445.            WinDismissDlg(hWnd, TRUE);
  446.            break;
  447.        }
  448.        break;
  449.  
  450. /************************************************************************/
  451. /* Close requested, exit dialogue                    */
  452. /************************************************************************/
  453.  
  454.    case    WM_CLOSE :
  455.        WinDismissDlg(hWnd, FALSE);
  456.        break;
  457.  
  458.             /* Pass    through    unhandled messages        */
  459.    default :
  460.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  461.    }
  462. return(0L);
  463. }
  464. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  465. #pragma    page( )
  466.  
  467. /* --- ViewBITMAPARRAYFILEHEADERDlgProc    ---------------- [ Public ] ---    */
  468. /*                                    */
  469. /*     This function is    used to    process    the messages for the dialog    */
  470. /*     procedure.                            */
  471. /*                                    */
  472. /*     Upon Entry:                            */
  473. /*                                    */
  474. /*     HWND   hWnd; = Dialog Window Handle                */
  475. /*     ULONG  msg;  = PM Message                    */
  476. /*     MPARAM mp1;  = Message Parameter    1                */
  477. /*     MPARAM mp2;  = Message Parameter    2                */
  478. /*                                    */
  479. /*     Upon Exit:                            */
  480. /*                                    */
  481. /*     ViewBITMAPARRAYFILEHEADERDlgProc    = Message Handling Result    */
  482. /*                                    */
  483. /* --------------------------------------------------------------------    */
  484.  
  485. MRESULT    EXPENTRY ViewBITMAPARRAYFILEHEADERDlgProc(HWND hWnd, ULONG msg,    MPARAM mp1, MPARAM mp2)
  486.  
  487. {
  488. CHAR               szNumber[32];   /* Numeric Buffer        */
  489. PBITMAPARRAYFILEHEADER pbafh;      /* Bitmap Array File Header Pointer  */
  490. PSZ               pszType;       /* Type String Pointer        */
  491. register INT i;               /* Index                */
  492.  
  493. switch ( msg )
  494.    {
  495.  
  496. /************************************************************************/
  497. /* Perform dialog initialization                    */
  498. /************************************************************************/
  499.  
  500.    case    WM_INITDLG :
  501.        pbafh = (PBITMAPARRAYFILEHEADER)abm[i = LONGFROMMP(mp2)].pb;
  502.        switch (    pbafh->usType )
  503.        {
  504.        case    BFT_ICON :
  505.            pszType = "BFT_ICON";
  506.            break;
  507.  
  508.       case BFT_BMAP    :
  509.            pszType = "BFT_BMAP";
  510.            break;
  511.  
  512.        case    BFT_POINTER :
  513.            pszType = "BFT_POINTER";
  514.            break;
  515.  
  516.        case    BFT_COLORICON :
  517.            pszType = "BFT_COLORICON";
  518.            break;
  519.  
  520.        case    BFT_COLORPOINTER :
  521.            pszType = "BFT_COLORPOINTER";
  522.            break;
  523.  
  524.        case    BFT_BITMAPARRAY    :
  525.            pszType = "BFT_BITMAPARRAY";
  526.            break;
  527.  
  528.        default :
  529.            pszType = "Unknown";
  530.            break;
  531.        }
  532.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)i, szNumber,    10));
  533.        WinSetDlgItemText(hWnd, IT_USTYPE,    pszType);
  534.        WinSetDlgItemText(hWnd, IT_CBSIZE,    _ltoa((LONG)pbafh->cbSize,    szNumber, 10));
  535.        WinSetDlgItemText(hWnd, IT_OFFNEXT,   _ltoa((LONG)pbafh->offNext, szNumber, 10));
  536.        WinSetDlgItemText(hWnd, IT_CXDISPLAY, _ltoa((LONG)pbafh->cxDisplay, szNumber, 10));
  537.        WinSetDlgItemText(hWnd, IT_CYDISPLAY, _ltoa((LONG)pbafh->cyDisplay, szNumber, 10));
  538.        break;
  539.  
  540. /************************************************************************/
  541. /* Process push    button selections                    */
  542. /************************************************************************/
  543.  
  544.    case    WM_COMMAND :
  545.        switch (    SHORT1FROMMP(mp1) )
  546.        {
  547.        case    DID_OK :
  548.            WinDismissDlg(hWnd, TRUE);
  549.            break;
  550.        }
  551.        break;
  552.  
  553. /************************************************************************/
  554. /* Close requested, exit dialogue                    */
  555. /************************************************************************/
  556.  
  557.    case    WM_CLOSE :
  558.        WinDismissDlg(hWnd, FALSE);
  559.        break;
  560.  
  561.             /* Pass    through    unhandled messages        */
  562.    default :
  563.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  564.    }
  565. return(0L);
  566. }
  567. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  568. #pragma    page( )
  569.  
  570. /* --- ViewBITMAPFILEHEADERDlgProc --------------------- [ Public ] ---    */
  571. /*                                    */
  572. /*     This function is    used to    process    the messages for the dialog    */
  573. /*     procedure.                            */
  574. /*                                    */
  575. /*     Upon Entry:                            */
  576. /*                                    */
  577. /*     HWND   hWnd; = Dialog Window Handle                */
  578. /*     ULONG  msg;  = PM Message                    */
  579. /*     MPARAM mp1;  = Message Parameter    1                */
  580. /*     MPARAM mp2;  = Message Parameter    2                */
  581. /*                                    */
  582. /*     Upon Exit:                            */
  583. /*                                    */
  584. /*     ViewBITMAPFILEHEADERDlgProc = Message Handling Result        */
  585. /*                                    */
  586. /* --------------------------------------------------------------------    */
  587.  
  588. MRESULT    EXPENTRY ViewBITMAPFILEHEADERDlgProc(HWND hWnd,    ULONG msg, MPARAM mp1, MPARAM mp2)
  589.  
  590. {
  591. CHAR          szNumber[32];       /* Numeric Buffer            */
  592. PBITMAPFILEHEADER pbfh;           /* Bitmap Array File    Header Pointer    */
  593. PSZ          pszType;       /* Type String Pointer        */
  594.  
  595. switch ( msg )
  596.    {
  597.  
  598. /************************************************************************/
  599. /* Perform dialog initialization                    */
  600. /************************************************************************/
  601.  
  602.    case    WM_INITDLG :
  603.        pbfh = (PBITMAPFILEHEADER)PVOIDFROMMP(mp2);
  604.        switch (    pbfh->usType )
  605.        {
  606.        case    BFT_ICON :
  607.            pszType = "BFT_ICON";
  608.            break;
  609.  
  610.       case BFT_BMAP    :
  611.            pszType = "BFT_BMAP";
  612.            break;
  613.  
  614.        case    BFT_POINTER :
  615.            pszType = "BFT_POINTER";
  616.            break;
  617.  
  618.        case    BFT_COLORICON :
  619.            pszType = "BFT_COLORICON";
  620.            break;
  621.  
  622.        case    BFT_COLORPOINTER :
  623.            pszType = "BFT_COLORPOINTER";
  624.            break;
  625.  
  626.        case    BFT_BITMAPARRAY    :
  627.            pszType = "BFT_BITMAPARRAY";
  628.            break;
  629.  
  630.        default :
  631.            pszType = "Unknown";
  632.            break;
  633.        }
  634.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)iBitmapSelected, szNumber, 10));
  635.        WinSetDlgItemText(hWnd, IT_USTYPE,   pszType);
  636.        WinSetDlgItemText(hWnd, IT_CBSIZE,   _ltoa((LONG)pbfh->cbSize, szNumber,    10));
  637.        WinSetDlgItemText(hWnd, IT_XHOTSPOT, _ltoa((LONG)pbfh->xHotspot,    szNumber, 10));
  638.        WinSetDlgItemText(hWnd, IT_YHOTSPOT, _ltoa((LONG)pbfh->yHotspot,    szNumber, 10));
  639.        WinSetDlgItemText(hWnd, IT_OFFBITS,  _ltoa((LONG)pbfh->offBits, szNumber, 10));
  640.        break;
  641.  
  642. /************************************************************************/
  643. /* Process push    button selections                    */
  644. /************************************************************************/
  645.  
  646.    case    WM_COMMAND :
  647.        switch (    SHORT1FROMMP(mp1) )
  648.        {
  649.        case    DID_OK :
  650.            WinDismissDlg(hWnd, TRUE);
  651.            break;
  652.        }
  653.        break;
  654.  
  655. /************************************************************************/
  656. /* Close requested, exit dialogue                    */
  657. /************************************************************************/
  658.  
  659.    case    WM_CLOSE :
  660.        WinDismissDlg(hWnd, FALSE);
  661.        break;
  662.  
  663.             /* Pass    through    unhandled messages        */
  664.    default :
  665.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  666.    }
  667. return(0L);
  668. }
  669. #pragma    subtitle("   Module Purpose - Dialog Procedure")
  670. #pragma    page( )
  671.  
  672. /* --- ViewBITMAPINFOHEADERDlgProc --------------------- [ Public ] ---    */
  673. /*                                    */
  674. /*     This function is    used to    process    the messages for the dialog    */
  675. /*     procedure.                            */
  676. /*                                    */
  677. /*     Upon Entry:                            */
  678. /*                                    */
  679. /*     HWND   hWnd; = Dialog Window Handle                */
  680. /*     ULONG  msg;  = PM Message                    */
  681. /*     MPARAM mp1;  = Message Parameter    1                */
  682. /*     MPARAM mp2;  = Message Parameter    2                */
  683. /*                                    */
  684. /*     Upon Exit:                            */
  685. /*                                    */
  686. /*     ViewBITMAPINFOHEADERDlgProc = Message Handling Result        */
  687. /*                                    */
  688. /* --------------------------------------------------------------------    */
  689.  
  690. MRESULT    EXPENTRY ViewBITMAPINFOHEADERDlgProc(HWND hWnd,    ULONG msg, MPARAM mp1,    MPARAM mp2)
  691.  
  692. {
  693. CHAR          szNumber[32];       /* Numeric Buffer            */
  694. PBITMAPINFOHEADER pbmp;           /* Bitmap Info Pointer        */
  695.  
  696. switch ( msg )
  697.    {
  698.  
  699. /************************************************************************/
  700. /* Perform dialog initialization                    */
  701. /************************************************************************/
  702.  
  703.    case    WM_INITDLG :
  704.        pbmp = (PBITMAPINFOHEADER)PVOIDFROMMP(mp2);
  705.        WinSetDlgItemText(hWnd, IT_BITMAPINDEX, _ltoa((LONG)iBitmapSelected, szNumber, 10));
  706.        WinSetDlgItemText(hWnd, IT_CBFIX,     _ltoa((LONG)pbmp->cbFix, szNumber,    10));
  707.        WinSetDlgItemText(hWnd, IT_CX,         _ltoa((LONG)pbmp->cx, szNumber, 10));
  708.        WinSetDlgItemText(hWnd, IT_CY,         _ltoa((LONG)pbmp->cy, szNumber, 10));
  709.        WinSetDlgItemText(hWnd, IT_CPLANES,   _ltoa((LONG)pbmp->cPlanes,    szNumber, 10));
  710.        WinSetDlgItemText(hWnd, IT_CBITCOUNT, _ltoa((LONG)pbmp->cBitCount, szNumber, 10));
  711.        break;
  712.  
  713. /************************************************************************/
  714. /* Process push    button selections                    */
  715. /************************************************************************/
  716.  
  717.    case    WM_COMMAND :
  718.        switch (    SHORT1FROMMP(mp1) )
  719.        {
  720.        case    DID_OK :
  721.            WinDismissDlg(hWnd, TRUE);
  722.            break;
  723.        }
  724.        break;
  725.  
  726. /************************************************************************/
  727. /* Close requested, exit dialogue                    */
  728. /************************************************************************/
  729.  
  730.    case    WM_CLOSE :
  731.        WinDismissDlg(hWnd, FALSE);
  732.        break;
  733.  
  734.             /* Pass    through    unhandled messages        */
  735.    default :
  736.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  737.    }
  738. return(0L);
  739. }
  740. #pragma    subtitle("   View Dialogues - RGB Table Value Set Function")
  741. #pragma    page( )
  742.  
  743. /* --- SetTableValues ---------------------------------    [ Private ] ---    */
  744. /*                                    */
  745. /*     This function is    used to    set the    values for the RGB table    */
  746. /*     within the RGB dialogue.                        */
  747. /*                                    */
  748. /*     Upon Entry:                            */
  749. /*                                    */
  750. /*     HWND   hWnd; = Dialog Window Handle                */
  751. /*                                    */
  752. /*     Upon Exit:                            */
  753. /*                                    */
  754. /*     Nothing                                */
  755. /*                                    */
  756. /* --------------------------------------------------------------------    */
  757.  
  758. static VOID SetTableValues(HWND    hWnd)
  759.  
  760. {
  761. CHAR   szColour[32];           /* Numeric Value            */
  762. CHAR   szIndex[32];           /* Numeric Value            */
  763. LONG   cShown;               /* Number of    Colours    Shown        */
  764. PULONG pul;               /* Long Pointer            */
  765. register INT i,    n;           /* Loop Counter            */
  766.  
  767.                /* Check    to see if the table only contains 2    */
  768.                /* colours in which case    only need to update    */
  769.                /* 2 colours                    */
  770.  
  771. if ( abm[iBitmapSelected].cColours == 2    )
  772.    cShown = 2;
  773. else
  774.    cShown = 16;
  775.  
  776. for ( i    = lVScrollPos, n = 0; n    < cShown; i++, n++ )
  777.    {
  778.    sprintf(szIndex, "RGB[%3d] =", i);
  779.    if (    f20Bitmap )
  780.        {
  781.        pul = (PULONG)(PVOID)&prgb2[i];
  782.        sprintf(szColour, "0x%08X", *pul);
  783.        }
  784.    else
  785.        sprintf(szColour, "0x00%02X%02X%02X", prgb[i].bRed, prgb[i].bGreen, prgb[i].bBlue);
  786.    WinSetDlgItemText(hWnd, (ULONG)(IT_INDEX00 +    n), szIndex);
  787.    WinSetDlgItemText(hWnd, (ULONG)(EF_INDEX00 +    n), szColour);
  788.    }
  789. }
  790. #pragma    subtitle("   View Dialogues - RGB Table Query Function")
  791. #pragma    page( )
  792.  
  793. /* --- QueryTableValues    -------------------------------- [ Public ] ---    */
  794. /*                                    */
  795. /*     This function is    used to    get the    values from the    RGB table    */
  796. /*     within the RGB dialogue.                        */
  797. /*                                    */
  798. /*     Upon Entry:                            */
  799. /*                                    */
  800. /*     HWND   hWnd; = Dialog Window Handle                */
  801. /*                                    */
  802. /*     Upon Exit:                            */
  803. /*                                    */
  804. /*     Nothing                                */
  805. /*                                    */
  806. /* --------------------------------------------------------------------    */
  807.  
  808. static VOID QueryTableValues(HWND hWnd)
  809.  
  810. {
  811. CHAR   szColour[32];           /* Numeric Value            */
  812. LONG   cShown;               /* Number of    Colours    Shown        */
  813. PULONG pul;               /* Long Pointer            */
  814. ULONG  ulColour;           /* Colour Value            */
  815. register INT i,    n;           /* Loop Counter            */
  816.  
  817.                /* Check    to see if the table only contains 2    */
  818.                /* colours in which case    only need to query    */
  819.                /* 2 colours                    */
  820.  
  821. if ( abm[iBitmapSelected].cColours == 2    )
  822.    cShown = 2;
  823. else
  824.    cShown = 16;
  825.  
  826. for ( i    = lVScrollPos, n = 0; n    < cShown; i++, n++ )
  827.    {
  828.    WinQueryDlgItemText(hWnd, (ULONG)(EF_INDEX00    + n), 11L, szColour);
  829.    ulColour = (ULONG)strtoul(szColour, NULL, 0);
  830.    if (    f20Bitmap )
  831.        {
  832.        pul = (PULONG)(PVOID)&prgb2[i];
  833.        *pul = ulColour;
  834.        }
  835.    else
  836.        {
  837.        prgb[i].bRed   =    (BYTE)((ulColour & 0x00ff0000UL) >> 16);
  838.        prgb[i].bGreen =    (BYTE)((ulColour & 0x0000ff00UL) >> 8);
  839.        prgb[i].bBlue  =    (BYTE)(ulColour    & 0x000000ffUL);
  840.        }
  841.    }
  842. }
  843. #pragma    subtitle("   View Dialogues - View Colour RGB Colour Table Procedure")
  844. #pragma    page( )
  845.  
  846. /* --- ViewColourTableDlgProc -------------------------- [ Public ] ---    */
  847. /*                                    */
  848. /*     This function is    used to    process    the messages for the View    */
  849. /*     RGB Colour Table    dialogue.                    */
  850. /*                                    */
  851. /*     Upon Entry:                            */
  852. /*                                    */
  853. /*     HWND   hWnd; = Dialog Window Handle                */
  854. /*     ULONG  msg;  = PM Message                    */
  855. /*     MPARAM mp1;  = Message Parameter    1                */
  856. /*     MPARAM mp2;  = Message Parameter    2                */
  857. /*                                    */
  858. /*     Upon Exit:                            */
  859. /*                                    */
  860. /*     ViewColourTableDlgProc =    Message    Handling Result            */
  861. /*                                    */
  862. /* --------------------------------------------------------------------    */
  863.  
  864. MRESULT    EXPENTRY ViewColourTableDlgProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  865.  
  866. {
  867. BOOL   fUpdate;               /* Table Updated Flag        */
  868.  
  869. switch ( msg )
  870.    {
  871.  
  872. /************************************************************************/
  873. /* Perform dialog initialization                    */
  874. /************************************************************************/
  875.  
  876.    case    WM_INITDLG :
  877.        lVScrollPos = 0L;
  878.        if ( f20Bitmap )
  879.        memcpy(prgb2    = (RGB2    *)malloc(abm[iBitmapSelected].cColours * sizeof(RGB2)),
  880.           pbTable = (PBYTE)PVOIDFROMMP(mp2), abm[iBitmapSelected].cColours * sizeof(RGB2));
  881.        else
  882.        memcpy(prgb = (RGB *)malloc(abm[iBitmapSelected].cColours * sizeof(RGB)),
  883.           pbTable = (PBYTE)PVOIDFROMMP(mp2), abm[iBitmapSelected].cColours * sizeof(RGB));
  884.  
  885.        if ( abm[iBitmapSelected].cColours == 16L )
  886.        WinDestroyWindow(WinWindowFromID(hWnd, SB_INDEX));
  887.  
  888.        SetTableValues(hWnd);
  889.        break;
  890.  
  891. /************************************************************************/
  892. /* Process push    button selections                    */
  893. /************************************************************************/
  894.  
  895.    case    WM_COMMAND :
  896.        switch (    SHORT1FROMMP(mp1) )
  897.        {
  898.        case    DID_OK :
  899.            QueryTableValues(hWnd);
  900.            if ( f20Bitmap )
  901.            {
  902.            if (    memcmp(prgb2, pbTable, abm[iBitmapSelected].cColours * sizeof(RGB2)) )
  903.                {
  904.                memcpy(pbTable, prgb2, abm[iBitmapSelected].cColours * sizeof(RGB2));
  905.                fUpdate = TRUE;
  906.                }
  907.            else
  908.                fUpdate = FALSE;
  909.            free(prgb2);
  910.            }
  911.            else
  912.            {
  913.            if (    memcmp(prgb, pbTable, abm[iBitmapSelected].cColours * sizeof(RGB)) )
  914.                {
  915.                memcpy(pbTable, prgb, abm[iBitmapSelected].cColours * sizeof(RGB));
  916.                fUpdate = TRUE;
  917.                }
  918.            else
  919.                fUpdate = FALSE;
  920.            free(prgb);
  921.            }
  922.            WinDismissDlg(hWnd, fUpdate);
  923.            break;
  924.        }
  925.        break;
  926.  
  927. /************************************************************************/
  928. /* Vertical Scroll bar selected                        */
  929. /************************************************************************/
  930.  
  931.    case    WM_VSCROLL :
  932.        QueryTableValues(hWnd);
  933.        switch (    HIUSHORT(mp2) )
  934.        {
  935.        case    SB_LINEUP :
  936.            lVScrollPos--;
  937.            break;
  938.  
  939.        case    SB_LINEDOWN :
  940.            lVScrollPos++;
  941.            break;
  942.  
  943.        case    SB_PAGEUP :
  944.            lVScrollPos -= 16L;
  945.            break;
  946.  
  947.        case    SB_PAGEDOWN :
  948.            lVScrollPos += 16L;
  949.            break;
  950.  
  951.        case    SB_SLIDERPOSITION :
  952.            lVScrollPos = SHORT1FROMMP(mp2);
  953.            break;
  954.  
  955.        default :
  956.            return(0L);
  957.        }
  958.                /* Reposition slider in scroll bar        */
  959.  
  960.        WinSendDlgItemMsg(hWnd, SB_INDEX, SBM_SETPOS, MPFROM2SHORT(lVScrollPos =    max(0, min(lVScrollPos,    240)), 0), 0L);
  961.        SetTableValues(hWnd);
  962.        break;
  963.  
  964. /************************************************************************/
  965. /* Close requested, exit dialogue                    */
  966. /************************************************************************/
  967.  
  968.    case    WM_CLOSE :
  969.        WinDismissDlg(hWnd, FALSE);
  970.        break;
  971.  
  972.             /* Pass    through    unhandled messages        */
  973.    default :
  974.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  975.    }
  976. return(0L);
  977. }
  978. #pragma    subtitle("   View Dialogues  - View System Info Procedure")
  979. #pragma    page( )
  980.  
  981. /* --- ViewSystemBitmapInfoDlgProc --------------------- [ Public ] ---    */
  982. /*                                    */
  983. /*     This function is    used to    process    the messages for the dialog    */
  984. /*     procedure.                            */
  985. /*                                    */
  986. /*     Upon Entry:                            */
  987. /*                                    */
  988. /*     HWND   hWnd; = Dialog Window Handle                */
  989. /*     ULONG  msg;  = PM Message                    */
  990. /*     MPARAM mp1;  = Message Parameter    1                */
  991. /*     MPARAM mp2;  = Message Parameter    2                */
  992. /*                                    */
  993. /*     Upon Exit:                            */
  994. /*                                    */
  995. /*     ViewSystemBitmapInfoDlgProc = Message Handling Result        */
  996. /*                                    */
  997. /* --------------------------------------------------------------------    */
  998.  
  999. MRESULT    EXPENTRY ViewSystemBitmapInfoDlgProc(HWND hWnd,    ULONG msg, MPARAM mp1,    MPARAM mp2)
  1000.  
  1001. {
  1002. CHAR szNumber[32];           /* Numeric Buffer            */
  1003. LONG alCaps[25];           /* Caps Info    Array            */
  1004.  
  1005. switch ( msg )
  1006.    {
  1007.  
  1008. /************************************************************************/
  1009. /* Perform dialog initialization                    */
  1010. /************************************************************************/
  1011.  
  1012.    case    WM_INITDLG :
  1013.        DevQueryCaps(WinOpenWindowDC(hWnd), CAPS_FAMILY,    25L, alCaps);
  1014.        WinSetDlgItemText(hWnd, IT_CXSCREEN,       _ltoa(alCaps[CAPS_WIDTH], szNumber, 10));
  1015.        WinSetDlgItemText(hWnd, IT_CYSCREEN,       _ltoa(alCaps[CAPS_HEIGHT], szNumber,    10));
  1016.        WinSetDlgItemText(hWnd, IT_HORZRESOLUTION,  _ltoa(alCaps[CAPS_HORIZONTAL_RESOLUTION], szNumber, 10));
  1017.        WinSetDlgItemText(hWnd, IT_VERTRESOLUTION,  _ltoa(alCaps[CAPS_VERTICAL_RESOLUTION], szNumber, 10));
  1018.        WinSetDlgItemText(hWnd, IT_PLANES,       _ltoa(alCaps[CAPS_COLOR_PLANES], szNumber, 10));
  1019.        WinSetDlgItemText(hWnd, IT_DISTINCTCOLOURS, _ltoa(alCaps[CAPS_COLORS], szNumber,    10));
  1020.        WinSetDlgItemText(hWnd, IT_BITCOUNT,       _ltoa(alCaps[CAPS_COLOR_BITCOUNT], szNumber,    10));
  1021.        WinSetDlgItemText(hWnd, IT_BITMAPFORMATS,   _ltoa(alCaps[CAPS_BITMAP_FORMATS], szNumber,    10));
  1022.  
  1023.        if ( alCaps[CAPS_RASTER_CAPS] & CAPS_RASTER_BITBLT )
  1024.        WinSetDlgItemText(hWnd, IT_BITBLT, "Yes");
  1025.        if ( alCaps[CAPS_RASTER_CAPS] & CAPS_RASTER_BANDING )
  1026.        WinSetDlgItemText(hWnd, IT_BANDING, "Yes");
  1027.        if ( alCaps[CAPS_RASTER_CAPS] & CAPS_RASTER_BITBLT_SCALING )
  1028.        WinSetDlgItemText(hWnd, IT_BITBLTSCALING, "Yes");
  1029.        break;
  1030.  
  1031. /************************************************************************/
  1032. /* Process push    button selections                    */
  1033. /************************************************************************/
  1034.  
  1035.    case    WM_COMMAND :
  1036.        switch (    SHORT1FROMMP(mp1) )
  1037.        {
  1038.        case    DID_OK :
  1039.            WinDismissDlg(hWnd, TRUE);
  1040.            break;
  1041.        }
  1042.        break;
  1043.  
  1044. /************************************************************************/
  1045. /* Close requested, exit dialogue                    */
  1046. /************************************************************************/
  1047.  
  1048.    case    WM_CLOSE :
  1049.        WinDismissDlg(hWnd, FALSE);
  1050.        break;
  1051.  
  1052.             /* Pass    through    unhandled messages        */
  1053.    default :
  1054.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  1055.    }
  1056. return(0L);
  1057. }
  1058.