4 * ---------------------------------------------------------------------------
6 * Implementation of a minimal C++ class framework for use with the
7 * Microsoft Windows Application Programming Interface.
11 * This file provides the implementation for the Create() method of
12 * the ChildWindowMaker class.
14 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
15 * Copyright (C) 2012, MinGW.org Project.
17 * ---------------------------------------------------------------------------
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:
26 * The above copyright notice and this permission notice shall be included
27 * in all copies or substantial portions of the Software.
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.
37 * ---------------------------------------------------------------------------
40 #define WIN32_LEAN_AND_MEAN
47 HWND ChildWindowMaker::Create
48 ( int id, HWND Parent, const char *ClassName, unsigned long style )
50 /* Create a generic child window, with specified ID, and
51 * owned by specified parent.
53 HWND child_window = CreateWindow( ClassName,
54 NULL, style | WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0,
55 Parent, (HMENU)(id), AppInstance, this
59 /* On failure, compose diagnostic message, and bail out.
61 const char *fmt = "%s: CreateWindow FAILED";
62 char description[1 + snprintf( NULL, 0, fmt, ClassName )];
63 snprintf( description, sizeof( description ), fmt, ClassName );
64 throw( runtime_error( description ) );
66 /* On success, return the window handle.
72 /* $RCSfile$: end of file */