home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / SAMPLES / SHOWDIB / SHOWDIB.H_ / SHOWDIB.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  8.6 KB  |  203 lines

  1. /****************************************************************************
  2.  *                                      *
  3.  *  FILE    : SHOWDIB.H                         *
  4.  *                                      *
  5.  *  DESCRIPTION : Header/include file for ShowDIB example.          *
  6.  *                                      *
  7.  ****************************************************************************/
  8.  
  9. #include "resource.h"
  10.  
  11. /* Macro to restrict a given value to an upper or lower boundary value */
  12. #define BOUND(x,min,max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
  13.  
  14. /* Macro to swap two values */
  15. #define SWAP(x,y)   ((x)^=(y)^=(x)^=(y))
  16.  
  17. /* Macro to find the minimum of two values */
  18. #define MIN(x,y) (((x) <= (y)) : x ? y)
  19.  
  20. /* Macros to display/remove hourglass cursor for lengthy operations */
  21. #define StartWait() hcurSave = SetCursor(LoadCursor(NULL,IDC_WAIT))
  22. #define EndWait()   SetCursor(hcurSave)
  23.  
  24. #define MINBAND     50     /* Minimum band size used by the program */
  25. #define BANDINCREMENT   20     /* Decrement for band size while trying  */
  26.                    /* to determine optimum band size.   */
  27.  
  28. /* Bit values for the DIB attributes flag (fFileOptions). Also used as control
  29.  * IDs for the radiobuttons for DIB bitcount in the File/Open dialog
  30.  */
  31. #define F_1BPP      DLGOPEN_1BPP
  32. #define F_4BPP      DLGOPEN_4BPP
  33. #define F_8BPP      DLGOPEN_8BPP
  34. #define F_24BPP     DLGOPEN_24BPP
  35.  
  36. /* Bit values for the DIB attributes flag (fFileOptions), also used as control
  37.  * IDs for the radiobuttons for DIB compression type in the File/Open dialog
  38.  */
  39. #define F_RLE4      DLGOPEN_RLE4
  40. #define F_RLE8      DLGOPEN_RLE8
  41. #define F_RGB       DLGOPEN_RGB
  42.  
  43. /* flags for _lseek */
  44. #define  SEEK_CUR 1
  45. #define  SEEK_END 2
  46. #define  SEEK_SET 0
  47.  
  48. /* struct to be passed in for the SETDIBSCALING printer escape */
  49. typedef struct {
  50.     short ScaleMode;
  51.     short dx, dy;
  52. } DIBPARAMS;
  53.  
  54. extern HWND hWndApp;               /* The handle to the app. window     */
  55.  
  56. #define MAXREAD  32768             /* Number of bytes to be read during */
  57.                        /* each read operation.          */
  58.  
  59. /* Header signatutes for various resources */
  60. #define BFT_ICON   0x4349   /* 'IC' */
  61. #define BFT_BITMAP 0x4d42   /* 'BM' */
  62. #define BFT_CURSOR 0x5450   /* 'PT' */
  63.  
  64. /* macro to determine if resource is a DIB */
  65. #define ISDIB(bft) ((bft) == BFT_BITMAP)
  66.  
  67. /* Macro to align given value to the closest DWORD (unsigned long ) */
  68. #define ALIGNULONG(i)   ((i+3)/4*4)
  69.  
  70. /* Macro to determine to round off the given value to the closest byte */
  71. #define WIDTHBYTES(i)   ((i+31)/32*4)
  72.  
  73. #define PALVERSION      0x300
  74. #define MAXPALETTE  256   /* max. # supported palette entries */
  75.  
  76. /********** THE FOLLOWING ARE USED IN DLGOPEN.C  ************************/
  77.  
  78.  
  79. #define DLGOPEN_OPTION          0xF000
  80. #define DLGOPEN_1BPP        0x0001
  81. #define DLGOPEN_4BPP        0x0002
  82. #define DLGOPEN_8BPP        0x0004
  83. #define DLGOPEN_24BPP       0x0008
  84. #define DLGOPEN_RLE4        0x0010
  85. #define DLGOPEN_RLE8        0x0020
  86. #define DLGOPEN_RGB     0x0040
  87.  
  88. #define DLGOPEN_OPTION8         0x0080
  89.  
  90. /*  flags:
  91.  *     The LOWORD is the standard FileOpen() flags (OF_*)
  92.  *     the HIWORD can be any of the following:
  93.  */
  94. #define OF_MUSTEXIST    0x00010000  /* file must exist if the user hits Ok    */
  95. #define OF_NOSHOWSPEC   0x00020000  /* DO NOT Show search spec in the edit box*/
  96. #define OF_SHOWSPEC 0x00000000  /* Show the search spec in the edit box   */
  97. #define OF_SAVE     0x00040000  /* Ok button will say "Save"          */
  98. #define OF_OPEN     0x00080000  /* Ok button will say "Open"          */
  99. #define OF_NOOPTIONS    0x00100000  /* Disable the options fold out       */
  100.  
  101. /* Attributes for DlgDirLst() */
  102. #define ATTRFILELIST    0x0000        /* include files only      */
  103. #define ATTRDIRLIST 0xC010        /* directories and drives ONLY */
  104. #define CBEXTMAX    6         /* Number of bytes in "\*.txt" */
  105.  
  106.  
  107. #define IDF(id)     ((id) & ~DLGOPEN_OPTION)  /* extracts flag from control ID */
  108. #define FID(f)      ((f)  |  DLGOPEN_OPTION)  /* extracts control ID from flag */
  109.  
  110. /***************** GLOBAL VARIABLES *************************/
  111.  
  112. extern char       achFileName[128]; /* File pathname               */
  113. extern DWORD          dwOffset;     /* Current position if DIB file pointer    */
  114. extern RECT       rcClip;       /* Current clip rectangle.             */
  115. extern BOOL       fPalColors;   /* TRUE if the current DIB's color table   */
  116.                     /* contains palette indexes not rgb values */
  117. extern BOOL       bDIBToDevice; /* Use SetDIBitsToDevice() to BLT data.    */
  118. extern BOOL       bLegitDraw;   /* We have a valid bitmap to draw          */
  119. extern WORD       wTransparent; /* Mode of DC                  */
  120. extern char       szAppName[];  /* App. name                   */
  121. extern HPALETTE       hpalCurrent;  /* Handle to current palette           */
  122. extern HANDLE         hdibCurrent;  /* Handle to current memory DIB        */
  123. extern HBITMAP        hbmCurrent;   /* Handle to current memory BITMAP         */
  124. extern HANDLE         hbiCurrent;   /* Handle to current bitmap info struct    */
  125. extern DWORD          dwStyle;      /* Style bits of the App. window           */
  126.  
  127. /***************** FUNCTION DECLARATIONS *******************/
  128.  
  129. DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul);
  130. DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul);
  131.  
  132. /***********************************************************/
  133. /* Declarations of functions used in showdib.c module      */
  134. /***********************************************************/
  135.  
  136. long    FAR PASCAL __export WndProc  (HWND, UINT, WPARAM, LPARAM) ;
  137. BOOL           MenuCommand (HWND hWnd, WORD wParam);
  138. int        InitDIB (HWND);
  139. void           FreeDib (void);
  140.  
  141. /***********************************************************/
  142. /* Declarations of functions used in dib.c module      */
  143. /***********************************************************/
  144.  
  145. HANDLE      OpenDIB (LPSTR szFile);
  146. BOOL        WriteDIB (LPSTR szFile,HANDLE hdib);
  147. WORD        PaletteSize (VOID FAR * pv);
  148. WORD        DibNumColors (VOID FAR * pv);
  149. HPALETTE    CreateDibPalette (HANDLE hdib);
  150. HPALETTE    CreateBIPalette (LPBITMAPINFOHEADER lpbi);
  151. HANDLE      DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
  152. HANDLE      BitmapFromDib (HANDLE hdib, HPALETTE hpal);
  153. BOOL        DibBlt (HDC hdc, int x0, int y0, int dx, int dy, HANDLE hdib, int x1, int y1, LONG rop);
  154. BOOL        StretchDibBlt (HDC hdc, int x0, int y0, int dx, int dy, HANDLE hdib, int x1, int y1, int dx1, int dy1, LONG rop);
  155. BOOL        DibInfo (HANDLE hdib,LPBITMAPINFOHEADER lpbi);
  156. HANDLE      ReadDibBitmapInfo (int fh);
  157. BOOL        DrawBitmap (HDC hdc, int x, int y, HBITMAP hbm, DWORD rop);
  158.  
  159. /***********************************************************/
  160. /* Declarations of functions used in drawdib. c module     */
  161. /***********************************************************/
  162.  
  163. void           PrintDIB (HWND hWnd, HDC hDC, int x, int y, int dx, int dy);
  164. void           AppPaint (HWND hWnd, HDC hDC, int x, int y);
  165. int        ErrMsg (PSTR sz,...);
  166. BOOL           fDialog (int id, HWND hwnd, FARPROC fpfn);
  167. void           BandDIB (HWND hWnd, HDC hDC, int x, int y);
  168. BOOL    FAR PASCAL __export AppAbout (HWND, unsigned, WORD, LONG) ;
  169. HANDLE         CopyHandle (HANDLE h);
  170. void           SizeWindow (HWND hWnd);
  171. void           GetRealClientRect (HWND hwnd, PRECT lprc);
  172. void           SetScrollRanges (HWND hwnd);
  173. void           DrawSelect (HDC hdc, BOOL fDraw);
  174. void        PASCAL NormalizeRect (RECT *prc);
  175. void           TrackMouse (HWND hwnd, POINT pt);
  176. HBITMAP        CopyBitmap (HBITMAP hbm);
  177. HPALETTE       CopyPalette (HPALETTE hpal);
  178. HBITMAP        CropBitmap (HBITMAP hbm, PRECT prc);
  179. HANDLE         RenderFormat (int cf);
  180. HANDLE         RealizeDibFormat (DWORD biStyle, WORD biBits);
  181.  
  182. /***********************************************************/
  183. /* Declarations of functions used in the print.c module    */
  184. /***********************************************************/
  185.  
  186. BOOL    PASCAL InitPrinting (HDC hDC, HWND hWnd, HANDLE hInst, LPSTR msg);
  187. void    PASCAL TermPrinting (HDC hDC);
  188. HDC PASCAL GetPrinterDC (void);
  189.  
  190. /***********************************************************/
  191. /* Declarations of functions used in the dlgopen.c module  */
  192. /***********************************************************/
  193.  
  194. int FAR PASCAL __export DlgfnOpen();
  195. int FAR PASCAL DlgOpenFile (
  196.     HWND        hwndParent,
  197.     char        *szTitle,
  198.     DWORD       flags,
  199.     char        *szExtIn,
  200.         char            *szFileNameIn,
  201.         WORD *          pfOpt
  202. );
  203.