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