home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / aniedit / anidefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-07  |  9.3 KB  |  343 lines

  1. /*
  2.  * Common includes
  3.  *
  4.  */
  5. #include "anicur.h"
  6. #include "anidlgs.h"
  7. #include "animsg.h"
  8.  
  9. /*
  10.  * Constants
  11.  *
  12.  */
  13. #define CMS_WAIT_FOR_PROCESS    (60 * 1000) // one minute
  14.  
  15. #define AIM_PROCESSTERM         (WM_USER + 0x0FFF)
  16. #define AIM_SETCHILDAPP         (AIM_PROCESSTERM + 1)
  17.  
  18. #define CCH_TITLE    80
  19. #define CCH_CREATOR  80
  20. #define CCH_JIF      10         /* Numbers are small even in German! */
  21.  
  22. #define CTRL_C  (TEXT(('C' - 'A') + 1))
  23. #define CTRL_V  (TEXT(('V' - 'A') + 1))
  24. #define CTRL_X  (TEXT(('X' - 'A') + 1))
  25.  
  26. #define TITL_ERROR  (DWORD)(-1)
  27. #define szPREVIEW   TEXT("AniEditPreviewClass")
  28. #define szBNTBAR    TEXT("AniEditBtnBarClass")
  29.  
  30.  
  31. #define PM_NEWCURSOR            (WM_USER + 0x4a50)
  32. #define PM_PAUSEANIMATION       (PM_NEWCURSOR + 1)
  33. #define PM_UNPAUSEANIMATION     (PM_NEWCURSOR + 2)
  34. #define PM_SETSTEP              (PM_NEWCURSOR + 3)
  35.  
  36. #define ID_PREVIEWTIMER         (0x0050)
  37.  
  38. #define MULTISEL        1       /* listbox is mutliple selction */
  39.  
  40. /*
  41.  * Structure defintions
  42.  *
  43.  */
  44. typedef struct _FRAME *PFRAME;
  45.  
  46. typedef struct _FRAME {
  47.     int         cRef;           /* refrence count */
  48.     int         iFrame;
  49.     PFRAME      pfrmNext;
  50.     DWORD       dwCheckSum;     /* checksum of the icon data.  Used to
  51.                                  * compare new imported icons against existing
  52.                                  * ones to see if we can sequence them.
  53.                                  */
  54.     HICON       hcur;           /* icon representation of raw data below */
  55.     WORD        xHotSpot;
  56.     WORD        yHotSpot;
  57.     RTAG        rtag;           /* icon chunk as it appears in file */
  58.     BYTE        abIcon[1];
  59. } FRAME;
  60.  
  61.  
  62. typedef struct _STEP *PSTEP;
  63.  
  64. typedef struct _STEP {
  65.     JIF     jif;
  66.     PFRAME  pfrmFrame;
  67. } STEP;
  68.  
  69. typedef struct _THDDATA {
  70.     HWND    hwndCaller;
  71.     HWND    hwndMonitor;
  72.     HANDLE  hprocMonitor;
  73. } THDDATA, *PTHDDATA;
  74.  
  75. typedef struct _ANICUR {
  76.     ANIHEADER anih;
  77.     BOOL      fDirty;
  78.     CHAR      azTitle[CCH_TITLE];
  79.     CHAR      azCreator[CCH_CREATOR];
  80.     TCHAR     szFile[MAX_PATH];
  81. } ANICUR;
  82.  
  83.  
  84. typedef struct _CLPBRDDAT *PCLPBRDDAT;
  85.  
  86. typedef struct _CLPBRDDAT {
  87.     PCLPBRDDAT pcbdNext;
  88.     STEP    stp;
  89. } CLPBRDDAT;
  90.  
  91. //
  92. // Structure that contains data used within a preview window.  This
  93. // data is unique for each preview window, and is used to optimize
  94. // the painting.
  95. //
  96. typedef struct
  97. {
  98.     HDC hdcMem;
  99.     HBITMAP hbmMem;
  100.     HBITMAP hbmOld;
  101.     HICON   hcur;
  102.     DWORD   iFrame;
  103.     WORD    xHot;
  104.     WORD    yHot;
  105. } PREVIEWDATA, *PPREVIEWDATA;
  106.  
  107. typedef struct {
  108.     int id;
  109.     int idSys;
  110. } RADIOCOLOR;
  111.  
  112. /*
  113.  * Header of the resource file in the new format
  114.  */
  115. #pragma pack(2)
  116. typedef struct tagNEWHEADER {
  117.     WORD reserved;
  118.     WORD rt;
  119.     WORD cResources;
  120. } NEWHEADER, *LPNEWHEADER;
  121.  
  122. typedef struct tagICONDIR {
  123.     BYTE Width;            /* 16, 32, 64 */
  124.     BYTE Height;           /* 16, 32, 64 */
  125.     BYTE ColorCount;       /* 2, 8, 16 */
  126.     BYTE reserved;
  127. } ICONDIR;
  128.  
  129. typedef struct tagCURSORDIR {
  130.     WORD Width;
  131.     WORD Height;
  132. } CURSORDIR;
  133.  
  134. typedef struct tagRESDIR {
  135.     union {
  136.         ICONDIR Icon;
  137.         CURSORDIR Cursor;
  138.     } ResInfo;
  139.  
  140.     WORD Planes;
  141.     WORD BitCount;
  142.     DWORD BytesInRes;
  143.     WORD idIcon;
  144. } RESDIR;
  145. typedef RESDIR *LPRESDIR;
  146.  
  147. typedef struct _ICONFILERESDIR {    // ird
  148.     BYTE bWidth;
  149.     BYTE bHeight;
  150.     BYTE bColorCount;
  151.     BYTE bReserved;
  152.     WORD xHotspot;
  153.     WORD yHotspot;
  154.     DWORD dwDIBSize;
  155.     DWORD dwDIBOffset;
  156. } ICONFILERESDIR;
  157.  
  158. typedef struct tagCURSORRESOURCE {
  159.     WORD xHotspot;
  160.     WORD yHotspot;
  161.     BITMAPINFOHEADER bih;
  162. } CURSORRESOURCE, *PCURSORRESOURCE;
  163. #pragma pack()
  164.  
  165.  
  166. /*
  167.  * Globals
  168.  *
  169.  */
  170. extern HANDLE hInst;
  171. extern HWND ghwndMain;
  172. extern HWND ghwndLB;
  173. extern int gcyCursor, gcxCursor;
  174. extern HBRUSH ghbrHighlight, ghbrWindow, ghbrPrevBackgnd;
  175. extern COLORREF gcrHighlightText;
  176. extern ANICUR ganiAcon;
  177. extern TCHAR gszTempFile[];
  178. extern BOOL gfEditFrame;
  179. extern TCHAR gszWindowTitle[];
  180. extern TCHAR gszDots[];
  181. extern PFRAME   gpfrmFrames;
  182. extern PCLPBRDDAT gpbdClipBoard;
  183. extern TCHAR gszCursorEditor[MAX_PATH];
  184. extern int giradColor;
  185. RADIOCOLOR garadColor[];
  186.  
  187. /*
  188.  * String table pointers
  189.  */
  190. extern LPTSTR gpszAniFilter;
  191. extern LPTSTR gpszImagEdit;
  192. extern LPTSTR gpszCUR;
  193. extern LPTSTR gpszANI;
  194. extern LPTSTR gpszUnknownError;
  195. extern LPTSTR gpszCurFilter;
  196. extern LPTSTR gpszUntitled;
  197. extern LPTSTR gpszImport;
  198.  
  199. /*
  200.  * Macros
  201.  *
  202.  */
  203. #if 0
  204. #   include <stdio.h>
  205. #   define DPRINT(p)   if(1){ printf p; fflush(stdout); } else
  206. #else
  207. #   define DPRINT(p)
  208. #endif
  209.  
  210.  
  211. #define WRITEME(hwnd)       \
  212.             MessageBox(hwnd, "This function is not yet implemented",    \
  213.             NULL, MB_OK | MB_ICONSTOP)
  214.  
  215. #define FALLTHRU(label)
  216.  
  217. #define COUNTOF(sz)     (sizeof(sz) / sizeof((sz)[0]))
  218.  
  219. #define FreeMem(pv)     LocalFree((HLOCAL)pv)
  220.  
  221. #define IsValidPS(ps)   (((ps) != (PSTEP)LB_ERR) && ((ps) != NULL))
  222.  
  223.  
  224. #define PADUP(cb)       (((cb) + 1) & ~1)
  225. #define RET_CLOSE_IF_ERR( func, hf )  \
  226.         if( !func ) {CloseHandle(hf); return FALSE;} else
  227.  
  228. #define GetStep(hwnd, iSel) (PSTEP)SendDlgItemMessage(hwnd, \
  229.         DLG_MAIN_FRAMELIST, LB_GETITEMDATA, iSel, 0)
  230.  
  231. #define GetStepCount(hwnd) SendDlgItemMessage(hwnd, \
  232.         DLG_MAIN_FRAMELIST, LB_GETCOUNT, 0, 0)
  233.  
  234. #define GetSelStepCount(hwnd) SendDlgItemMessage(hwnd, \
  235.         DLG_MAIN_FRAMELIST, LB_GETSELCOUNT, 0, 0)
  236.  
  237. #define ResumePreview(hwnd, id) \
  238.     SendDlgItemMessage(hwnd, id, PM_UNPAUSEANIMATION, 0, 0)
  239.  
  240. #define PausePreview(hwnd, id) \
  241.     SendDlgItemMessage(hwnd, id, PM_PAUSEANIMATION, 0, 0)
  242.  
  243. #define SetPreviewStep(hwnd, id, iStep) \
  244.     SendDlgItemMessage(hwnd, id, PM_SETSTEP, iStep, 0)
  245.  
  246. #define PreviewCursor(hwnd, id) \
  247.     SendDlgItemMessage(hwnd, id, PM_NEWCURSOR, 0, 0)
  248.  
  249. #define FmtFree( psz ) if((psz) != gszDots) LocalFree(psz); else
  250.  
  251. #define UpdateStepSel( hWnd )                                    \
  252.     SendMessage(hWnd, WM_COMMAND, MAKEWPARAM( DLG_MAIN_FRAMELIST, \
  253.             LBN_SELCHANGE), (LPARAM)(GetDlgItem(hWnd,             \
  254.             DLG_MAIN_FRAMELIST)))
  255.  
  256. #define SetStepSel(hWnd, iMin, iMax)    (               \
  257.     SendDlgItemMessage(hWnd, DLG_MAIN_FRAMELIST,        \
  258.             LB_SELITEMRANGE, TRUE, MAKELPARAM((iMin), (iMax))), \
  259.     UpdateStepSel(hWnd)                                 \
  260. )
  261.  
  262.  
  263. /*
  264.  * Function Prototypes
  265.  *
  266.  */
  267.  
  268. /*
  269.  * In aniedit.c
  270.  */
  271. BOOL InitApplication(HANDLE);
  272. BOOL InitInstance(HANDLE, int);
  273. INT  APIENTRY GetHeightFromPoints( int pts);
  274. BOOL APIENTRY MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam);
  275. void DrawCursorListItem( DRAWITEMSTRUCT *pdis );
  276. int FmtMessageBox( HWND hwnd, DWORD dwTitleID, LPTSTR pszTitleStr,
  277.     UINT fuStyle, BOOL fSound, DWORD dwTextID, ... );
  278. LPTSTR FmtSprintf( DWORD id, ... );
  279. PVOID AllocMem( DWORD cb );
  280. LRESULT CALLBACK PreviewWndProc( HWND hwnd, UINT msg, WPARAM wParam,
  281.         LPARAM lParam );
  282. VOID NextFrame( HWND hwnd, BOOL fRun );
  283. VOID SetWindowFileTitle(HWND hWnd, LPTSTR szFileTitle);
  284. void AniAddFontModule(HINSTANCE hInst);
  285. VOID ReadRegistry( VOID );
  286. VOID WriteRegistry( VOID );
  287. LRESULT CALLBACK BtnBarWndProc( HWND hwnd, UINT msg, WPARAM wParam,
  288.         LPARAM lParam);
  289. #ifdef DBCS
  290. BOOL LoadResourceStr( VOID );
  291. #endif
  292.  
  293.  
  294. /*
  295.  * In anicmd.c
  296.  */
  297. void LoadAniFile(HWND hWnd, HANDLE hfCursor, LPTSTR szFileTitle, LPTSTR szFile);
  298. BOOL DoCommand( HWND hWnd, UINT wParam, LONG lParam );
  299. VOID ExitCommand(HWND hWnd);
  300. BOOL CheckDirty(HWND hWnd);
  301. void NewAniCursor( HWND hwnd );
  302. BOOL ExecProgram( HWND hwndCaller, LPTSTR pszCmdLine );
  303. BOOL GetCurrentSel( HWND hwnd, int id, int *paiSel, int ciSel, int *pcSel );
  304. VOID SetCurrentSel( HWND hwnd, int id, BOOL fExtend, int iSel);
  305. VOID EditFrame(HWND hWnd, BOOL fEditFrame);
  306. PSTEP NewStep( void );
  307. VOID DestroyStep( PSTEP ps );
  308. VOID CopyStep( PSTEP psDst, PSTEP psSrc );
  309. VOID LinkStepFrame(PSTEP ps, PFRAME pf );
  310. VOID DestroyFrame( PFRAME pf );
  311. PCLPBRDDAT NewClpBrdDat( void );
  312. VOID DestroyClpBrdDat(PCLPBRDDAT pcbd);
  313. int __cdecl RevCompInts(const void *elm1, const void *elm2);
  314. BOOL APIENTRY About(HWND, UINT, UINT, LONG);
  315. BOOL APIENTRY OptionsProc( HWND hDlg, UINT message, UINT wParam, LONG lParam);
  316. void ClearStepSel( HWND hWnd );
  317.  
  318.  
  319.  
  320. /*
  321.  * In anifile.c
  322.  */
  323. BOOL CreateFrameFromCursorFile(HWND hwnd,  LPTSTR pszFile, BOOL fEdit);
  324. HANDLE PromptAndOpenFile( HWND hwnd, DWORD  cchFileTitle, LPTSTR pszFileTitle,
  325.     DWORD cchFileName, LPTSTR pszFileName, LPTSTR pszFilter);
  326. BOOL PromptForFile( HWND hwnd, DWORD  cchFileTitle, LPTSTR pszFileTitle,
  327.     DWORD  cchFileName, LPTSTR pszFile, LPTSTR pszFilter, LPTSTR pszDlgTitle,
  328.     BOOL fSave );
  329. BOOL ReadAniFile( HWND hwnd, HANDLE hf );
  330. PFRAME ReadIconFromFile(HWND hwnd, HANDLE hf, DWORD ckSize);
  331. BOOL ReadTag( HANDLE hf, PRTAG ptag);
  332. BOOL ReadChunk( HANDLE hf, PRTAG ptag, PVOID pv);
  333. BOOL ReadChunkN( HANDLE hf, PRTAG ptag, PVOID pv, DWORD cbMax);
  334. BOOL SkipChunk( HANDLE hf, PRTAG ptag);
  335. DWORD CalcCheckSum( PBYTE pb, DWORD cb );
  336. HICON ConvertDataToIcon( PFRAME pf, WORD *pxHotSave, WORD *pyHotSave );
  337. BOOL GetTempCursorFileName( LPTSTR pszName );
  338. BOOL SaveAniFile( HWND hwnd, HANDLE hf );
  339. BOOL WriteTag(HANDLE hf, PRTAG prtag);
  340. BOOL WriteType(HANDLE hf, FOURCC ckID );
  341. BOOL WriteTagData(HANDLE hf, PRTAG prtag, VOID *pvData );
  342. VOID SaveFile(HWND hwnd, BOOL fPrompt);
  343.