Date: 02-16-2022
Return to Index
created by gbSnippets
'This is the basic window template that will be used on all of the snippets in this part of
'the library.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim ALL
#Include "Win32API.inc"
Global hMainWnd as DWord, hButton as DWord
Function WinMain (ByVal hInst As DWord, ByVal hPrevInstance As DWord, ByVal lpCmdLine As Asciiz Ptr, ByVal iCmdShow As Long) As Long
Local Msg As tagMsg, myWin As WndClassEx, szAppName As Asciiz * 80, hwndButton As DWord
szAppName = "HelloSDK" : myWin.cbSize = SizeOf(myWin)
myWin.hIcon = LoadIcon(hInst, "aainfo") : myWin.Style = %CS_HREDRAW Or %CS_VREDRAW
myWin.hCursor = LoadCursor(%NULL, ByVal %IDC_ARROW) : myWin.lpfnWndProc = CodePTR(WndProc)
myWin.hbrBackground = %Color_BtnFace+1 : myWin.cbClsExtra = 0
myWin.lpszMenuName = %NULL : myWin.cbWndExtra = 0
myWin.lpszClassName = VarPTR(szAppName) : myWin.hInstance = hInst
myWin.hIconSm = LoadIcon(hInst, ByVal %IDI_APPLICATION) : RegisterClassEx myWin
hMainWnd = CreateWindow(szAppName, "SDK", %WS_OverlappedWindow, 500,400,300,400,%Null, %Null, hInst, ByVal %Null)
hButton = CreateWindow("Button","Push",%WS_TabStop Or %WS_Visible Or %WS_Child Or %BS_DefPushButton, _
10,10,80,20,hMainWnd,%Null,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
ShowWindow hMainWnd, iCmdShow : UpdateWindow hMainWnd
Do While GetMessage(Msg, %NULL, 0, 0) : TranslateMessage Msg : DispatchMessage Msg : Loop
End Function
Function WndProc (ByVal hWnd AS DWord, ByVal wMsg AS DWord, ByVal wParam AS DWord, ByVal lParam As Long) EXPORT As Long
' WndProc is the message handler for all windows creating using the HelloWin class name.
Local hDC As DWord, pPaint AS PAINTSTRUCT, tRect AS RECT
Select Case wMsg
Case %WM_CREATE
Case %WM_PAINT
Case %WM_ERASEBKGND
Case %WM_DESTROY
PostQuitMessage 0
Exit Function
End Select
Function = DefWindowProc(hWnd, wMsg, wParam, lParam) 'if not handled above, pass to Windows default message handler.
End Function
'gbs_00383
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm