[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project


[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]


hwnd = WinCreateStdWindow( hwndParent, flFrameStyle, pflCreateFlags, pszClientClass, pszTitle, flClientStyle, hmodResource, ulFrameId, phwndClient );


HWND hwndParent (input)
Handle to parent window. If HWND_DESKTOP is specified, a main window is created.

ULONG flFrameStyle (input)
Window style. Usually chosen from pre-defined PM constants, but you can also create your own styles for your own classes. FS_ style flags may only be used when the frame is created from a dialog template. Here are the pre-defined PM styles (any combination):

FS_AUTOICON System redraws icon for application.
FS_BORDER Window has thin border.
FS_DLGBORDER Window has dialog border.
FS_MOUSEALIGN Position is relative to mouse position.
FS_NOBYTEALIGN Moves are not aligned to nearest byte. Slower, but nicer.
FS_NOMOVEWITHOWNER Window will not move when owner does.
FS_SCREENALIGN Coordinates are relative to top left of screen.
FS_SIZEBORDER Window has normal resizable border.
FS_SYSMODAL System modal window. Usually not a good idea.
FS_TASKLIST Window will be added to tasklist.
WS_ANIMATE Enables WPS animation, unless user has disabled this feature.
WS_CLIPCHILDREN Window cannot draw on children.
WS_CLIPSIBLINGS Window cannot draw on siblings.
WS_DISABLED Creates window disabled. This might be desirable for filling list boxes, and so on. WinEnableWindow must be used later.
WS_GROUP Start a new group for dialog box purposes. This should not be used on every window in the group, only the first one.
WS_PARENTCLIP Window created with this style cannot draw outside their parents, but they CAN draw on their parent, so care sould be used.
WS_SAVEBITS PM will save the pixels underneath this window for when this window closes and moves away. This is faster, but uses more memory. With todays fast systems, if you are not concerned about higher RAM usage, this should be on.
WS_SYNCPAINTS WM_PAINT messages will be sent, rather than posted.
WS_TABSTOP Specifies that pressing tab in a dialog box will move the focus to this window. Otherwise it will be skipped.
WS_VISIBLE Without this style, the window will be created invisible, and will have to be displayed later with WinSetWindowPos or WinShowWindow. The window also has to have size to be displayed, but may come up underneath other windows.

PULONG pflCreateFlags (input)
Class name. Must already either be registered via WinRegisterClass, or be a pre-defined PM class. This could be one of the following:

FCF_ACCELTABLE Specifies that accelerator keys should be loaded from resource file.
FCF_AUTOICON PM automatically handles WM_PAINT messages while app is iconzied.
FCF_BORDER Creates window with thin border.
FCF_DLGBORDER Creates window with dialog-style fixed border.
FCF_HIDEBUTTON Adds hide button to frame.
FCF_HIDEMAX Adds hide and maximize buttons to frame
FCF_HORZSCROLL Adds horizontal scroll bar to client window.
FCF_ICON Uses an icon from resource file as app icon.
FCF_MAXBUTTON Adds maximize button to frame.
FCF_MENU Loads a menu from resource file.
FCF_MINBUTTON Adds minimize button to frame.
FCF_MINMAX Adds minimize and maximize buttons to frame.
FCF_MOUSEALIGN Application window is created relative to mouse position at the time of creation.
FCF_NOBYTEALIGN Does not force alignment window on an even byte, unlike VIO windows.
FCF_NOMOVEWITHOWNER Disables movement of window when owner moves. This is irrelevant with HWND_DESKTOP as owner.
FCF_SCREENALIGN Application window is created relative to the top left corner of screen.
FCF_SHELLPOSITION Application window is given automatic size and window position by PM upon creation.
FCF_SIZEBORDER Frame window is created with a sizable normal border.
FCF_STANDARD Creates window with a system menu, titlebar, minimize and maximize buttons, menu, sizable border, icon, accelerator keys, a default size and position, and an entry in the tasklist. In other words, this basically creates a whole, normal window.
FCF_SYSMENU Frame window is created with a system menu in top left corner.
FCF_SYSMODAL Window is created system modal, ie. other apps cannot get the focus. Usually, this option should not be used, except for critical messages.
FCF_TASKLIST Creates an entry in the window list for application.
FCF_TITLEBAR Creates frame window with a titlebar.
FCF_VERTSCROLL Creates a vertical scroll bar in client window.

PSZ pszClientClass (input)
This class must be a pre-registered class name. If you pass NULL, no client window will be created.

PSZ pszTitle (input)
Window title. This title is only used if you specified FCF_TITLEBAR or FCF_STANDARD.

ULONG flClientStyle (input)
These flags (see WS_ style flags above) determine the style of the client window.

HMODULE hmodResource (input)
A handle to a resource module which has the required icon, menu, and accelerator table.

ULONG ulFrameId (input)
A value given by programmer for identification of the window by owner. between 0x0000 and 0xFFFF.

PHWND pwhndClient (output)
This returns the HWND for the newly created client window.


HWND hwnd
Handle to the newly created window. NULLHANDLE is returned if there was an error. In this case, WinGetLastError might return:


Include Info

#define INCL_WIN
#define INCL_PM
#include <os2.h>

Usage Explanation

Use this API to create a standard type window, as a main window for an application. It can be used elsewhere, but this is less common. You would usually create the window with the WS_VISIBLE style. If FCF_SHELLPOSITION is not specified, the dimensions and location of window are all 0, and you must then use WinSetWindowPos to size and position window later. If WS_VISIBLE is not used, WinShowWindow can be used later to show the window.

You can reach the sub-windows of the newly created frame window with the following ids: FID_CLIENT, FID_HORZSCROLL, FID_MINMAX, FID_MENU, FID_SYSMENU, FID_TITLEBAR, FID_VERTSCROLL.

Relevant Structures


The id used for the menu, icon, and accelerator table must be the same, if they are loaded from templates in a resource file.

Sample Code

#define INCL_WINMESSAGEMGR #include <os2.h> HAB hab; HMQ hmq; HWND hwndMain, hwndClient; ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_TASKLIST | FCF_ICON | FCF_ACCELTABLE | FCF_MENU; CHAR szClientClass[] = "CLIENT"; CHAR szTitle; hab = WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); if(!WinRegisterClass(hab, szClientClass,(PFNWP)ClientWndProc, 0, 0)) exit(1); WinLoadString(hab, 0, ID_APPNAME, sizeof(szTitle), szTitle); hwndMain = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, szClientClass, szTitle, 0, 0, ID_APPNAME, &hwndClient);

See Also

WinCreateWindow, WinDestroyWindow, WinEnableWindow, WinSetWindowPos, WinShowWindow


Carsten Whimster - bcrwhims@uwaterloo.ca


Last modified June 22/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project