Date: 02-16-2022
Return to Index
created by gbSnippets
'Covers PowerBASIC controls: TextBox, RichEdit, Edit Box of ComboBox
'Primary Code:
hTemp = CreateWindow("Edit","Ok",%WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD Or %BS_DEFPUSHBUTTON, _
10,10,20,20,hMainWnd,%Null,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
Syntax: 'CreateWindow (Class, Text, Style, x,y,w,h,hParent,hMenu,hInstance,creation_parameters)
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim ALL
#Include "Win32API.inc"
#Resource "gbsnippets.pbr"
%IDC_Edit01 = 501 :%IDC_Edit02 = 502
Global hMainWnd As Dword, hTemp As Dword, hBMP 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)
hTemp = CreateWindow("Edit","One Line!",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border, _
10,10,80,20,hMainWnd,%IDC_Edit01,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Edit","More than" + $CrLf + "one line.",%WS_TabStop Or %WS_Visible Or %WS_Child Or _
%WS_Border Or %ES_MultiLine Or %ES_WantReturn, _
10,90,80,60,hMainWnd,%IDC_Edit01,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Edit","More than one wide" + $CrLf + "line.",%WS_TabStop Or %WS_Visible Or %WS_Child Or _
%WS_Border Or %ES_MultiLine Or %ES_WantReturn Or %ES_AutoHScroll Or %ES_AutoVScroll _
Or %WS_HScroll Or %WS_VScroll, _
10,170,125,125,hMainWnd,%IDC_Edit01,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_00387
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm