// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) 1993, 1994  Microsoft Corporation.  All Rights Reserved.
//
// PURPOSE:
//    Contains declarations for all globally scoped names in the program.
//

//-------------------------------------------------------------------------
// Product identifier string defines

//  **TODO** Change these strings to the name of your application.

    #define APPNAME       GDIPRINT
    #define ICONFILE      GDIPRINT.ICO
    #define SZAPPNAME     "GDIPRINT"
    #define SZDESCRIPTION "GDIPRINT Example Application"
    #define SZABOUT       "About GDIPRINT"
    #define SZVERSION     "Version 4.0"


//-------------------------------------------------------------------------
// Functions for handling main window messages.  The message-dispatching
// mechanism expects all message-handling functions to have the following
// prototype:
//
//     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);

// **TODO**  Add message-handling function prototypes here.  Be sure to
//           add the function names to the main window message table in
//           gdiprint.c.

LRESULT MsgCommand            (HWND, UINT, WPARAM, LPARAM);  // gdiprint.c   
LRESULT MsgClose              (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgDestroy            (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgCreate             (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgSize               (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgPaletteChanged     (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgQueryNewPalette    (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgQueryEndSession    (HWND, UINT, WPARAM, LPARAM);
LRESULT MsgNotify             (HWND, UINT, WPARAM, LPARAM);  // toolbar.c
LRESULT MsgTimer              (HWND, UINT, WPARAM, LPARAM);  // statbar.c
LRESULT MsgMenuSelect         (HWND, UINT, WPARAM, LPARAM);

//-------------------------------------------------------------------------
// Functions for handling main window commands--ie. functions for
// processing WM_COMMAND messages based on the wParam value.
// The message-dispatching mechanism expects all command-handling
// functions to have the following prototype:
//
//     LRESULT FunctionName(HWND, WORD, WORD, HWND);

// **TODO**  Add message-handling function prototypes here.  Be sure to
//           add the function names to the main window command table in
//           gdiprint.c.

LRESULT CmdExit       (HWND, WORD, WORD, HWND);     // gdiprint.c
LRESULT CmdAbout      (HWND, WORD, WORD, HWND);     // about.c 
LRESULT CmdInfo       (HWND, WORD, WORD, HWND);     // infodlg.c
LRESULT CmdNew        (HWND, WORD, WORD, HWND);     // filedlg.c
LRESULT CmdOpen       (HWND, WORD, WORD, HWND);
LRESULT CmdSave       (HWND, WORD, WORD, HWND);
LRESULT CmdClose      (HWND, WORD, WORD, HWND);
LRESULT CmdPrint      (HWND, WORD, WORD, HWND);     // print.c  
LRESULT CmdPageSetup  (HWND, WORD, WORD, HWND);
LRESULT CmdPrintSetup (HWND, WORD, WORD, HWND);

LRESULT CmdDrawMode   (HWND, WORD, WORD, HWND);     // client.c
LRESULT CmdFill       (HWND, WORD, WORD, HWND);
LRESULT CmdCreatePen  (HWND, WORD, WORD, HWND);
LRESULT CmdCreateBrush(HWND, WORD, WORD, HWND);
LRESULT CmdClear      (HWND, WORD, WORD, HWND);     // gdiprint.c


//-------------------------------------------------------------------------
// Global function prototypes.

// **TODO**  Add global function prototypes here.

BOOL    InitApplication(HINSTANCE, int);     // init.c
BOOL    CenterWindow(HWND, HWND);            // misc.c
void    SetWindowTitle(HWND, LPSTR);         // misc.c 
void    InitDIBSection(HWND);                // misc.c
void    RemoveDIBSection(void);              // misc.c
HWND    CreateClientWindow(HWND);            // client.c
void    SizeClientWindow(HWND);              // client.c  
void    InitDrawObjects(void);               // client.c
int     QuerySaveChanges(HWND);              // filedlg.c
HBITMAP LoadDIBSection(HWND, LPSTR);         // fileio.c


// Callback functions.  These are called by Windows.

// **TODO**  Add new callback function prototypes here.  

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);       // gdiprint.c
LRESULT CALLBACK ClientWndProc(HWND, UINT, WPARAM, LPARAM); // client.c

//-------------------------------------------------------------------------
// Command ID definitions.  These definitions are used to associate menu
// items with commands.

// **TODO**  Add IDs for all menu commands here.  Be sure that the IDs you
//           add are also added to the main window command table in gdiprint.c
//           and the menu statements in the resource file.

// File menu
#define IDM_FILEMENU    1000
#define IDM_FILENEW     1001
#define IDM_FILEOPEN    1002
#define IDM_FILESAVE    1003
#define IDM_FILESAVEAS  1004
#define IDM_FILECLOSE   1005
#define IDM_FILEPRINT   1006
#define IDM_FILEPAGESU  1007
#define IDM_FILEPRINTSU 1008
#define IDM_EXIT        1009
      
// Info menu
#define IDM_INFO        1050
      
// Edit menu
#define IDM_EDITMENU    1100
#define IDM_EDITUNDO    1101
#define IDM_EDITCUT     1102
#define IDM_EDITCOPY    1103
#define IDM_EDITPASTE   1104
#define IDM_EDITCLEAR   1105

// Draw menu
#define IDM_DRAWMENU    1200
#define IDM_PIXEL       1201
#define IDM_LINE        1202
#define IDM_RECT        1203
#define IDM_ELLIPSE     1204
#define IDM_BEZIER      1205
#define IDM_FILL        1206
#define IDM_NOFILL      1207
#define IDM_CREATEPEN   1208
#define IDM_CREATEBRUSH 1209    
#define IDM_CLEAR       1210

// Help menu
#define IDM_HELPMENU    1300
#define IDM_ABOUT       1301


//-------------------------------------------------------------------------
// String Table ID definitions.

#define IDS_APPNAME         1
#define IDS_DESCRIPTION     2
#define IDS_READY           3
#define IDS_FILTERSTRING    4       
#define IDS_SAVEASTITLE     5 
#define IDS_UNTITLED        6 
#define IDS_SAVECHANGES     7 

//-------------------------------------------------------------------------
//  About dialog defines.

#define IDD_VERFIRST    100
#define IDD_VERLAST     104

// Defines for FileNew and Common Dialog FileOpen and FileSaveAs

#define IDD_FILETEXT        110
#define IDD_FILETYPE        111
#define IDD_RGB             112
#define IDD_RLE4            113
#define IDD_RLE8            114
#define IDD_PM              115
#define IDD_1               116
#define IDD_4               117
#define IDD_8               118
#define IDD_16              119
#define IDD_24              120
#define IDD_FILETYPEGROUP   121
#define IDD_BPP             122
#define IDD_WIDTH           123
#define IDD_HEIGHT          124
                               
// Abort dialog defines.
                                         
#define IDD_FILENAME        130                                         

//-------------------------------------------------------------------------
// constants for DIB error string table

#define ERR_MIN                 4096     // All error #s >= this value. 
#define ERR_NOT_DIB             4096     // Tried to load a file, NOT a DIB!
#define ERR_UNSUPPORTEDFORMAT   4097     // DIB is not in a supported format!
#define ERR_MEMORY              4098     // Not enough memory!
#define ERR_READ                4099     // Error reading file!
#define ERR_SAVE                5000     // Error saving file!
#define ERR_LOCK                5001     // Error on a GlobalLock()!
#define ERR_OPEN                5002     // Error opening a file!
#define ERR_CREATEPAL           5003     // Error creating palette.
#define ERR_GETDC               5004     // Couldn't get a DC.      
#define ERR_FILENOTFOUND        5005     // Error opening file
#define ERR_INVALIDHANDLE       5006     // Invalid Handle
#define ERR_DIBFUNCTION         5007     // Error on call to DIB function
#define ERR_CREATEDIBSECTION    5008     // Error on call to CreateDIBSection 
#define ERR_FILLCOLORTABLE      5009     // Error on call to FillColorTable 
#define ERR_WIDTH               5010     // Didn't define a bitmap width
#define ERR_HEIGHT              5011     // Didn't define a bitmap height  
#define ERR_STRETCHDIBITS       5012     // StretchDIBits failed
#define ERR_UNDEFINEDERROR      5013     // Undefined error
#define ERR_MAX                 5013     // All error #s < this value

//-------------------------------------------------------------------------
// Global variable declarations.

extern HINSTANCE hInst;          // The current instance handle
extern char      szAppName[];    // The name of this application
extern HWND      hWndClient;     // The Client window
extern HMENU     hMenu;          // Application menu
extern HICON     hIcon;          // Application icon
                
// palette-related globals
extern HPALETTE  hPalette;       // App's logical palette
extern BOOL      bPalDevice;     // palette device flag

// drawing-related globals
extern LOGPEN    logPen;         // structure for pen attributes
extern LOGBRUSH  logBrush;       // structure for brush attributes

// DIB section-related globals
extern char      szCurrentFile[]; 
extern HBITMAP   hBitmap;
extern HANDLE    hDIBInfo;
extern LPVOID    lpvBits;
extern BOOL      fChanges;
                                    

// **TODO**  For NON-MDI applications, uncomment line 1 below and comment
//           line 2.  For MDI applications, uncomment line 2 below, comment
//           line 1, and then define hwndMDIClient as a global variable in
//           INIT.C
#define hwndMDIClient NULL        /* (1) Stub for NON-MDI applications. */
// extern HWND hwndMDIClient;     /* (2) For MDI applications.          */


//-------------------------------------------------------------------------
// Message and command dispatch infrastructure.  The following type
// definitions and functions are used by the message and command dispatching
// mechanism and do not need to be changed.

    // Function pointer prototype for message handling functions.
typedef LRESULT (*PFNMSG)(HWND, UINT, WPARAM, LPARAM);

    // Function pointer prototype for command handling functions.
typedef LRESULT (*PFNCMD)(HWND, WORD, WORD, HWND);

    // Enumerated type used to determine which default window procedure
    // should be called by the message- and command-dispatching mechanism
    // if a message or command is not handled explicitly.
typedef enum
{
   edwpNone,            // Do not call any default procedure.
   edwpWindow,          // Call DefWindowProc.
   edwpDialog,          // Call DefDlgProc (This should be used only for
                        // custom dialogs - standard dialog use edwpNone).
   edwpMDIChild,        // Call DefMDIChildProc.
   edwpMDIFrame         // Call DefFrameProc.
} EDWP;                // Enumeration for Default Window Procedures

    // This structure maps messages to message handling functions.
typedef struct _MSD
{
    UINT   uMessage;
    PFNMSG pfnmsg;
} MSD;                 // MeSsage Dispatch structure

    // This structure contains all of the information that a window
    // procedure passes to DispMessage in order to define the message
    // dispatching behavior for the window.
typedef struct _MSDI
{
    int  cmsd;          // Number of message dispatch structs in rgmsd
    MSD *rgmsd;         // Table of message dispatch structures
    EDWP edwp;          // Type of default window handler needed.
} MSDI, FAR *LPMSDI;   // MeSsage Dipatch Information

    // This structure maps command IDs to command handling functions.
typedef struct _CMD
{
    WORD   wCommand;
    PFNCMD pfncmd;
} CMD;                 // CoMmand Dispatch structure

    // This structure contains all of the information that a command
    // message procedure passes to DispCommand in order to define the
    // command dispatching behavior for the window.
typedef struct _CMDI
{
    int  ccmd;          // Number of command dispatch structs in rgcmd
    CMD *rgcmd;         // Table of command dispatch structures
    EDWP edwp;          // Type of default window handler needed.
} CMDI, FAR *LPCMDI;   // CoMmand Dispatch Information

    // Message and command dispatching functions.  They look up messages
    // and commands in the dispatch tables and call the appropriate handler
    // function.
LRESULT DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM);
LRESULT DispCommand(LPCMDI, HWND, WPARAM, LPARAM);

    // Message dispatch information for the main window
extern MSDI msdiMain;
    // Command dispatch information for the main window
extern CMDI cmdiMain;



//-------------------------------------------------------------------------
// Version string definitions--Leave these alone.

#define SZRCOMPANYNAME "CompanyName"
#define SZRDESCRIPTION "FileDescription"
#define SZRVERSION     "FileVersion"
#define SZRAPPNAME     "InternalName"
#define SZRCOPYRIGHT   "LegalCopyright"
#define SZRTRADEMARK   "LegalTrademarks"
#define SZRPRODNAME    "ProductName"
#define SZRPRODVER     "ProuctVersion"
    
 
