]>
Commit | Line | Data |
---|---|---|
df62e023 RC |
1 | #ifndef CINSTALL_WINDOW_H |
2 | #define CINSTALL_WINDOW_H | |
3 | ||
4 | /* | |
5 | * Copyright (c) 2001, Gary R. Van Sickle. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * A copy of the GNU General Public License can be found at | |
13 | * http://www.gnu.org/ | |
14 | * | |
15 | * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net> | |
16 | * | |
17 | */ | |
18 | ||
19 | // This is the header for the Window class. It serves both as a window class | |
20 | // in its own right and as a base class for other window-like classes (e.g. PropertyPage, | |
21 | // PropSheet). | |
22 | ||
23 | #include <windows.h> | |
24 | ||
25 | class Window | |
26 | { | |
27 | static ATOM WindowClassAtom; | |
28 | static HINSTANCE AppInstance; | |
29 | ||
30 | ||
31 | bool RegisterWindowClass (); | |
32 | static LRESULT CALLBACK FirstWindowProcReflector (HWND hwnd, UINT uMsg, | |
33 | WPARAM wParam, | |
34 | LPARAM lParam); | |
35 | static LRESULT CALLBACK WindowProcReflector (HWND hwnd, UINT uMsg, | |
36 | WPARAM wParam, LPARAM lParam); | |
37 | ||
38 | HWND WindowHandle; | |
39 | ||
40 | Window *Parent; | |
41 | ||
b7301c43 RC |
42 | // FIXME: replace with <vector> when we get a chance. |
43 | static const int MAXFONTS = 5; | |
44 | HFONT Fonts[MAXFONTS]; | |
45 | int FontCounter; | |
46 | ||
df62e023 RC |
47 | protected: |
48 | void SetHWND (HWND h) | |
49 | { | |
50 | WindowHandle = h; | |
51 | }; | |
52 | ||
53 | public: | |
54 | Window (); | |
55 | virtual ~ Window (); | |
56 | ||
57 | static void SetAppInstance (HINSTANCE h) | |
58 | { | |
59 | AppInstance = h; | |
60 | }; | |
61 | ||
62 | virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); | |
63 | virtual bool MessageLoop (); | |
64 | ||
65 | virtual bool Create (Window * Parent = NULL, | |
66 | DWORD Style = | |
67 | WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); | |
68 | void Show (int State); | |
69 | ||
70 | HWND GetHWND () const | |
71 | { | |
72 | return WindowHandle; | |
73 | }; | |
74 | HINSTANCE GetInstance () const | |
75 | { | |
76 | return AppInstance; | |
77 | }; | |
78 | ||
79 | Window *GetParent () const | |
80 | { | |
81 | return Parent; | |
82 | }; | |
83 | HWND GetDlgItem (int id) const | |
84 | { | |
85 | return::GetDlgItem (GetHWND (), id); | |
86 | }; | |
b7301c43 RC |
87 | bool SetDlgItemFont(int id, const TCHAR *fontname, int Pointsize, |
88 | int Weight = FW_NORMAL, bool Italic = false, bool Underline = false, bool Strikeout = false); | |
89 | ||
90 | UINT IsButtonChecked (int nIDButton) const; | |
df62e023 RC |
91 | |
92 | void PostMessage (UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0); | |
93 | ||
94 | virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam) | |
95 | { | |
96 | return false; | |
97 | }; | |
98 | ||
b7301c43 RC |
99 | virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code) |
100 | { | |
101 | // Not processed. | |
102 | return false; | |
103 | }; | |
104 | ||
df62e023 RC |
105 | // Center the window on the parent, or on screen if no parent. |
106 | void CenterWindow (); | |
107 | ||
108 | }; | |
109 | ||
110 | #endif // CINSTALL_WINDOW_H |