Date: 02-16-2022
Return to Index
created by gbSnippets
'Credit: Dave Biggs
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
%IDC_Ask = 500
Global ix, iy As Long, hDlg As Dword, ghHook As Dword
Function PBMain() As Long
ix = 300 : iy = 300
Dialog New Pixels, 0, "Toolbar Test",ix,iy,400,300, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Ask, "Ask", 10,10,50,25
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Ask
ghHook = SetWindowsHookEx(%WH_CBT, CodePtr(InputBoxProc), GetModuleHandle(""), GetCurrentThreadId)
temp$ = InputBox$("Enter your name:", "InputBox Test", "Gary Beene",ix+50,iy+50)
End Select
End Select
End Function
Function InputBoxProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Local szTemp As Asciiz * %Max_Path, cw As CBT_CREATEWND Ptr, cst As CREATESTRUCT Ptr
Function = CallNextHookEx(ByVal ghHook, ByVal nCode, ByVal wParam, ByVal lParam)
If nCode < 0 Then Exit Function
If nCode = %HCBT_ACTIVATE Then UnhookWindowsHookEx ghHook
If nCode = %HCBT_CREATEWND Then
cw = lParam ' Get pointer to CBT_CREATEWND struct so we can... TT: Nick Melnick
cst = @cw.lpcs ' get a pointer to the CREATESTRUCT struct
GetClassName wParam, szTemp, %Max_Path ' for each window / control as it is created
If UCase$(szTemp) = "STATIC" Then @cst.cy = 20 'prompt
If UCase$(szTemp) = "EDIT" Then @cst.cx = 190 : @cst.y = @cst.y - 130 'textbox
If UCase$(szTemp) = "EDIT" Then SetWindowLong wparam, %GWL_Style, GetWindowLong(wParam,%GWL_Style) Or %ES_Password
If UCase$(szTemp) = "#32770" Then @cst.cy = @cst.cy - 130 'dialog
End If
End Function
'gbs_00790
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm