]>
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 | ||
58db1046 RC |
25 | class String; |
26 | ||
df62e023 RC |
27 | class Window |
28 | { | |
29 | static ATOM WindowClassAtom; | |
30 | static HINSTANCE AppInstance; | |
31 | ||
32 | ||
33 | bool RegisterWindowClass (); | |
34 | static LRESULT CALLBACK FirstWindowProcReflector (HWND hwnd, UINT uMsg, | |
35 | WPARAM wParam, | |
36 | LPARAM lParam); | |
37 | static LRESULT CALLBACK WindowProcReflector (HWND hwnd, UINT uMsg, | |
38 | WPARAM wParam, LPARAM lParam); | |
39 | ||
40 | HWND WindowHandle; | |
41 | ||
42 | Window *Parent; | |
43 | ||
b7301c43 RC |
44 | // FIXME: replace with <vector> when we get a chance. |
45 | static const int MAXFONTS = 5; | |
46 | HFONT Fonts[MAXFONTS]; | |
47 | int FontCounter; | |
48 | ||
df62e023 RC |
49 | protected: |
50 | void SetHWND (HWND h) | |
51 | { | |
52 | WindowHandle = h; | |
53 | }; | |
54 | ||
55 | public: | |
56 | Window (); | |
57 | virtual ~ Window (); | |
58 | ||
59 | static void SetAppInstance (HINSTANCE h) | |
60 | { | |
61 | AppInstance = h; | |
62 | }; | |
63 | ||
64 | virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); | |
65 | virtual bool MessageLoop (); | |
66 | ||
67 | virtual bool Create (Window * Parent = NULL, | |
68 | DWORD Style = | |
69 | WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); | |
70 | void Show (int State); | |
71 | ||
72 | HWND GetHWND () const | |
73 | { | |
74 | return WindowHandle; | |
75 | }; | |
76 | HINSTANCE GetInstance () const | |
77 | { | |
78 | return AppInstance; | |
79 | }; | |
80 | ||
81 | Window *GetParent () const | |
82 | { | |
83 | return Parent; | |
84 | }; | |
85 | HWND GetDlgItem (int id) const | |
86 | { | |
87 | return::GetDlgItem (GetHWND (), id); | |
88 | }; | |
58db1046 RC |
89 | bool SetDlgItemFont (int id, const TCHAR * fontname, int Pointsize, |
90 | int Weight = FW_NORMAL, bool Italic = | |
91 | false, bool Underline = false, bool Strikeout = false); | |
b7301c43 RC |
92 | |
93 | UINT IsButtonChecked (int nIDButton) const; | |
df62e023 RC |
94 | |
95 | void PostMessage (UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0); | |
96 | ||
97 | virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam) | |
98 | { | |
99 | return false; | |
100 | }; | |
101 | ||
b7301c43 RC |
102 | virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code) |
103 | { | |
104 | // Not processed. | |
105 | return false; | |
106 | }; | |
107 | ||
df62e023 RC |
108 | // Center the window on the parent, or on screen if no parent. |
109 | void CenterWindow (); | |
110 | ||
58db1046 RC |
111 | // Set the title of the window. |
112 | void SetWindowText (const String & s); | |
113 | ||
df62e023 RC |
114 | }; |
115 | ||
116 | #endif // CINSTALL_WINDOW_H |