]> cygwin.com Git - cygwin-apps/setup.git/blob - window.h
2001-12-22 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[cygwin-apps/setup.git] / window.h
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
42 protected:
43 void SetHWND (HWND h)
44 {
45 WindowHandle = h;
46 };
47
48 public:
49 Window ();
50 virtual ~ Window ();
51
52 static void SetAppInstance (HINSTANCE h)
53 {
54 AppInstance = h;
55 };
56
57 virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam);
58 virtual bool MessageLoop ();
59
60 virtual bool Create (Window * Parent = NULL,
61 DWORD Style =
62 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN);
63 void Show (int State);
64
65 HWND GetHWND () const
66 {
67 return WindowHandle;
68 };
69 HINSTANCE GetInstance () const
70 {
71 return AppInstance;
72 };
73
74 Window *GetParent () const
75 {
76 return Parent;
77 };
78 HWND GetDlgItem (int id) const
79 {
80 return::GetDlgItem (GetHWND (), id);
81 };
82
83 void PostMessage (UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0);
84
85 virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam)
86 {
87 return false;
88 };
89
90 // Center the window on the parent, or on screen if no parent.
91 void CenterWindow ();
92
93 };
94
95 #endif // CINSTALL_WINDOW_H
This page took 0.039605 seconds and 5 git commands to generate.