SDK App - 2. Create/Register Class

Category: SDK

Date: 02-16-2022

Return to Index


 
'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.
1. Define
2. Register
3. Show
4. Message Loop
5. Message Response
 
'2. Register
'Once the Window class has been defined (see http://gbl_00355) you can use
'the CreateWindow API to register the class with the Windows operating system.
'Two variables are needed, one for the name of the window and one to hold
'the handle assigned to the window by the Windows operating system.
 
    Local myApp As Asciiz*80, hWnd As DWord
    myApp = "SDK"
    hWnd  = CreateWindow(szAppName, "SDK Demo", %WS_OVERLAPPEDWINDOW, 500,400,300,150,%Null, %Null, hInst, ByVal %Null)
 
'Once the CreateWindow statement is executed, the Window is registered.
 
'Here are descriptions of the arguments of the CreateWindow() function.
    hWnd = CreateWindow(szAppName, _               ' window class name
                        "SDK Demo", _              ' window caption
                        %WS_OVERLAPPEDWINDOW, _    ' window style
                        500, _                     ' initial x position
                        400, _                     ' initial y position
                        300, _                     ' initial x size
                        150, _                     ' initial y size
                        %NULL, _                   ' parent window handle
                        %NULL, _                   ' window menu handle
                        hInstance, _               ' program instance handle
                        ByVal %NULL)               ' creation parameters
 
'gbs_00354
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm