📄 classlib.h
字号:
virtual UINT CreateToolbar(void);
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM
, LRESULT *);
virtual LRESULT OnCommand(HWND, WPARAM, LPARAM);
virtual void OnDocumentDataChange(CDocument *);
virtual void OnDocumentActivate(CDocument *);
virtual BOOL SaveOpenDialog(LPTSTR, UINT, UINT, BOOL
, UINT *);
virtual UINT ReplaceCharWithNull(LPTSTR, int);
virtual LPTSTR PszWhiteSpaceScan(LPTSTR, BOOL);
public:
CFrame(HINSTANCE, HINSTANCE, LPSTR, int);
virtual ~CFrame(void);
virtual BOOL Init(PFRAMEINIT);
virtual WPARAM MessageLoop(void);
virtual BOOL AskAndSave(LPTSTR);
virtual void UpdateMenus(HMENU, UINT);
virtual void UpdateToolbar(void);
virtual void WindowTitleSet(CDocument *, BOOL);
virtual PCStatusLine inline StatusLine(void);
};
typedef CFrame *PCFrame;
//Other Miscellaneous CFrame definitions
//ToolBar and StatStrip IDs used in this frame
#define ID_GIZMOBAR 11
#define ID_STATSTRIP 12
//Classname
#define SZCLASSFRAME TEXT("Frame")
/**
** CClient encapsulates an MDI or SDI client window
**/
//Forward reference
class CDocumentAdviseSink;
typedef CDocumentAdviseSink *PCDocumentAdviseSink;
//CLIENT.CPP
LRESULT APIENTRY SDIClientWndProc(HWND, UINT, WPARAM, LPARAM);
#define CBCLIENTWNDEXTRA sizeof(LONG)
#define CLIENTWL_HWNDDOC 0
class CClient : public CWindow
{
friend LRESULT APIENTRY SDIClientWndProc(HWND, UINT, WPARAM
, LPARAM);
protected:
PCFrame m_pFR; //Frame window information
UINT m_cDoc; //Count of open documents
CDocument * m_pDocLast; //Last created document
HWND m_hListDocs; //List of documents
//This is created to send notifications to the frame
PCDocumentAdviseSink m_pAdv;
private:
//This non-overridable sets m_pDocLast
CDocument * CreateDoc(void);
protected:
//Overridable for creating a new CDocument
virtual CDocument * CreateCDocument(void);
public:
CClient(HINSTANCE, PCFrame);
virtual ~CClient(void);
PCFrame Frame(void);
UINT DocumentCount(void);
HWND DocumentList(void);
virtual BOOL Init(HMENU, LPRECT);
virtual BOOL TranslateAccelerator(LPMSG);
virtual LRESULT DefaultFrameProc(HWND, UINT, WPARAM
, LPARAM);
virtual void OnWindowCommand(UINT, UINT);
virtual void OnSize(UINT, UINT, UINT, UINT);
virtual CDocument * NewDocument(BOOL);
virtual CDocument * ActiveDocument(void);
virtual BOOL ShowDocument(CDocument *, BOOL);
virtual BOOL SDIVerify(void);
virtual UINT CloseDocument(CDocument *);
virtual BOOL QueryCloseAllDocuments(BOOL, BOOL);
virtual BOOL FCleanVerify(CDocument *);
};
typedef CClient *PCClient;
//Other Miscellaneous CFrame definitions
//Document window identifiers
#define ID_DOCUMENT 999 //Internal ID for all documents
#define ID_MDICHILDMIN 1000 //Starting point for MDI doc IDs
#define SZCLASSSDICLIENT TEXT("SDIClient")
/**
** CDocument encapsulates an MDI or SDI child window
**/
//DOCWIN.CPP
LRESULT APIENTRY DocumentWndProc(HWND, UINT, WPARAM, LPARAM);
//DOCUMENT.CPP
//File-related string lengths.
#define CCHPATHMAX 256
#define CCHFILENAMEMAX 15
//Window extra bytes and offsets
#define CBDOCUMENTWNDEXTRA sizeof(LONG)
#define DOCWL_STRUCTURE 0
//Error codes from Load and Save functions
#define DOCERR_NONE 0
#define DOCERR_NOFILE 1
#define DOCERR_COULDNOTOPEN 2
#define DOCERR_READFAILURE 3
#define DOCERR_UNSUPPORTEDVERSION 4
#define DOCERR_WRITEFAILURE 5
#define DOCERR_CANCELLED 6
#define DOCERR_STDMAX 6
/*
* Structure containing resource ranges and other data for
* initialization of a CDocument object through its Init member.
*/
typedef struct tagDOCUMENTINIT
{
UINT idsMin; //Stringtable start and end
UINT idsMax;
HWND hWndDoc; //HWND of this document, created in client
} DOCUMENTINIT, *PDOCUMENTINIT;
class CDocument : public CWindow
{
friend LRESULT APIENTRY DocumentWndProc(HWND, UINT, WPARAM
, LPARAM);
protected:
PCFrame m_pFR; //Back pointer
UINT m_cf; //Clipboard format
BOOL m_fDirty; //Is file dirty?
BOOL m_fNoDirty; //Don't touch dirty flag
BOOL m_fNoSize; //Prevent sizing
BOOL m_fFileKnown; //File/Save allowed?
TCHAR m_szFile[CCHPATHMAX]; //Filename for Save
PCStringTable m_pST; //Document strings
/*
* If someone above us wants information, they'll
* give us this object.
*/
PCDocumentAdviseSink m_pAdv;
protected:
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM
, LRESULT *);
public:
CDocument(HINSTANCE, PCFrame, PCDocumentAdviseSink);
virtual ~CDocument(void);
virtual BOOL Init(PDOCUMENTINIT);
virtual BOOL FDirtySet(BOOL);
virtual BOOL FDirtyGet(void);
virtual void Clear(void);
virtual UINT Load(BOOL, LPTSTR);
virtual UINT Save(UINT, LPTSTR);
virtual void ErrorMessage(UINT);
virtual BOOL Clip(HWND, BOOL);
virtual HGLOBAL RenderFormat(UINT);
virtual BOOL FQueryPaste(void);
virtual BOOL Paste(HWND);
virtual void Undo(void);
virtual BOOL FQuerySave(void);
virtual void Rename(LPTSTR);
virtual UINT FilenameGet(LPTSTR, UINT);
virtual PCFrame FrameGet(void);
};
typedef CDocument *PCDocument;
//Classname for documents, not localized
#define SZCLASSDOCUMENT TEXT("document")
//Macro that isolates us from MDI or SDI Def procs
#ifdef MDI
#define DEFDOCUMENTPROC DefMDIChildProc
#else
#define DEFDOCUMENTPROC DefWindowProc
#endif
//Message to get PCDocument from hWnd
#define DOCM_PDOCUMENT (WM_USER+0)
/**
** CDocumentAdviseSink through which a document notifies the
** frame or important events.
**/
class CDocumentAdviseSink
{
protected:
LPVOID m_pv; //Customizable structure
public:
CDocumentAdviseSink(LPVOID);
virtual void OnDataChange(PCDocument);
virtual void OnCloseRequest(PCDocument);
virtual void OnSizeChange(PCDocument, LPRECT);
virtual void OnCaptionChange(PCDocument);
virtual void OnActivate(PCDocument);
};
/**
** CHatchWin when used as a parent window creates a thin
** hatch border around the child window.
**/
BOOL HatchWindowRegister(HINSTANCE);
//Classname
#define SZCLASSHATCHWIN TEXT("hatchwin")
//Window extra bytes and offsets
#define CBHATCHWNDEXTRA (sizeof(LONG))
#define HWWL_STRUCTURE 0
//Notification codes for WM_COMMAND messages
#define HWN_BORDERDOUBLECLICKED 1
//Width of the border
#define HATCHWIN_BORDERWIDTHDEFAULT 4
class CHatchWin : public CWindow
{
friend LRESULT APIENTRY HatchWndProc(HWND, UINT, WPARAM, LPARAM);
public:
int m_dBorder;
int m_dBorderOrg;
UINT m_uID;
HWND m_hWndKid;
HWND m_hWndAssociate;
RECT m_rcPos;
RECT m_rcClip;
public:
CHatchWin(HINSTANCE);
~CHatchWin(void);
BOOL Init(HWND, UINT, HWND);
HWND HwndAssociateSet(HWND);
HWND HwndAssociateGet(void);
void RectsSet(LPRECT, LPRECT);
void ChildSet(HWND);
void ShowHatch(BOOL);
};
typedef CHatchWin *PCHatchWin;
#endif //_CLASSLIB_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -