Return to Index
created by gbSnippets
'There are essentially 5 parts to creating a window:
'A data structure is filled out with the window properties and the CreateWindowEx
'API is used to register the window, then the ShowWindow/UpdateWindow API are used
'to display the window. A message loop keeps the window on the screen and a message
'function is used to respond to messages sent to the window (including sending a
'PostQuitMessage() to end the message loop and close the application.
4. Message Loop
5. Message Response
'Declare a variable of type WndClassEx and fill the elements of that variable with the Window properties
Local myWin AS WndClassEx
'Define the elements of a window
myWin.cbSize = SizeOf(wce)
myWin.Style = %CS_HREDRAW Or %CS_VREDRAW
myWin.lpfnWndProc = CodePTR(WndProc) 'message function - "WndProc" can be any function name
myWin.cbClsExtra = 0
myWin.cbWndExtra = 0
myWin.hInstance = hInst
myWin.hIcon = LoadIcon(hInst, "aainfo") 'icon from PBR file
myWin.hCursor = LoadCursor(%NULL, ByVal %IDC_ARROW)
myWin.hbrBackground = %NULL ' No class background, we do it ourselves
myWin.lpszMenuName = %NULL
myWin.lpszClassName = VarPTR(szAppName)
myWin.hIconSm = LoadIcon(hInst, ByVal %IDI_APPLICATION)
'Per MSDN, you must initialize any unused members of the WNDCLASSEX structure to zero Or NULL.
'The Window Class elements are as shown in the following table.
'The WndClassEX structure is covered in more detail at MSDN
'The following information is a summary of the MSDN page.
'The WNDCLASSEX structure contains Window Class information. It is used with the RegisterClassEx
'and GetClassInfoEx functions.
'Specifies the size, in bytes, of the structure. Set this member to SizeOf(WNDCLASSEX).
'Be sure to Set this member before calling the GetClassInfoEx Function.
'Specifies the Class Style(s). This member can be any combination of the Class Styles.
'Pointer to the Window procedure. You must use the CallWindowProc Function to Call the Window procedure. For more information, see WindowProc.
'Specifies the number of extra bytes to allocate following the Window-Class structure. The system initializes the bytes to zero.
'Specifies the number of extra bytes to allocate following the Window Instance. The system initializes the bytes to zero. If an application uses WNDCLASSEX to Register a Dialog Box created by using the Class directive in the resource file, it must Set this member to DLGWINDOWEXTRA.
'Handle to the Instance that contains the Window procedure For the Class.
'Handle to the Class Icon. This member must be a Handle to an Icon resource. If this member is NULL, the system provides a default Icon.
'Handle to the Class cursor. This member must be a Handle to a cursor resource. If this member is NULL, an application must explicitly Set the cursor shape whenever the mouse moves into the application's window.
'Handle to the Class background brush. This member can be a Handle to the physical brush to be used For painting the background, Or it can be a Color value. A Color value must be one of the following standard system colors (the value 1 must be added to the chosen Color). If a Color value is given, you must convert it to one of the following HBRUSH types:
' The system automatically deletes Class background brushes when the Class is unregistered by using UnregisterClass. An application should Not Delete these brushes.''''
' When this member is NULL, an application must Paint its own background whenever it is requested to Paint in its Client area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message Or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint Function.
' Pointer to a null-terminated character String that specifies the resource Name of the Class Menu, as the Name appears in the resource file. If you use an integer to identify the Menu, use the MAKEINTRESOURCE Macro. If this member is NULL, windows belonging to this Class have no default Menu.
'pointer to a null-terminated string - the Window Class Name (any name registered with RegisterClass Or RegisterClassEx, or any of the predefined control-class names.
The maximum length For lpszClassName is 256. If lpszClassName is greater than the maximum length, the RegisterClassEx Function will fail.
'handle to a small icon associated with the Window Class. If NULL, the icon is drawn from hIcon property
created by gbSnippets