OSDN Git Service

Initial commit for new package.
[mingw/wtklite.git] / wtkbase.cpp
1 /*
2  * wtkbase.cpp
3  *
4  * ---------------------------------------------------------------------------
5  *
6  * Implementation of a minimal C++ class framework for use with the
7  * Microsoft Windows Application Programming Interface.
8  *
9  * $Id$
10  *
11  * This file provides the constructor for WindowClassMaker C++ class objects,
12  * and the implementation for the Create() method of the WindowMaker class.
13  *
14  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
15  * Copyright (C) 2012, MinGW.org Project.
16  *
17  * ---------------------------------------------------------------------------
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining a
20  * copy of this software and associated documentation files (the "Software"),
21  * to deal in the Software without restriction, including without limitation
22  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
23  * and/or sell copies of the Software, and to permit persons to whom the
24  * Software is furnished to do so, subject to the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be included
27  * in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
30  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
32  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35  * DEALINGS IN THE SOFTWARE.
36  *
37  * ---------------------------------------------------------------------------
38  *
39  */
40 #define WIN32_LEAN_AND_MEAN
41
42 #include "wtkplus.h"
43
44 namespace WTK
45 {
46   WindowClassMaker::WindowClassMaker( HINSTANCE instance, unsigned id ):
47   GenericWindow( instance )
48   {
49     /* Construct a window class registration helper, and assign
50      * default attributes to suit top-level windows.
51      */
52     hInstance = instance;
53     style = CS_HREDRAW | CS_VREDRAW;
54     hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
55     lpszMenuName = MAKEINTRESOURCE( id );
56     hCursor = LoadCursor( (HINSTANCE)(NULL), IDC_ARROW );
57     hIcon = LoadIcon( instance, lpszMenuName );
58     lpfnWndProc = WindowProcedure;
59     cbClsExtra = cbWndExtra = 0;
60   }
61
62   HWND WindowMaker::Create( const char *ClassName, const char *Caption )
63   {
64     /* Create a generic top-level application window, with attributes
65      * appropriate to a registered (named) window class.
66      */
67     AppWindow = CreateWindow( ClassName,
68         Caption, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS,
69         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
70         (HWND)(NULL), (HMENU)(NULL), AppInstance, this
71       );
72     if( ! AppWindow ) throw( runtime_error( "CreateWindow FAILED" ) );
73     return AppWindow;
74   }
75 }
76
77 /* $RCSfile$: end of file */