Date: 02-16-2022
Return to Index
created by gbSnippets
'Covers PowerBASIC controls: Line, Label, Image
'Primary Code:
hTemp = CreateWindow("Static","Ok1",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_BlackRect, _
10,10,80,40,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_St01 = 501 :%IDC_St02 = 502 :%IDC_St03 = 503 :%IDC_St04 = 504
%IDC_St05 = 505 :%IDC_St06 = 506 :%IDC_St07 = 507 :%IDC_St08 = 508
%IDC_St09 = 509 :%IDC_St10 = 510 :%IDC_St11 = 511 :%IDC_St12 = 512
%IDC_St13 = 513 :%IDC_St14 = 514 :%IDC_St15 = 515 :%IDC_St16 = 516
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,250,335,575,%Null, %Null, hInst, ByVal %Null)
'simple
hTemp = CreateWindow("Static","Ok1",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_BlackRect, _
10,10,80,40,hMainWnd,%IDC_St01,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok2",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_GrayRect, _
10,70,80,40,hMainWnd,%IDC_St02,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok3",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_WhiteRect, _
10,130,80,40,hMainWnd,%IDC_St03,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok4",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_BlackFrame, _
10,190,80,40,hMainWnd,%IDC_St04,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok5",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_GrayFrame, _
10,250,80,40,hMainWnd,%IDC_St05,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok6",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_WhiteFrame, _
10,310,80,40,hMainWnd,%IDC_St06,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok7",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_EtchedHorz, _
10,370,80,40,hMainWnd,%IDC_St07,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok8",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_EtchedVert, _
10,430,80,40,hMainWnd,%IDC_St08,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Ok9",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_EtchedFrame, _
10,490,80,40,hMainWnd,%IDC_St09,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
'text
hTemp = CreateWindow("Static","Left",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Left, _
110,10,80,40,hMainWnd,%IDC_St10,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Right",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Right, _
110,70,80,40,hMainWnd,%IDC_St11,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Center",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Center, _
110,130,80,40,hMainWnd,%IDC_St12,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Wrap the long lines",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Center, _
110,190,80,40,hMainWnd,%IDC_St13,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Or not wrap the long lines",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_LeftNoWordWrap Or %WS_Border Or %SS_Center, _
110,250,80,40,hMainWnd,%IDC_St14,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hTemp = CreateWindow("Static","Or do not wrap the long lines",%WS_TabStop Or %WS_Visible Or %WS_Child Or %SS_LeftNoWordWrap Or %WS_Border, _
110,250,80,40,hMainWnd,%IDC_St15,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
'image
hTemp = CreateWindow("Static","",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Bitmap, _
210,10,100,100,hMainWnd,%IDC_St16,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hBmp = LoadImage(GetModuleHandle(""), "cowgirl", %IMAGE_BITMAP, 0, 0, 0)
SendMessage hTemp, %STM_SetImage, %Image_Bitmap, hBMP
hTemp = CreateWindow("Static","",%WS_TabStop Or %WS_Visible Or %WS_Child Or %WS_Border Or %SS_Icon, _
210,120,100,100,hMainWnd,%IDC_St16,GetWindowLong(hMainWnd, %GWL_HINSTANCE), %Null)
hBmp = LoadImage(GetModuleHandle(""), "aainfo", %IMAGE_ICON, 0, 0, 0)
SendMessage hTemp, %STM_SetImage, %Image_Icon, hBMP
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_00389
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm