|
|
1.1 root 1: // Microsoft Foundation Classes C++ library.
2: // Copyright (C) 1992 Microsoft Corporation,
3: // All rights reserved.
4:
5: // This source code is only intended as a supplement to the
6: // Microsoft Foundation Classes Reference and Microsoft
7: // QuickHelp documentation provided with the library.
8: // See these sources for detailed information regarding the
9: // Microsoft Foundation Classes product.
10:
11: #ifndef __AFXWIN_H__
12: #define __AFXWIN_H__
13:
14: /////////////////////////////////////////////////////////////////////////////
15: // Classes declared in this file
16:
17: class CSize;
18: class CPoint;
19: class CRect;
20:
21: //CObject
22: // CException
23: class CResourceException; // Win resource failure exception
24:
25: class CGdiObject; // CDC drawing tool
26: class CPen; // a pen / HPEN wrapper
27: class CBrush; // a brush / HBRUSH wrapper
28: class CFont; // a font / HFONT wrapper
29: class CBitmap; // a bitmap / HBITMAP wrapper
30: class CPalette; // a palette / HPALLETE wrapper
31: class CRgn; // a region / HRGN wrapper
32:
33: class CDC; // a Display Context / HDC wrapper
34: class CClientDC; // CDC for client of window
35: class CWindowDC; // CDC for entire window
36: class CPaintDC; // embeddable BeginPaint struct helper
37:
38: class CMenu; // a menu / HMENU wrapper
39:
40: class CWnd; // a window / HWND wrapper
41: class CDialog; // a dialog
42:
43: // controls
44: class CStatic; // Static control
45: class CButton; // Button control
46: class CBitmapButton; // Bitmap button (self-draw)
47: class CListBox; // ListBox control
48: class CComboBox; // ComboBox control
49: class CEdit; // Edit control
50: class CScrollBar; // ScrollBar control
51:
52: // frame windows
53: class CFrameWnd; // standard SDI frame
54: class CMDIFrameWnd; // standard MDI frame
55: class CMDIChildWnd; // standard MDI child
56:
57: class CWinApp; // simple application base class
58:
59: /////////////////////////////////////////////////////////////////////////////
60: // Make sure 'afx.h' is included first
61:
62: #ifndef __AFX_H__
63: #ifndef _WINDOWS
64: #define _WINDOWS
65: #endif
66: #include "afx.h"
67: #else
68: #ifndef _WINDOWS
69: #error Please #define _WINDOWS before including afx.h
70: #endif
71: #endif
72:
73: // we must include certain parts of Windows.h
74: #undef NOKERNEL
75: #undef NOGDI
76: #undef NOUSER
77: #undef NOSOUND
78: #undef NOCOMM
79: #undef NODRIVERS
80: #undef NOLOGERROR
81: #undef NOPROFILER
82: #undef NOMEMMGR
83: #undef NOLFILEIO
84: #undef NOOPENFILE
85: #undef NORESOURCE
86: #undef NOATOM
87: #undef NOLANGUAGE
88: #undef NOLSTRING
89: #undef NODBCS
90: #undef NOKEYBOARDINFO
91: #undef NOGDICAPMASKS
92: #undef NOCOLOR
93: #undef NOGDIOBJ
94: #undef NODRAWTEXT
95: #undef NOTEXTMETRIC
96: #undef NOSCALABLEFONT
97: #undef NOBITMAP
98: #undef NORASTEROPS
99: #undef NOMETAFILE
100: #undef NOSYSMETRICS
101: #undef NOSYSTEMPARAMSINFO
102: #undef NOMSG
103: #undef NOWINSTYLES
104: #undef NOWINOFFSETS
105: #undef NOSHOWWINDOW
106: #undef NODEFERWINDOWPOS
107: #undef NOVIRTUALKEYCODES
108: #undef NOKEYSTATES
109: #undef NOWH
110: #undef NOMENUS
111: #undef NOSCROLL
112: #undef NOCLIPBOARD
113: #undef NOICONS
114: #undef NOMB
115: #undef NOSYSCOMMANDS
116: #undef NOMDI
117: #undef NOCTLMGR
118: #undef NOWINMESSAGES
119:
120: // The MFC library MUST be built with WINVER >= 0x030A (the default)
121: // even when Windows 3.0 is the target. There are no compatability
122: // issues, rather this is done for source code maintainability.
123:
124: // MFC applications may be built with WINVER == 0x300 (Win 3.0 only)
125: // or WINVER == 0x030A (Win 3.1/3.0)
126:
127: #ifdef STRICT
128: // The default for MFC is not STRICT, since C++ and MFC
129: // provide all of the same benefits (see TN012.TXT). If
130: // you wish to use STRICT typechecking, then you must rebuild
131: // the library after removing the following #undef.
132: #undef STRICT
133: #endif
134:
135: extern "C" {
136: #include "windows.h"
137: }
138:
139: #ifndef WINVER
140: #error Please include the correct WINDOWS.H (from \C700\INCLUDE)
141: #endif
142:
143: #ifdef _NTWIN
144: // private header file for Windows NT
145: #include "afxnt.h"
146: #endif //_NTWIN
147:
148: #ifndef __AFXRES_H__
149: #include "afxres.h" // standard resource IDs
150: #endif
151:
152: #ifndef EXPORT
153: #define EXPORT __export
154: #endif
155: #ifdef _WINDLL
156: #define AFX_EXPORT __loadds
157: #else
158: #define AFX_EXPORT EXPORT
159: #endif
160:
161: // Type modifier for message handlers
162: #define afx_msg /* intentional placeholder */
163:
164: /////////////////////////////////////////////////////////////////////////////
165: // CSize - An extent, similar to Windows SIZE structure.
166:
167: #if (WINVER < 0x030a)
168: typedef struct tagSIZE
169: {
170: int cx;
171: int cy;
172: } SIZE;
173: typedef SIZE* PSIZE;
174: typedef SIZE NEAR* NPSIZE;
175: typedef SIZE FAR* LPSIZE;
176: #endif /* WINVER < 0x030a */
177:
178: class CSize : public tagSIZE
179: {
180: public:
181:
182: // Constructors
183: CSize();
184: CSize(int initCX, int initCY);
185: CSize(SIZE initSize);
186: CSize(POINT initPt);
187: CSize(DWORD dwSize);
188:
189: // Operations
190: BOOL operator==(SIZE size) const;
191: BOOL operator!=(SIZE size) const;
192: void operator+=(SIZE size);
193: void operator-=(SIZE size);
194:
195: // Operators returning CSize values
196: CSize operator+(SIZE size) const;
197: CSize operator-(SIZE size) const;
198: };
199:
200: /////////////////////////////////////////////////////////////////////////////
201: // CPoint - A 2-D point, similar to Windows POINT structure.
202:
203: class CPoint : public tagPOINT
204: {
205: public:
206:
207: // Constructors
208: CPoint();
209: CPoint(int initX, int initY);
210: CPoint(POINT initPt);
211: CPoint(SIZE initSize);
212: CPoint(DWORD dwPoint);
213:
214: // Operations
215: void Offset(int xOffset, int yOffset);
216: void Offset(POINT point);
217: void Offset(SIZE size);
218: BOOL operator==(POINT point) const;
219: BOOL operator!=(POINT point) const;
220: void operator+=(SIZE size);
221: void operator-=(SIZE size);
222:
223: // Operators returning CPoint values
224: CPoint operator+(SIZE size) const;
225: CPoint operator-(SIZE size) const;
226:
227: // Operators returning CSize values
228: CSize operator-(POINT point) const;
229: };
230:
231: /////////////////////////////////////////////////////////////////////////////
232: // CRect - A 2-D rectangle, similar to Windows RECT structure.
233:
234: class CRect : public tagRECT
235: {
236: public:
237:
238: // Constructors
239: CRect();
240: CRect(int l, int t, int r, int b);
241: CRect(const RECT& srcRect);
242: CRect(LPRECT lpSrcRect);
243: CRect(POINT point, SIZE size);
244:
245: // Attributes (in addition to RECT members)
246: int Width() const;
247: int Height() const;
248: CSize Size() const;
249: CPoint& TopLeft();
250: CPoint& BottomRight();
251:
252: // convert between CRect and LPRECT (no need for &)
253: operator LPRECT();
254:
255: BOOL IsRectEmpty() const;
256: BOOL IsRectNull() const;
257: BOOL PtInRect(POINT point) const;
258:
259: // Operations (from standard Windows)
260: void SetRect(int x1, int y1, int x2, int y2);
261: void SetRectEmpty();
262: void CopyRect(LPRECT lpSrcRect);
263: BOOL EqualRect(LPRECT lpRect) const;
264:
265: void InflateRect(int x, int y);
266: void InflateRect(SIZE size);
267: void OffsetRect(int x, int y);
268: void OffsetRect(SIZE size);
269: void OffsetRect(POINT point);
270:
271: // operations that fill '*this' with result
272: int IntersectRect(LPRECT lpRect1, LPRECT lpRect2);
273: int UnionRect(LPRECT lpRect1, LPRECT lpRect2);
274: #if (WINVER >= 0x030a)
275: BOOL SubtractRect(LPRECT lpRectSrc1, LPRECT lpRectSrc2);
276: #endif /* WINVER >= 0x030a */
277:
278: // Additional Operations
279: void operator=(const RECT& srcRect);
280: BOOL operator==(const RECT& rect) const;
281: BOOL operator!=(const RECT& rect) const;
282: void operator+=(POINT point);
283: void operator-=(POINT point);
284: void operator&=(const RECT& rect);
285: void operator|=(const RECT& rect);
286:
287: // Operators returning CRect values
288: CRect operator+(POINT point) const;
289: CRect operator-(POINT point) const;
290: CRect operator&(const RECT& rect2) const;
291: CRect operator|(const RECT& rect2) const;
292: };
293:
294: #ifdef _DEBUG
295: // Diagnostic Output
296: CDumpContext& operator<<(CDumpContext& dc, SIZE size);
297: CDumpContext& operator<<(CDumpContext& dc, POINT point);
298: CDumpContext& operator<<(CDumpContext& dc, const RECT& rect);
299: #endif //_DEBUG
300:
301: // Serialization
302: CArchive& operator<<(CArchive& ar, SIZE size);
303: CArchive& operator<<(CArchive& ar, POINT point);
304: CArchive& operator<<(CArchive& ar, const RECT& rect);
305: CArchive& operator>>(CArchive& ar, SIZE& size);
306: CArchive& operator>>(CArchive& ar, POINT& point);
307: CArchive& operator>>(CArchive& ar, RECT& rect);
308:
309: /////////////////////////////////////////////////////////////////////////////
310: // Standard exception for resource failures
311:
312: class CResourceException : public CException
313: {
314: DECLARE_DYNAMIC(CResourceException)
315: public:
316: CResourceException();
317: };
318:
319: void AfxThrowResourceException();
320:
321: /////////////////////////////////////////////////////////////////////////////
322: // CGdiObject abstract class for CDC SelectObject
323:
324: class CGdiObject : public CObject
325: {
326: DECLARE_DYNAMIC(CGdiObject)
327: public:
328:
329: // Attributes
330: HANDLE m_hObject;
331: HANDLE GetSafeHandle() const;
332:
333: static CGdiObject* FromHandle(HANDLE hObject);
334: static void DeleteTempMap();
335: BOOL Attach(HANDLE hObject);
336: HANDLE Detach();
337:
338: // Constructors
339: CGdiObject(); // must Create a derived class object
340: virtual ~CGdiObject();
341: BOOL DeleteObject();
342:
343: // Operations
344: int GetObject(int nCount, void FAR* lpObject) const;
345: BOOL CreateStockObject(int nIndex);
346: BOOL UnrealizeObject();
347:
348: // Implementation
349: #ifdef _DEBUG
350: virtual void Dump(CDumpContext& dc) const;
351: #endif
352: };
353:
354: /////////////////////////////////////////////////////////////////////////////
355: // CGdiObject subclasses (drawing tools)
356:
357: class CPen : public CGdiObject
358: {
359: DECLARE_DYNAMIC(CPen)
360:
361: public:
362: static CPen* FromHandle(HPEN hPen);
363:
364: // Constructors
365: CPen();
366: CPen(int nPenStyle, int nWidth, DWORD crColor);
367: BOOL CreatePen(int nPenStyle, int nWidth, DWORD crColor);
368: BOOL CreatePenIndirect(LPLOGPEN lpLogPen);
369: };
370:
371: class CBrush : public CGdiObject
372: {
373: DECLARE_DYNAMIC(CBrush)
374:
375: public:
376: static CBrush* FromHandle(HBRUSH hBrush);
377:
378: // Constructors
379: CBrush();
380: CBrush(DWORD crColor); // CreateSolidBrush
381: CBrush(int nIndex, DWORD crColor); // CreateHatchBrush
382: CBrush(CBitmap* pBitmap); // CreatePatternBrush
383:
384: BOOL CreateSolidBrush(DWORD crColor);
385: BOOL CreateHatchBrush(int nIndex, DWORD crColor);
386: BOOL CreateBrushIndirect(LPLOGBRUSH lpLogBrush);
387: BOOL CreatePatternBrush(CBitmap* pBitmap);
388: BOOL CreateDIBPatternBrush(GLOBALHANDLE hPackedDIB, UINT nUsage);
389: };
390:
391: class CFont : public CGdiObject
392: {
393: DECLARE_DYNAMIC(CFont)
394:
395: public:
396: static CFont* FromHandle(HFONT hFont);
397:
398: // Constructors
399: CFont();
400: BOOL CreateFontIndirect(LPLOGFONT lpLogFont);
401: BOOL CreateFont(int nHeight, int nWidth, int nEscapement,
402: int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline,
403: BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
404: BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
405: LPCSTR lpFacename);
406: };
407:
408:
409: class CBitmap : public CGdiObject
410: {
411: DECLARE_DYNAMIC(CBitmap)
412:
413: public:
414: static CBitmap* FromHandle(HBITMAP hBitmap);
415:
416: // Constructors
417: CBitmap();
418:
419: BOOL LoadBitmap(LPCSTR lpBitmapName);
420: BOOL LoadBitmap(UINT nIDBitmap);
421: BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_
422: BOOL CreateBitmap(int nWidth, int nHeight, BYTE nPlanes, BYTE nBitcount,
423: const void FAR* lpBits);
424: BOOL CreateBitmapIndirect(LPBITMAP lpBitmap);
425: BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight);
426: BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight);
427:
428: // Operations
429: DWORD SetBitmapBits(DWORD dwCount, const void FAR* lpBits);
430: DWORD GetBitmapBits(DWORD dwCount, void FAR* lpBits) const;
431: CSize SetBitmapDimension(int nWidth, int nHeight);
432: CSize GetBitmapDimension() const;
433: };
434:
435: class CPalette : public CGdiObject
436: {
437: DECLARE_DYNAMIC(CPalette)
438:
439: public:
440: static CPalette* FromHandle(HPALETTE hPalette);
441:
442: // Constructors
443: CPalette();
444: BOOL CreatePalette(LPLOGPALETTE lpLogPalette);
445:
446: // Operations
447: UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
448: LPPALETTEENTRY lpPaletteColors) const;
449: UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
450: LPPALETTEENTRY lpPaletteColors);
451: void AnimatePalette(UINT nStartIndex, UINT nNumEntries,
452: LPPALETTEENTRY lpPaletteColors);
453: UINT GetNearestPaletteIndex(DWORD crColor) const;
454: BOOL ResizePalette(UINT nNumEntries);
455: };
456:
457: class CRgn : public CGdiObject
458: {
459: DECLARE_DYNAMIC(CRgn)
460:
461: public:
462: static CRgn* FromHandle(HRGN hRgn);
463:
464: // Constructors
465: CRgn();
466: BOOL CreateRectRgn(int x1, int y1, int x2, int y2);
467: BOOL CreateRectRgnIndirect(LPRECT lpRect);
468: BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2);
469: BOOL CreateEllipticRgnIndirect(LPRECT lpRect);
470: BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode);
471: BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
472: int nCount, int nPolyFillMode);
473: BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2,
474: int x3, int y3);
475:
476: // Operations
477: void SetRectRgn(int x1, int y1, int x2, int y2);
478: void SetRectRgn(LPRECT lpRect);
479: int CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode);
480: int CopyRgn(CRgn* pRgnSrc);
481: BOOL EqualRgn(CRgn* pRgn) const;
482: int OffsetRgn(int x, int y);
483: int OffsetRgn(POINT point);
484: int GetRgnBox(LPRECT lpRect) const;
485: BOOL PtInRegion(int x, int y) const;
486: BOOL PtInRegion(POINT point) const;
487: BOOL RectInRegion(LPRECT lpRect) const;
488: };
489:
490: /////////////////////////////////////////////////////////////////////////////
491: // The device context
492:
493: class CDC : public CObject
494: {
495: DECLARE_DYNAMIC(CDC)
496: public:
497:
498: // Attributes
499: HDC m_hDC;
500: HDC GetSafeHdc() const;
501:
502: static CDC* FromHandle(HDC hDC);
503: static void DeleteTempMap();
504: BOOL Attach(HDC hDC);
505: HDC Detach();
506:
507: // Constructors
508: CDC();
509:
510: BOOL CreateDC(LPCSTR lpDriverName, LPCSTR lpDeviceName,
511: LPCSTR lpOutput, const void FAR* lpInitData);
512: BOOL CreateIC(LPCSTR lpDriverName, LPCSTR lpDeviceName,
513: LPCSTR lpOutput, const void FAR* lpInitData);
514: BOOL CreateCompatibleDC(CDC* pDC);
515:
516: BOOL DeleteDC();
517: virtual ~CDC();
518:
519: // Implementation support
520: #ifdef _DEBUG
521: virtual void AssertValid() const;
522: virtual void Dump(CDumpContext& dc) const;
523: #endif
524:
525: protected:
526: static CGdiObject* SelectGdiObject(HDC hDC, HANDLE h);
527: public:
528:
529: // Device-Context Functions
530: #ifndef _NTWIN
531: CPoint GetDCOrg() const;
532: #endif
533: int SaveDC() const;
534: BOOL RestoreDC(int nSavedDC);
535: int GetDeviceCaps(int nIndex) const;
536:
537: // Drawing-Tool Functions
538: CPoint GetBrushOrg() const;
539: CPoint SetBrushOrg(int x, int y);
540: CPoint SetBrushOrg(POINT point);
541: int EnumObjects(int nObjectType,
542: int (FAR PASCAL EXPORT* lpfn)(LPSTR, LPSTR),
543: LPSTR lpData);
544:
545: // type-safe selection helpers
546: CGdiObject* SelectObject(CGdiObject* pObject); // do not use for regions
547: CGdiObject* SelectStockObject(int nIndex);
548: CPen* SelectObject(CPen* pPen);
549: CBrush* SelectObject(CBrush* pBrush);
550: CFont* SelectObject(CFont* pFont);
551: CBitmap* SelectObject(CBitmap* pBitmap);
552: int SelectObject(CRgn* pRgn); // special return for regions
553:
554: // Color and Color Palette Functions
555: DWORD GetNearestColor(DWORD crColor) const;
556: CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground);
557: UINT RealizePalette();
558: void UpdateColors();
559:
560: // Drawing-Attribute Functions
561: DWORD GetBkColor() const;
562: DWORD SetBkColor(DWORD crColor);
563: int GetBkMode() const;
564: int SetBkMode(int nBkMode);
565: int GetPolyFillMode() const;
566: int SetPolyFillMode(int nPolyFillMode);
567: int GetROP2() const;
568: int SetROP2(int nDrawMode);
569: int GetStretchBltMode() const;
570: int SetStretchBltMode(int nStretchMode);
571: DWORD GetTextColor() const;
572: DWORD SetTextColor(DWORD crColor);
573:
574: // Mapping Functions
575: int GetMapMode() const;
576: int SetMapMode(int nMapMode);
577: // Viewport Origin
578: CPoint GetViewportOrg() const;
579: CPoint SetViewportOrg(int x, int y);
580: CPoint SetViewportOrg(POINT point);
581: CPoint OffsetViewportOrg(int nWidth, int nHeight);
582:
583: // Viewport Extent
584: CSize GetViewportExt() const;
585: CSize SetViewportExt(int x, int y);
586: CSize SetViewportExt(SIZE size);
587: CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
588:
589: // Window Origin
590: CPoint GetWindowOrg() const;
591: CPoint SetWindowOrg(int x, int y);
592: CPoint SetWindowOrg(POINT point);
593: CPoint OffsetWindowOrg(int nWidth, int nHeight);
594:
595: // Window extent
596: CSize GetWindowExt() const;
597: CSize SetWindowExt(int x, int y);
598: CSize SetWindowExt(SIZE size);
599: CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
600:
601: // Coordinate Functions
602: void DPtoLP(LPPOINT lpPoints, int nCount = 1) const;
603: void DPtoLP(LPRECT lpRect) const;
604: void LPtoDP(LPPOINT lpPoints, int nCount = 1) const;
605: void LPtoDP(LPRECT lpRect) const;
606:
607: // Region Functions
608: BOOL FillRgn(CRgn* pRgn, CBrush* pBrush);
609: BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight);
610: BOOL InvertRgn(CRgn* pRgn);
611: BOOL PaintRgn(CRgn* pRgn);
612:
613: // Clipping Functions
614: int GetClipBox(LPRECT lpRect) const;
615: int SelectClipRgn(CRgn* pRgn);
616: int ExcludeClipRect(int x1, int y1, int x2, int y2);
617: int ExcludeClipRect(LPRECT lpRect);
618: int ExcludeUpdateRgn(CWnd* pWnd);
619: int IntersectClipRect(int x1, int y1, int x2, int y2);
620: int IntersectClipRect(LPRECT lpRect);
621: int OffsetClipRgn(int x, int y);
622: int OffsetClipRgn(SIZE size);
623: BOOL PtVisible(int x, int y) const;
624: BOOL PtVisible(POINT point) const;
625: BOOL RectVisible(LPRECT lpRect) const;
626:
627: // Line-Output Functions
628: CPoint GetCurrentPosition() const;
629: CPoint MoveTo(int x, int y);
630: CPoint MoveTo(POINT point);
631: BOOL LineTo(int x, int y);
632: BOOL LineTo(POINT point);
633: BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
634: BOOL Arc(LPRECT lpRect, POINT ptStart, POINT ptEnd);
635: BOOL Polyline(LPPOINT lpPoints, int nCount);
636:
637: // Simple Drawing Functions
638: void FillRect(LPRECT lpRect, CBrush* pBrush);
639: void FrameRect(LPRECT lpRect, CBrush* pBrush);
640: void InvertRect(LPRECT lpRect);
641: BOOL DrawIcon(int x, int y, HICON hIcon);
642: BOOL DrawIcon(POINT point, HICON hIcon);
643:
644: // Ellipse and Polygon Functions
645: BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3,
646: int x4, int y4);
647: BOOL Chord(LPRECT lpRect, POINT ptStart, POINT ptEnd);
648: void DrawFocusRect(LPRECT lpRect);
649: BOOL Ellipse(int x1, int y1, int x2, int y2);
650: BOOL Ellipse(LPRECT lpRect);
651: BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
652: BOOL Pie(LPRECT lpRect, POINT ptStart, POINT ptEnd);
653: BOOL Polygon(LPPOINT lpPoints, int nCount);
654: BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount);
655: BOOL Rectangle(int x1, int y1, int x2, int y2);
656: BOOL Rectangle(LPRECT lpRect);
657: BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
658: BOOL RoundRect(LPRECT lpRect, POINT point);
659:
660: // Bitmap Function
661: BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop);
662: BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
663: int xSrc, int ySrc, DWORD dwRop);
664: BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
665: int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop);
666: DWORD GetPixel(int x, int y) const;
667: DWORD GetPixel(POINT point) const;
668: DWORD SetPixel(int x, int y, DWORD crColor);
669: DWORD SetPixel(POINT point, DWORD crColor);
670: BOOL FloodFill(int x, int y, DWORD crColor);
671: BOOL ExtFloodFill(int x, int y, DWORD crColor, UINT nFillType);
672:
673: // Text Functions
674: BOOL TextOut(int x, int y, const CString& str);
675: BOOL TextOut(int x, int y, LPCSTR lpString, int nCount);
676: BOOL ExtTextOut(int x, int y, UINT nOptions, LPRECT lpRect,
677: LPCSTR lpString, UINT nCount, LPINT lpDxWidths);
678: CSize TabbedTextOut(int x, int y, LPCSTR lpString, int nCount,
679: int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
680: int DrawText(LPCSTR lpString, int nCount, LPRECT lpRect,
681: UINT nFormat);
682: CSize GetTextExtent(LPCSTR lpString, int nCount) const;
683: CSize GetTabbedTextExtent(LPCSTR lpString, int nCount,
684: int nTabPositions, LPINT lpnTabStopPositions) const;
685: BOOL GrayString(CBrush* pBrush,
686: BOOL (FAR PASCAL EXPORT* lpfnOutput)(HDC, DWORD, int),
687: DWORD lpData, int nCount,
688: int x, int y, int nWidth, int nHeight);
689: UINT GetTextAlign() const;
690: UINT SetTextAlign(UINT nFlags);
691: int GetTextFace(int nCount, LPSTR lpFacename) const;
692: BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const;
693: int SetTextJustification(int nBreakExtra, int nBreakCount);
694: int GetTextCharacterExtra() const;
695: int SetTextCharacterExtra(int nCharExtra);
696:
697: // Font Functions
698: BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
699: DWORD SetMapperFlags(DWORD dwFlag);
700: CSize GetAspectRatioFilter() const;
701:
702: // Printer Escape Functions
703: int Escape(int nEscape, int nCount, LPCSTR lpInData, void FAR* lpOutData);
704:
705: // Escape helpers
706: #ifndef _NTWIN
707: int StartDoc(LPCSTR pDocName);
708: // Windows 3.1 use StartDoc(LPDOCINFO lpDocInfo)
709: #endif
710: int StartPage();
711: int EndPage();
712: int SetAbortProc(BOOL (FAR PASCAL EXPORT* lpfn)(HDC, int));
713: int AbortDoc();
714: int EndDoc();
715:
716: // Scrolling Functions
717: BOOL ScrollDC(int dx, int dy, LPRECT lpRectScroll, LPRECT lpRectClip,
718: CRgn* pRgnUpdate, LPRECT lpRectUpdate);
719:
720: // MetaFile Functions
721: BOOL PlayMetaFile(HANDLE hMF);
722:
723: // Windows 3.1 Specific GDI functions
724: #if (WINVER >= 0x030a)
725: BOOL QueryAbort() const;
726: UINT SetBoundsRect(const RECT FAR* lpRectBounds, UINT flags);
727: UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags);
728: int StartDoc(LPDOCINFO lpDocInfo);
729: BOOL GetCharABCWidths(UINT nFirst, UINT nLast, LPABC lpabc) const;
730: DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const;
731: int GetKerningPairs(int nPairs, KERNINGPAIR FAR* lpkrnpair) const;
732: UINT GetOutlineTextMetrics(UINT cbData, OUTLINETEXTMETRIC FAR* lpotm) const;
733: DWORD GetGlyphOutline(UINT nChar, UINT nFormat, GLYPHMETRICS FAR* lpgm,
734: DWORD cbBuffer, void FAR* lpBuffer, const MAT2 FAR* lpmat2) const;
735: #endif
736:
737: };
738:
739: /////////////////////////////////////////////////////////////////////////////
740: // CDC Helpers
741:
742: class CClientDC : public CDC
743: {
744: DECLARE_DYNAMIC(CClientDC)
745:
746: // Constructors
747: public:
748: CClientDC(CWnd* pWnd);
749:
750: // Attributes
751: protected:
752: HWND m_hWnd;
753:
754: // Implementation
755: public:
756: virtual ~CClientDC();
757: #ifdef _DEBUG
758: virtual void AssertValid() const;
759: virtual void Dump(CDumpContext& dc) const;
760: #endif
761: };
762:
763: class CWindowDC : public CDC
764: {
765: DECLARE_DYNAMIC(CWindowDC)
766:
767: // Constructors
768: public:
769:
770: CWindowDC(CWnd* pWnd);
771:
772: // Attributes
773: protected:
774: HWND m_hWnd;
775:
776: // Implementation
777: public:
778: virtual ~CWindowDC();
779: #ifdef _DEBUG
780: virtual void AssertValid() const;
781: virtual void Dump(CDumpContext& dc) const;
782: #endif
783: };
784:
785: class CPaintDC : public CDC
786: {
787: DECLARE_DYNAMIC(CPaintDC)
788:
789: // Constructors
790: public:
791: CPaintDC(CWnd* pWnd); // BeginPaint
792:
793: // Attributes
794: protected:
795: HWND m_hWnd;
796: public:
797: PAINTSTRUCT m_ps; // actual paint struct !
798:
799: // Implementation
800: virtual ~CPaintDC();
801: #ifdef _DEBUG
802: virtual void AssertValid() const;
803: virtual void Dump(CDumpContext& dc) const;
804: #endif
805: };
806:
807: class CMetaFileDC : public CDC
808: {
809: DECLARE_DYNAMIC(CMetaFileDC)
810:
811: // Constructors
812: public:
813: CMetaFileDC();
814: BOOL Create(LPCSTR lpFilename = NULL);
815:
816: // Special close
817: HANDLE Close();
818:
819: // Operations : selecting in a MetaFile DC returns a BOOL, not old object
820: BOOL SelectObject(CGdiObject* pObject);
821: BOOL SelectStockObject(int nIndex);
822: };
823:
824:
825: /////////////////////////////////////////////////////////////////////////////
826: // CMenu
827:
828: class CMenu : public CObject
829: {
830: DECLARE_DYNAMIC(CMenu)
831: public:
832:
833: // Constructors
834: CMenu();
835:
836: BOOL CreateMenu();
837: BOOL CreatePopupMenu();
838: BOOL LoadMenu(LPCSTR lpMenuName);
839: BOOL LoadMenu(UINT nIDMenu);
840: BOOL LoadMenuIndirect(const void FAR* lpMenuTemplate);
841: BOOL DestroyMenu();
842:
843: // Attributes
844: HMENU m_hMenu;
845: HMENU GetSafeHmenu() const;
846:
847: static CMenu* FromHandle(HMENU hMenu);
848: static void DeleteTempMap();
849: BOOL Attach(HMENU hMenu);
850: HMENU Detach();
851:
852: // CMenu Operations
853: BOOL DeleteMenu(UINT nPosition, UINT nFlags);
854: BOOL TrackPopupMenu(UINT nFlags, int x, int y,
855: const CWnd* pWnd, const RECT FAR* lpRect = 0);
856:
857: // CMenuItem Operations
858: BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0,
859: LPCSTR lpNewItem = NULL);
860: BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp);
861: BOOL CheckMenuItem(UINT nIDCheckItem, UINT nCheck);
862: BOOL EnableMenuItem(UINT nIDEnableItem, UINT nEnable);
863: UINT GetMenuItemCount() const;
864: UINT GetMenuItemID(int nPos) const;
865: UINT GetMenuState(UINT nID, UINT nFlags) const;
866: int GetMenuString(UINT nIDItem, LPSTR lpString, int nMaxCount,
867: UINT nFlags) const;
868: CMenu* GetSubMenu(int nPos) const;
869: BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
870: LPCSTR lpNewItem = NULL);
871: BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
872: const CBitmap* pBmp);
873: BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
874: LPCSTR lpNewItem = NULL);
875: BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
876: const CBitmap* pBmp);
877: BOOL RemoveMenu(UINT nPosition, UINT nFlags);
878: BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags,
879: const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked);
880:
881: // Overridables (must override draw and measure for owner-draw menu items)
882: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
883: virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
884:
885: // Implementation
886: #ifdef _DEBUG
887: virtual void AssertValid() const;
888: virtual void Dump(CDumpContext& dc) const;
889: #endif
890:
891: virtual ~CMenu();
892: };
893:
894: /////////////////////////////////////////////////////////////////////////////
895: // Window wrapping message map
896:
897: struct CMessageEntry; // declared below after CWnd
898: struct NEAR CMessageMap
899: {
900: CMessageMap* pBaseMessageMap;
901: CMessageEntry FAR* lpEntries;
902: };
903:
904: #define DECLARE_MESSAGE_MAP() \
905: private: \
906: static CMessageEntry BASED_CODE _messageEntries[]; \
907: protected: \
908: static CMessageMap messageMap; \
909: virtual CMessageMap* GetMessageMap() const;
910:
911: #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
912: CMessageMap* theClass::GetMessageMap() const \
913: { return &theClass::messageMap; } \
914: CMessageMap theClass::messageMap = \
915: { &(baseClass::messageMap), \
916: (CMessageEntry FAR*) &(theClass::_messageEntries) }; \
917: CMessageEntry BASED_CODE theClass::_messageEntries[] = \
918: {
919:
920: #define END_MESSAGE_MAP() \
921: { 0, 0, AfxSig_end, (AFX_PMSG)0 } \
922: };
923:
924: // Message map signature values and macros in separate header
925: #include "afxmsg.h"
926:
927: /////////////////////////////////////////////////////////////////////////////
928:
929:
930: /////////////////////////////////////////////////////////////////////////////
931: // CWnd - a Microsoft Windows application window
932:
933: class CWnd : public CObject
934: {
935: DECLARE_DYNAMIC(CWnd)
936: protected:
937: static const MSG* GetCurrentMessage();
938:
939: // Attributes
940: public:
941: HWND m_hWnd;
942:
943: HWND GetSafeHwnd() const;
944: DWORD GetStyle() const;
945: DWORD GetExStyle() const;
946:
947: // Constructors and other creation
948: CWnd();
949:
950: static CWnd* FromHandle(HWND hWnd);
951: static CWnd* FromHandlePermanent(HWND hWnd); // INTERNAL USE
952: static void DeleteTempMap();
953: BOOL Attach(HWND hWndNew);
954: HWND Detach();
955: BOOL SubclassWindow(HWND hWnd);
956: BOOL SubclassDlgItem(UINT nID, CWnd* pParent);
957: // for dynamic subclassing of windows control
958:
959: protected: // This CreateEx() wraps CreateWindowEx
960: BOOL CreateEx(DWORD dwExStyle, LPCSTR lpClassName,
961: LPCSTR lpWindowName, DWORD dwStyle,
962: int x, int y, int nWidth, int nHeight,
963: HWND hwndParent, HMENU nIDorHMenu);
964:
965: private:
966: CWnd(HWND hWnd); // just for special initialization
967:
968: public:
969: // for child windows...
970: BOOL Create(LPCSTR lpClassName,
971: LPCSTR lpWindowName, DWORD dwStyle,
972: const RECT& rect,
973: const CWnd* pParentWnd, UINT nID);
974:
975: virtual BOOL DestroyWindow();
976:
977:
978: // Message Functions
979: LONG SendMessage(UINT message, UINT wParam = 0, LONG lParam = 0);
980: BOOL PostMessage(UINT message, UINT wParam = 0, LONG lParam = 0);
981:
982: // Window Text Functions
983: void SetWindowText(LPCSTR lpString);
984: int GetWindowText(LPSTR lpString, int nMaxCount) const;
985: int GetWindowTextLength() const;
986: void GetWindowText(CString& rString) const;
987: void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
988: CFont* GetFont();
989:
990: // CMenu Functions - non-Child windows only
991: CMenu* GetMenu() const;
992: BOOL SetMenu(CMenu* pMenu);
993: void DrawMenuBar();
994: CMenu* GetSystemMenu(BOOL bRevert) const;
995: BOOL HiliteMenuItem(CMenu* pMenu, UINT nIDHiliteItem, UINT nHilite);
996:
997: // Special attributes for Child windows only
998: int GetDlgCtrlID() const;
999:
1000: // Window Size and Position Functions
1001: void CloseWindow();
1002: BOOL OpenIcon();
1003: BOOL IsIconic() const;
1004: BOOL IsZoomed() const;
1005: void MoveWindow(int x, int y, int nWidth, int nHeight,
1006: BOOL bRepaint = TRUE);
1007: void MoveWindow(LPRECT lpRect, BOOL bRepaint = TRUE);
1008:
1009: static const CWnd NEAR wndTop; // SetWindowPos's pWndInsertAfter
1010: static const CWnd NEAR wndBottom; // SetWindowPos's pWndInsertAfter
1011: #if (WINVER >= 0x030a)
1012: static const CWnd NEAR wndTopMost; // SetWindowPos's pWndInsertAfter (3.1)
1013: static const CWnd NEAR wndNoTopMost; // SetWindowPos's pWndInsertAfter (3.1)
1014: #endif /* WINVER >= 0x030a */
1015:
1016: BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
1017: int cx, int cy, UINT nFlags);
1018: UINT ArrangeIconicWindows();
1019: void BringWindowToTop();
1020: void GetWindowRect(LPRECT lpRect) const;
1021: void GetClientRect(LPRECT lpRect) const;
1022:
1023: #if (WINVER >= 0x030a)
1024: BOOL GetWindowPlacement(WINDOWPLACEMENT FAR* lpwndpl) const;
1025: BOOL SetWindowPlacement(const WINDOWPLACEMENT FAR* lpwndpl);
1026: #endif /* WINVER >= 0x030a */
1027:
1028: // Coordinate Mapping Functions
1029: void ClientToScreen(LPPOINT lpPoint) const;
1030: void ClientToScreen(LPRECT lpRect) const;
1031: void ScreenToClient(LPPOINT lpPoint) const;
1032: void ScreenToClient(LPRECT lpRect) const;
1033: #if (WINVER >= 0x030a)
1034: void MapWindowPoints(CWnd* pwndTo, LPPOINT lpPoint, UINT nCount) const;
1035: void MapWindowPoints(CWnd* pwndTo, LPRECT lpRect) const;
1036: #endif /* WINVER >= 0x030a */
1037:
1038: // Update/Painting Functions
1039: CDC* BeginPaint(LPPAINTSTRUCT lpPaint);
1040: void EndPaint(LPPAINTSTRUCT lpPaint);
1041: CDC* GetDC();
1042: CDC* GetWindowDC();
1043: int ReleaseDC(CDC* pDC);
1044:
1045: void UpdateWindow();
1046: void SetRedraw(BOOL bRedraw = TRUE);
1047: BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE);
1048: int GetUpdateRgn(CRgn* pRgn, BOOL bErase = FALSE);
1049: void Invalidate(BOOL bErase = TRUE);
1050: void InvalidateRect(LPRECT lpRect, BOOL bErase = TRUE);
1051: void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
1052: void ValidateRect(LPRECT lpRect);
1053: void ValidateRgn(CRgn* pRgn);
1054: BOOL ShowWindow(int nCmdShow);
1055: BOOL IsWindowVisible() const;
1056: void ShowOwnedPopups(BOOL bShow = TRUE);
1057:
1058: #if (WINVER >= 0x030a)
1059: CDC* GetDCEx(CRgn* prgnClip, DWORD flags);
1060: BOOL LockWindowUpdate();
1061: BOOL RedrawWindow(const RECT FAR* lpRectUpdate = NULL,
1062: CRgn* prgnUpdate = NULL,
1063: UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
1064: BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH);
1065: #endif /* WINVER >= 0x030a */
1066:
1067: // Timer Functions
1068: UINT SetTimer(int nIDEvent, UINT nElapse,
1069: UINT (FAR PASCAL EXPORT* lpfnTimer)(HWND, UINT, int, DWORD));
1070: BOOL KillTimer(int nIDEvent);
1071:
1072: // Window State Functions
1073: BOOL IsWindowEnabled() const;
1074: BOOL EnableWindow(BOOL bEnable = TRUE);
1075:
1076: static CWnd* GetActiveWindow();
1077: CWnd* SetActiveWindow();
1078:
1079: static CWnd* GetCapture();
1080: CWnd* SetCapture();
1081: static CWnd* GetFocus();
1082: CWnd* SetFocus();
1083:
1084: CWnd* SetSysModalWindow();
1085: static CWnd* GetSysModalWindow();
1086:
1087: static CWnd* GetDesktopWindow();
1088:
1089: // Dialog-Box Item Functions
1090: // (NOTE: Dialog-Box Items are not necessarily in dialog boxes!)
1091: void CheckDlgButton(int nIDButton, UINT nCheck);
1092: void CheckRadioButton(int nIDFirstButton, int nIDLastButton,
1093: int nIDCheckButton);
1094: int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton);
1095: int DlgDirList(LPSTR lpPathSpec, int nIDListBox,
1096: int nIDStaticPath, UINT nFileType);
1097: int DlgDirListComboBox(LPSTR lpPathSpec, int nIDComboBox,
1098: int nIDStaticPath, UINT nFileType);
1099: BOOL DlgDirSelect(LPSTR lpString, int nIDListBox);
1100: BOOL DlgDirSelectComboBox(LPSTR lpString, int nIDComboBox);
1101:
1102: CWnd* GetDlgItem(int nID) const;
1103: UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL,
1104: BOOL bSigned = TRUE) const;
1105: int GetDlgItemText(int nID, LPSTR lpStr, int nMaxCount) const;
1106:
1107: CWnd* GetNextDlgGroupItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
1108:
1109: CWnd* GetNextDlgTabItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
1110: UINT IsDlgButtonChecked(int nIDButton) const;
1111: LONG SendDlgItemMessage(int nID, UINT message,
1112: UINT wParam = 0, LONG lParam = 0);
1113: void SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE);
1114: void SetDlgItemText(int nID, LPCSTR lpString);
1115:
1116: // Scrolling Functions
1117: int GetScrollPos(int nBar) const;
1118: void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const;
1119: void ScrollWindow(int xAmount, int yAmount,
1120: const RECT FAR* lpRect = NULL,
1121: const RECT FAR* lpClipRect = NULL);
1122: int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
1123: void SetScrollRange(int nBar, int nMinPos, int nMaxPos,
1124: BOOL bRedraw = TRUE);
1125: void ShowScrollBar(UINT nBar, BOOL bShow = TRUE);
1126: #if (WINVER >= 0x030a)
1127: int ScrollWindowEx(int dx, int dy,
1128: const RECT FAR* lpRectScroll, const RECT FAR* lpRectClip,
1129: CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags);
1130: #endif /* WINVER >= 0x030a */
1131:
1132: // Window Access Functions
1133: CWnd* ChildWindowFromPoint(POINT point) const;
1134: static CWnd* FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName);
1135: CWnd* GetNextWindow(UINT nFlag = GW_HWNDNEXT) const;
1136: CWnd* GetTopWindow() const;
1137:
1138: CWnd* GetWindow(UINT nCmd) const;
1139: CWnd* GetLastActivePopup() const;
1140:
1141: BOOL IsChild(CWnd* pWnd) const;
1142: CWnd* GetParent() const;
1143: CWnd* SetParent(CWnd* pWndNewParent);
1144: static CWnd* WindowFromPoint(POINT point);
1145:
1146: // Alert Functions
1147: BOOL FlashWindow(BOOL bInvert);
1148: int MessageBox(LPCSTR lpText, LPCSTR lpCaption = NULL,
1149: UINT nType = MB_OK);
1150:
1151: // Clipboard Functions
1152: BOOL ChangeClipboardChain(HWND hWndNext);
1153: HWND SetClipboardViewer();
1154: BOOL OpenClipboard();
1155: static CWnd* GetClipboardOwner();
1156: static CWnd* GetClipboardViewer();
1157: #if (WINVER >= 0x030a)
1158: static CWnd* GetOpenClipboardWindow();
1159: #endif /* WINVER >= 0x030a */
1160:
1161: // Caret Functions
1162: void CreateCaret(CBitmap* pBitmap);
1163: void CreateSolidCaret(int nWidth, int nHeight);
1164: void CreateGrayCaret(int nWidth, int nHeight);
1165: static CPoint GetCaretPos();
1166: static void SetCaretPos(POINT point);
1167: void HideCaret();
1168: void ShowCaret();
1169:
1170: // Window-Management message handler member functions
1171: protected:
1172: virtual BOOL OnCommand(UINT wParam, LONG lParam);
1173:
1174: afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
1175: afx_msg void OnActivateApp(BOOL bActive, HANDLE hTask);
1176: afx_msg void OnCancelMode();
1177: afx_msg void OnChildActivate();
1178: afx_msg void OnClose();
1179: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
1180:
1181: #ifdef _NTWIN
1182: // special handler to fan in WM_CTLCOLOR - implementation
1183: afx_msg LRESULT OnNTCtlColor(WPARAM wParam, LPARAM lParam);
1184: #endif
1185: afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
1186:
1187: afx_msg void OnDestroy();
1188: afx_msg void OnEnable(BOOL bEnable);
1189: afx_msg void OnEndSession(BOOL bEnding);
1190: afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
1191: afx_msg BOOL OnEraseBkgnd(CDC* pDC);
1192: afx_msg void OnGetMinMaxInfo(LPPOINT lpPoints);
1193: afx_msg void OnIconEraseBkgnd(CDC* pDC);
1194: afx_msg void OnKillFocus(CWnd* pNewWnd);
1195: afx_msg LONG OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
1196: afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
1197: afx_msg void OnMove(int x, int y);
1198: afx_msg void OnPaint();
1199: afx_msg void OnParentNotify(UINT message, LONG lParam);
1200: afx_msg HCURSOR OnQueryDragIcon();
1201: afx_msg BOOL OnQueryEndSession();
1202: afx_msg BOOL OnQueryNewPalette();
1203: afx_msg BOOL OnQueryOpen();
1204: afx_msg void OnSetFocus(CWnd* pOldWnd);
1205: afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
1206: afx_msg void OnSize(UINT nType, int cx, int cy);
1207: #if (WINVER >= 0x030a)
1208: afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
1209: afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
1210: #endif /* WINVER >= 0x030a */
1211:
1212: // Nonclient-Area message handler member functions
1213: afx_msg BOOL OnNcActivate(BOOL bActive);
1214: afx_msg void OnNcCalcSize(NCCALCSIZE_PARAMS FAR* lpncsp);
1215: afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
1216: afx_msg void OnNcDestroy();
1217: afx_msg UINT OnNcHitTest(CPoint point);
1218: afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
1219: afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
1220: afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
1221: afx_msg void OnNcMButtonDblClk(UINT nHitTest, CPoint point);
1222: afx_msg void OnNcMButtonDown(UINT nHitTest, CPoint point);
1223: afx_msg void OnNcMButtonUp(UINT nHitTest, CPoint point);
1224: afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
1225: afx_msg void OnNcPaint();
1226: afx_msg void OnNcRButtonDblClk(UINT nHitTest, CPoint point);
1227: afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
1228: afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
1229:
1230: // System message handler member functions
1231: #if (WINVER >= 0x030a)
1232: afx_msg void OnDropFiles(HANDLE hDropInfo);
1233: afx_msg void OnPaletteIsChanging(CWnd* pRealizeWnd);
1234: #endif /* WINVER >= 0x030a */
1235: afx_msg void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags);
1236: afx_msg void OnSysCommand(UINT nID, LONG lParam);
1237: afx_msg void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
1238: afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
1239: afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
1240: afx_msg void OnCompacting(UINT nCpuTime);
1241: afx_msg void OnDevModeChange(LPSTR lpDeviceName);
1242: afx_msg void OnFontChange();
1243: afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
1244: afx_msg void OnSpoolerStatus(UINT nStatus, UINT nJobs);
1245: afx_msg void OnSysColorChange();
1246: afx_msg void OnTimeChange();
1247: afx_msg void OnWinIniChange(LPSTR lpSection);
1248:
1249: // Input message handler member functions
1250: afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
1251: afx_msg void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
1252: afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
1253: afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
1254: afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
1255: afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
1256: afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
1257: afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
1258: afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
1259: afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
1260: afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
1261: afx_msg int OnMouseActivate(CWnd* pFrameWnd, UINT nHitTest, UINT message);
1262: afx_msg void OnMouseMove(UINT nFlags, CPoint point);
1263: afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
1264: afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
1265: afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
1266: afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
1267: afx_msg void OnTimer(UINT nIDEvent);
1268: afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
1269:
1270: // Initialization message handler member functions
1271: afx_msg void OnInitMenu(CMenu* pMenu);
1272: afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
1273:
1274: // Clipboard message handler member functions
1275: afx_msg void OnAskCbFormatName(UINT nMaxCount, LPSTR lpString);
1276: afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
1277: afx_msg void OnDestroyClipboard();
1278: afx_msg void OnDrawClipboard();
1279: afx_msg void OnHScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
1280: afx_msg void OnPaintClipboard(CWnd* pClipAppWnd, HANDLE hPaintStruct);
1281: afx_msg void OnRenderAllFormats();
1282: afx_msg void OnRenderFormat(UINT nFormat);
1283: afx_msg void OnSizeClipboard(CWnd* pClipAppWnd, HANDLE hRect);
1284: afx_msg void OnVScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
1285:
1286: // Control message handler member functions
1287: afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex);
1288: afx_msg int OnCompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
1289: afx_msg void OnDeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
1290: afx_msg void OnDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
1291: afx_msg UINT OnGetDlgCode();
1292: afx_msg void OnMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
1293: afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
1294:
1295: // MDI message handler member functions
1296: afx_msg void OnMDIActivate(BOOL bActivate,
1297: CWnd* pActivateWnd, CWnd* pDeactivateWnd);
1298:
1299: // Overridables and other helpers (for implementation of derived classes)
1300: protected:
1301: // for deriving from a standard control
1302: virtual WNDPROC* GetSuperWndProcAddr();
1303:
1304: // for translating Windows messages in main message pump
1305: virtual BOOL PreTranslateMessage(MSG* pMsg);
1306:
1307: // for processing Windows messages
1308: virtual LONG WindowProc(UINT message, UINT wParam, LONG lParam);
1309:
1310: // for handling default processing
1311: LONG Default();
1312: virtual LONG DefWindowProc(UINT message, UINT wParam, LONG lParam);
1313:
1314: // for custom cleanup after WM_NCDESTROY
1315: virtual void PostNcDestroy();
1316:
1317: // Implementation
1318: public:
1319: virtual ~CWnd();
1320: #ifdef _DEBUG
1321: virtual void AssertValid() const;
1322: virtual void Dump(CDumpContext& dc) const;
1323: #endif
1324:
1325: protected:
1326: friend void FAR PASCAL AFX_EXPORT _AfxSendMsgHook(int, UINT, LONG);
1327: friend LONG _AfxCallWndProc(CWnd*, HWND, UINT, UINT, LONG);
1328:
1329: friend class CWinApp; // for PreTranslate access
1330:
1331: DECLARE_MESSAGE_MAP()
1332: };
1333:
1334: // helpers for registering your own WNDCLASSes
1335: const char* AfxRegisterWndClass(UINT nClassStyle,
1336: HCURSOR hCursor = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0);
1337:
1338: LONG FAR PASCAL AFX_EXPORT AfxWndProc(HWND, UINT, UINT, LONG);
1339:
1340: /////////////////////////////////////////////////////////////////////////////
1341: // pointer to afx_msg member function
1342:
1343: #define AFX_MSG_CALL PASCAL
1344:
1345: typedef void (AFX_MSG_CALL CWnd::*AFX_PMSG)(void);
1346: struct CMessageEntry
1347: {
1348: UINT nMessage; // windows message or control notification code
1349: UINT nID; // control ID (or 0 for windows messages)
1350: UINT nSig; // signature type (action) or near pointer to extra
1351: AFX_PMSG pfn; // routine to call (or special value)
1352: };
1353:
1354: /////////////////////////////////////////////////////////////////////////////
1355: // CDialog, CModalDialog
1356:
1357:
1358: class CDialog : public CWnd
1359: {
1360: DECLARE_DYNAMIC(CDialog)
1361: public:
1362:
1363: // Constructors (protected since you must subclass to implement a Dialog)
1364: protected:
1365: // Modeless construct
1366: CDialog();
1367: ~CDialog();
1368:
1369: BOOL Create(LPCSTR lpTemplateName, CWnd* pParentWnd = NULL);
1370: BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
1371:
1372: // Generic construct (for modal too)
1373: BOOL CreateIndirect(const void FAR* lpDialogTemplate,
1374: CWnd* pParentWnd = NULL);
1375:
1376: // Attributes
1377: public:
1378: void MapDialogRect(LPRECT lpRect) const;
1379:
1380: protected:
1381: HBRUSH m_hBrushCtlBk;
1382:
1383: // Operations
1384: public:
1385: // message processing for modeless
1386: BOOL IsDialogMessage(LPMSG lpMsg);
1387:
1388: // support for passing on tab control - use 'PostMessage' if needed
1389: void NextDlgCtrl() const;
1390: void PrevDlgCtrl() const;
1391: void GotoDlgCtrl(CWnd* pWndCtrl);
1392:
1393: // default button access
1394: void SetDefID(UINT nID);
1395: DWORD GetDefID();
1396:
1397: // support for "new look" dialog boxes, set background color with this
1398: BOOL SetCtlBkColor(COLORREF clrCtlBk);
1399:
1400: // termination
1401: void EndDialog(int nResult);
1402:
1403: // Overridables (special message map entries)
1404: virtual BOOL OnInitDialog();
1405: virtual void OnSetFont(CFont* pFont);
1406:
1407: // Default implementation sets colors to the "new look"
1408: afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
1409:
1410: // Implementation
1411: #ifdef _DEBUG
1412: virtual void AssertValid() const;
1413: #endif
1414:
1415: protected:
1416: virtual BOOL PreTranslateMessage(MSG* pMsg);
1417: virtual WNDPROC* GetSuperWndProcAddr();
1418:
1419: DECLARE_MESSAGE_MAP()
1420: };
1421:
1422: class CModalDialog : public CDialog
1423: {
1424: DECLARE_DYNAMIC(CModalDialog)
1425:
1426: // Constructors
1427: public:
1428: CModalDialog(LPCSTR lpTemplateName, CWnd* pParentWnd = NULL);
1429: CModalDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);
1430:
1431: // advanced usage - create indirect
1432: BOOL CreateIndirect(HANDLE hDialogTemplate);
1433:
1434: // Operations
1435: virtual int DoModal();
1436:
1437: // Overridables (automatic message map entries)
1438: protected:
1439: virtual void OnOK();
1440: virtual void OnCancel();
1441:
1442: // Implementation
1443: #ifdef _DEBUG
1444: public:
1445: virtual void AssertValid() const;
1446: virtual void Dump(CDumpContext& dc) const;
1447: #endif
1448:
1449: protected:
1450:
1451: // parameters for 'DoModal'
1452: LPCSTR m_lpDialogTemplate; // name or MAKEINTRESOURCE
1453: HANDLE m_hDialogTemplate; // Indirect if (lpDialogTemplate == NULL)
1454: CWnd* m_pParentWnd;
1455:
1456: DECLARE_MESSAGE_MAP()
1457: };
1458:
1459: /////////////////////////////////////////////////////////////////////////////
1460: // Standard Windows controls
1461:
1462: class CStatic : public CWnd
1463: {
1464: DECLARE_DYNAMIC(CStatic)
1465:
1466: // Constructors
1467: public:
1468: CStatic();
1469: BOOL Create(LPCSTR lpText, DWORD dwStyle,
1470: const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff);
1471:
1472: #if (WINVER >= 0x030a)
1473: HICON SetIcon(HICON hIcon);
1474: HICON GetIcon() const;
1475: #endif /* WINVER >= 0x030a */
1476:
1477:
1478: // Implementation
1479: protected:
1480: virtual WNDPROC* GetSuperWndProcAddr();
1481: };
1482:
1483: class CButton : public CWnd
1484: {
1485: DECLARE_DYNAMIC(CButton)
1486:
1487: // Constructors
1488: public:
1489: CButton();
1490: BOOL Create(LPCSTR lpCaption, DWORD dwStyle,
1491: const RECT& rect, CWnd* pParentWnd, UINT nID);
1492:
1493: // Attributes
1494: UINT GetState() const;
1495: void SetState(BOOL bHighlight);
1496: int GetCheck() const;
1497: void SetCheck(int nCheck);
1498: UINT GetButtonStyle() const;
1499: void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);
1500:
1501: // Overridables (for owner draw only)
1502: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
1503:
1504: // Implementation
1505: protected:
1506: virtual WNDPROC* GetSuperWndProcAddr();
1507: };
1508:
1509:
1510: class CListBox : public CWnd
1511: {
1512: DECLARE_DYNAMIC(CListBox)
1513:
1514: // Constructors
1515: public:
1516: CListBox();
1517: BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
1518:
1519: // Attributes
1520:
1521: // for entire listbox
1522: int GetCount() const;
1523: int GetHorizontalExtent() const;
1524: void SetHorizontalExtent(int cxExtent);
1525: int GetTopIndex() const;
1526: int SetTopIndex(int nIndex);
1527:
1528: // for single-selection listboxes
1529: int GetCurSel() const;
1530: int SetCurSel(int nSelect);
1531:
1532: // for multiple-selection listboxes
1533: int GetSel(int nIndex) const; // also works for single-selection
1534: int SetSel(int nIndex, BOOL bSelect = TRUE);
1535: int GetSelCount() const;
1536: int GetSelItems(int nMaxItems, LPINT rgIndex) const;
1537:
1538: // for listbox items
1539: DWORD GetItemData(int nIndex) const;
1540: int SetItemData(int nIndex, DWORD dwItemData);
1541: int GetItemRect(int nIndex, LPRECT lpRect) const;
1542: int GetText(int nIndex, LPSTR lpBuffer) const;
1543: int GetTextLen(int nIndex) const;
1544: void GetText(int nIndex, CString& rString) const;
1545:
1546: // Settable only attributes
1547: void SetColumnWidth(int cxWidth);
1548: BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
1549: void SetTabStops();
1550: BOOL SetTabStops(int cxEachStop);
1551:
1552: #if (WINVER >= 0x030a)
1553: int SetItemHeight(int nIndex, UINT cyItemHeight);
1554: int GetItemHeight(int nIndex) const;
1555: int FindStringExact(int nIndexStart, LPCSTR lpszFind) const;
1556: int GetCaretIndex() const;
1557: int SetCaretIndex(int nIndex, BOOL bScroll = TRUE);
1558:
1559: #endif /* WINVER >= 0x030a */
1560:
1561: // Operations
1562: // manipulating listbox items
1563: int AddString(LPCSTR lpItem);
1564: int DeleteString(UINT nIndex);
1565: int InsertString(int nIndex, LPCSTR lpItem);
1566: void ResetContent();
1567: int Dir(UINT attr, LPCSTR lpWildCard);
1568:
1569: // selection helpers
1570: int FindString(int nStartAfter, LPCSTR lpItem) const;
1571: int SelectString(int nStartAfter, LPCSTR lpItem);
1572: int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem);
1573:
1574: // Overridables (must override draw, measure and compare for owner draw)
1575: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
1576: virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
1577: virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
1578: virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
1579:
1580: // Implementation
1581: protected:
1582: virtual WNDPROC* GetSuperWndProcAddr();
1583: };
1584:
1585: class CComboBox : public CWnd
1586: {
1587: DECLARE_DYNAMIC(CComboBox)
1588:
1589: // Constructors
1590: public:
1591: CComboBox();
1592: BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
1593:
1594: // Attributes
1595: // for entire combo box
1596: int GetCount() const;
1597: int GetCurSel() const;
1598: int SetCurSel(int nSelect);
1599:
1600: // for edit control
1601: DWORD GetEditSel() const;
1602: BOOL LimitText(int nMaxChars);
1603: BOOL SetEditSel(int nStartChar, int nEndChar);
1604:
1605: // for combobox item
1606: DWORD GetItemData(int nIndex) const;
1607: int SetItemData(int nIndex, DWORD dwItemData);
1608: int GetLBText(int nIndex, LPSTR lpText) const;
1609: int GetLBTextLen(int nIndex) const;
1610: void GetLBText(int nIndex, CString& rString) const;
1611:
1612: #if (WINVER >= 0x030a)
1613: int SetItemHeight(int nIndex, UINT cyItemHeight);
1614: int GetItemHeight(int nIndex) const;
1615: int FindStringExact(int nIndexStart, LPCSTR lpszFind) const;
1616: int SetExtendedUI(BOOL bExtended = TRUE);
1617: BOOL GetExtendedUI() const;
1618: void GetDroppedControlRect(LPRECT lprect) const;
1619: BOOL GetDroppedState() const;
1620: #endif /* WINVER >= 0x030a */
1621:
1622: // Operations
1623: // for drop-down combo boxes
1624: void ShowDropDown(BOOL bShowIt = TRUE);
1625:
1626: // manipulating listbox items
1627: int AddString(LPCSTR lpString);
1628: int DeleteString(UINT nIndex);
1629: int InsertString(int nIndex, LPCSTR lpString);
1630: void ResetContent();
1631: int Dir(UINT attr, LPCSTR lpWildCard);
1632:
1633: // selection helpers
1634: int FindString(int nStartAfter, LPCSTR lpString) const;
1635: int SelectString(int nStartAfter, LPCSTR lpString);
1636:
1637: // Clipboard operations
1638: void Clear();
1639: void Copy();
1640: void Cut();
1641: void Paste();
1642:
1643: // Overridables (must override draw, measure and compare for owner draw)
1644: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
1645: virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
1646: virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
1647: virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
1648:
1649: // Implementation
1650: protected:
1651: virtual WNDPROC* GetSuperWndProcAddr();
1652: };
1653:
1654:
1655: class CEdit : public CWnd
1656: {
1657: DECLARE_DYNAMIC(CEdit)
1658:
1659: // Constructors
1660: public:
1661: CEdit();
1662: BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
1663:
1664: // Attributes
1665: BOOL CanUndo() const;
1666: int GetLineCount() const;
1667: BOOL GetModify() const;
1668: void SetModify(BOOL bModified = TRUE);
1669: void GetRect(LPRECT lpRect) const;
1670: DWORD GetSel() const;
1671: HANDLE GetHandle() const;
1672: void SetHandle(HANDLE hBuffer);
1673:
1674: // NOTE: first word in lpBuffer must contain the size of the buffer!
1675: int GetLine(int nIndex, LPSTR lpBuffer) const;
1676: int GetLine(int nIndex, LPSTR lpBuffer, int nMaxLength) const;
1677:
1678: // Operations
1679: void EmptyUndoBuffer();
1680: BOOL FmtLines(BOOL bAddEOL);
1681:
1682: void LimitText(int nChars = 0);
1683: int LineFromChar(int nIndex = -1) const;
1684: int LineIndex(int nLine = -1) const;
1685: int LineLength(int nLine = -1) const;
1686: void LineScroll(int nLines, int nChars = 0);
1687: void ReplaceSel(LPCSTR lpNewText);
1688: void SetPasswordChar(char ch);
1689: void SetRect(LPRECT lpRect);
1690: void SetRectNP(LPRECT lpRect);
1691: void SetSel(DWORD dwSelection);
1692: void SetSel(int nStartChar, int nEndChar);
1693: BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
1694: void SetTabStops();
1695: BOOL SetTabStops(int cxEachStop);
1696:
1697: // Clipboard operations
1698: BOOL Undo();
1699: void Clear();
1700: void Copy();
1701: void Cut();
1702: void Paste();
1703:
1704: #if (WINVER >= 0x030a)
1705: BOOL SetReadOnly(BOOL bReadOnly = TRUE);
1706: int GetFirstVisibleLine() const;
1707: char GetPasswordChar() const;
1708: #endif /* WINVER >= 0x030a */
1709:
1710: // Implementation
1711: protected:
1712: virtual WNDPROC* GetSuperWndProcAddr();
1713: };
1714:
1715:
1716: class CScrollBar : public CWnd
1717: {
1718: DECLARE_DYNAMIC(CScrollBar)
1719:
1720: // Constructors
1721: public:
1722: CScrollBar();
1723: BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
1724:
1725: // Attributes
1726: int GetScrollPos() const;
1727: int SetScrollPos(int nPos, BOOL bRedraw = TRUE);
1728: void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const;
1729: void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE);
1730: void ShowScrollBar(BOOL bShow = TRUE);
1731:
1732: #if (WINVER >= 0x030a)
1733: BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH);
1734: #endif /* WINVER >= 0x030a */
1735:
1736: // Implementation
1737: protected:
1738: virtual WNDPROC* GetSuperWndProcAddr();
1739: };
1740:
1741: /////////////////////////////////////////////////////////////////////////////
1742: // Extra Custom Controls
1743:
1744: // CBitmapButton - push-button with 2 or 3 bitmap images
1745: class CBitmapButton : public CButton
1746: {
1747: DECLARE_DYNAMIC(CBitmapButton)
1748:
1749: protected:
1750: // all bitmaps must be the same size
1751: CBitmap m_bitmap; // normal image (REQUIRED)
1752: CBitmap m_bitmapSel; // selected image (OPTIONAL)
1753: CBitmap m_bitmapFocus; // focused but not selected (OPTIONAL)
1754:
1755: public:
1756: // Construction
1757: CBitmapButton();
1758: CBitmapButton(LPCSTR lpBitmapResource, LPCSTR lpBitmapResourceSel = NULL,
1759: LPCSTR lpBitmapResourceFocus = NULL);
1760:
1761: BOOL LoadBitmaps(LPCSTR lpBitmapResource, LPCSTR lpBitmapResourceSel = NULL,
1762: LPCSTR lpBitmapResourceFocus = NULL);
1763: BOOL AutoLoad(UINT nID, CWnd* pParent);
1764:
1765: // Operations
1766: void SizeToContent();
1767:
1768: // Implementation:
1769: protected:
1770: virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
1771: };
1772:
1773: /////////////////////////////////////////////////////////////////////////////
1774: // CFrameWnd
1775:
1776: class CFrameWnd : public CWnd
1777: {
1778: DECLARE_DYNAMIC(CFrameWnd)
1779:
1780: protected:
1781: // Protected attributes
1782: HACCEL m_hAccelTable;
1783:
1784: public:
1785: static const CRect NEAR rectDefault;
1786:
1787: // Constructors
1788: CFrameWnd();
1789:
1790: BOOL LoadAccelTable(LPCSTR lpAccelTableName);
1791: BOOL Create(LPCSTR lpClassName,
1792: LPCSTR lpWindowName,
1793: DWORD dwStyle = WS_OVERLAPPEDWINDOW,
1794: const RECT& rect = rectDefault,
1795: const CWnd* pParentWnd = NULL, // != NULL for popups
1796: LPCSTR lpMenuName = NULL);
1797:
1798: // Implementation
1799: public:
1800: #ifdef _DEBUG
1801: virtual void AssertValid() const;
1802: virtual void Dump(CDumpContext& dc) const;
1803: #endif
1804:
1805: virtual ~CFrameWnd();
1806:
1807: virtual CFrameWnd* GetParentFrame();
1808: virtual CFrameWnd* GetChildFrame();
1809:
1810: protected:
1811: virtual BOOL PreTranslateMessage(MSG* pMsg);
1812: virtual void PostNcDestroy(); // default to delete this.
1813: };
1814:
1815: /////////////////////////////////////////////////////////////////////////////
1816: // MDI Support
1817:
1818: class CMDIFrameWnd : public CFrameWnd
1819: {
1820: DECLARE_DYNAMIC(CMDIFrameWnd)
1821: public:
1822:
1823: // Constructors
1824: CMDIFrameWnd();
1825:
1826: BOOL Create(LPCSTR lpClassName,
1827: LPCSTR lpWindowName,
1828: DWORD dwStyle,
1829: const RECT& rect,
1830: const CWnd* pParentWnd,
1831: LPCSTR lpMenuName);
1832:
1833: // Overridables (automatic message map entries)
1834: protected:
1835: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
1836:
1837: // Attributes
1838: public:
1839: HWND m_hWndMDIClient;
1840:
1841: virtual BOOL CreateClient(LPCREATESTRUCT lpCreateStruct,
1842: CMenu* pWindowMenu);
1843:
1844: void MDIActivate(CWnd* pWndActivate);
1845: CMDIChildWnd* MDIGetActive(BOOL* pbMaximized = NULL) const;
1846: void MDIIconArrange();
1847: void MDIMaximize(CWnd* pWnd);
1848: void MDINext();
1849: void MDIRestore(CWnd* pWnd);
1850: CMenu* MDISetMenu(CMenu* pFrameMenu, CMenu* pWindowMenu);
1851:
1852: void MDICascade();
1853: void MDITile();
1854:
1855: #if (WINVER >= 0x030a)
1856: void MDITile(int nType);
1857: void MDICascade(int nType);
1858: #endif /* WINVER >= 0x030a */
1859:
1860: // Implementation
1861: public:
1862: #ifdef _DEBUG
1863: virtual void AssertValid() const;
1864: #endif
1865: virtual CFrameWnd* GetChildFrame();
1866: protected:
1867: virtual BOOL PreTranslateMessage(MSG* pMsg);
1868: virtual LONG DefWindowProc(UINT nMsg, UINT wParam, LONG lParam);
1869: virtual BOOL OnCommand(UINT wParam, LONG lParam);
1870: protected:
1871: DECLARE_MESSAGE_MAP()
1872:
1873: friend class CMDIChildWnd;
1874: };
1875:
1876:
1877: class CMDIChildWnd : public CFrameWnd
1878: {
1879: DECLARE_DYNAMIC(CMDIChildWnd)
1880: protected:
1881: CMDIFrameWnd* m_pMDIFrameWnd; // our MDIFrame parent
1882:
1883: // Constructors
1884: public:
1885: CMDIChildWnd();
1886:
1887: BOOL Create(LPCSTR lpClassName,
1888: LPCSTR lpWindowName,
1889: DWORD dwStyle = 0,
1890: const RECT& rect = rectDefault,
1891: CMDIFrameWnd* pParentWnd = NULL);
1892:
1893: // Operations
1894: void MDIDestroy();
1895: void MDIActivate();
1896: void MDIMaximize();
1897: void MDIRestore();
1898:
1899: // Implementation
1900: public:
1901: #ifdef _DEBUG
1902: virtual void AssertValid() const;
1903: virtual void Dump(CDumpContext& dc) const;
1904: #endif
1905:
1906: virtual BOOL DestroyWindow();
1907: virtual CFrameWnd* GetParentFrame();
1908: protected:
1909: virtual BOOL PreTranslateMessage(MSG* pMsg);
1910: virtual LONG DefWindowProc(UINT nMsg, UINT wParam, LONG lParam);
1911:
1912: friend class CMDIFrameWnd;
1913: };
1914:
1915: /////////////////////////////////////////////////////////////////////////////
1916: // Global functions for access to the one and only CWinApp
1917:
1918: extern "C"
1919: {
1920: // standard C variables if you wish to access them from C programs,
1921: // use inline functions for C++ programs
1922: extern CWinApp* afxCurrentWinApp;
1923: extern HANDLE afxCurrentInstanceHandle;
1924: extern HANDLE afxCurrentResourceHandle;
1925: extern const char* afxCurrentAppName;
1926: extern BOOL AfxWinInit(HINSTANCE, HINSTANCE, LPSTR, int);
1927: extern void AfxWinTerm();
1928: }
1929:
1930: // Global Windows state data helper functions (inlines)
1931: CWinApp* AfxGetApp();
1932: HINSTANCE AfxGetInstanceHandle();
1933: HINSTANCE AfxGetResourceHandle();
1934: const char* AfxGetAppName();
1935:
1936: /////////////////////////////////////////////////////////////////////////////
1937: // CWinApp - the world's simplest Windows application
1938:
1939: class CWinApp : public CObject
1940: {
1941: DECLARE_DYNAMIC(CWinApp)
1942: public:
1943:
1944: // Constructor
1945: CWinApp(const char* pszAppName = NULL);
1946: void SetCurrentHandles();
1947:
1948: // Attributes
1949: // Startup args (do not change)
1950: const char* m_pszAppName; // from constructor
1951: HINSTANCE m_hInstance;
1952: HINSTANCE m_hPrevInstance;
1953: LPSTR m_lpCmdLine;
1954: int m_nCmdShow;
1955:
1956: // Running args
1957: CWnd* m_pMainWnd; // main window (optional)
1958:
1959: // Operations
1960: // Cursors
1961: HCURSOR LoadCursor(LPCSTR lpCursorName);
1962: HCURSOR LoadCursor(UINT nIDCursor);
1963: HCURSOR LoadStandardCursor(LPCSTR lpCursorName); // for IDC_ values
1964: HCURSOR LoadOEMCursor(UINT nIDCursor); // for OCR_ values
1965:
1966: // Icons
1967: HICON LoadIcon(LPCSTR lpIconName);
1968: HICON LoadIcon(UINT nIDIcon);
1969: HICON LoadStandardIcon(LPCSTR lpIconName); // for IDI_ values
1970: HICON LoadOEMIcon(UINT nIDIcon); // for OIC_ values
1971:
1972: BOOL PumpMessage();
1973:
1974: // Overridables
1975: // hooks for your initialization code
1976: virtual BOOL InitApplication();
1977: virtual BOOL InitInstance();
1978:
1979: virtual int Run();
1980:
1981: // called by standard 'Run' implementation
1982: virtual BOOL PreTranslateMessage(MSG* pMsg);
1983: virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
1984: virtual int ExitInstance(); // return app exit code
1985:
1986:
1987: // Implementation
1988: #ifdef _DEBUG
1989: virtual void AssertValid() const;
1990: virtual void Dump(CDumpContext& dc) const;
1991: #endif
1992:
1993: protected:
1994: MSG m_msgCur;
1995:
1996: #ifdef _DEBUG
1997: // Diagnostic trap for when going back to message pump is not permitted.
1998: protected:
1999: int m_nDisablePumpCount;
2000: public:
2001: void EnablePump(BOOL bEnable);
2002: #endif
2003:
2004: };
2005:
2006: /////////////////////////////////////////////////////////////////////////////
2007: // Extra diagnostic tracing options
2008:
2009: #ifdef _WINDOWS
2010: extern "C" extern int afxTraceFlags;
2011: // 1 => multi-app debugging
2012: // 2 => main message pump trace (includes DDE)
2013: // 4 => Windows message tracing
2014: // 8 => Windows command routing trace (set 4+8 for control notifications)
2015: // 16 (0x10) => special OLE callback trace
2016: #endif // _WINDOWS
2017:
2018: /////////////////////////////////////////////////////////////////////////////
2019: // Inline function declarations
2020:
2021: #include "afxwin.inl"
2022:
2023:
2024: #endif //__AFXWIN_H__
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.