home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d020_1_4 / 6.ddi / SHOWDIB / SHOWDIB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-01  |  9.1 KB  |  244 lines

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