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