Date: 02-16-2022
Return to Index
created by gbSnippets
'An online tutorial on templates can be found at:
'http://www.garybeene.com/power/pb-tutor-templates.htm
'Use this template by copying everything below "'Copy below here:"
'and put in a file with a ".pbtpl" extension under pbwin90\bin.
'When PB IDE starts, the template will be available under the
'toolbar "Create New File" dropdown menu.
'Copy below here:
1
.bas
Standard: Dialog + Buttons
#Compile EXE
#Dim All
%Unicode=1
#Debug Error On 'catch array/pointer errors - OFF in production
#Debug Display On 'display untrapped errors - OFF in production
#Tools Off 'use ON only when needed for Trace/Profile/CallStk
#Include "win32api.inc"
'use these inside procedures:
'#Debug Print "msg" 'on as-needed basis only
'#Debug Code ON 'ignored in production, use OFF for speed in development testing
Function PBMain() As Long
Local hDlg As Dword
MakeDialog(hDlg)
End Function
Sub MakeDialog(hDlg as Dword)
Dialog New Pixels, 0, "Button Test",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Control Add Label, hDlg, 101,"results", 50,40,100,20, %WS_Border
Control Add Label, hDlg, 102,"results", 50,70,100,20, %WS_Border
Dialog Show Modal hDlg Call DlgProc
End Sub
CallBack Function DlgProc() As Long
'Console message list
Static iMsgCount&
CPrint Str$(iMsgCount&)+ " " + WinMsg(CB.Msg)
Incr iMsgCount&
Select Case CB.Msg
Case %WM_Command
Select Case CB.Ctl
Case 100
If CB.Ctlmsg = %BN_Clicked Then
Local iResult1&, iResult2&
'... test code here - place results in labels 100 & 101
Control Set Text CB.Hndl, 101, Str$(iResult1&)
Control Set Text CB.Hndl, 102, Str$(iResult2&)
End If
End Select
End Select
End Function
Sub CPrint (SOut As String) 'Semen Matusovski's CPrint code:
Static hConsole As Long, cWritten As Long
If hConsole = 0 Then AllocConsole: hConsole = GetStdHandle(-11&)
WriteConsole hConsole, ByCopy sOut + $CrLf, Len(sOut) + 2, cWritten, ByVal 0&
End Sub
'gbs_00250
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm