Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
'Thanks to George Bleck and Cliff Nichols
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_ButtonOpenOSK = 500
IDC_ButtonCloseOSK
IDC_TextBox
End Enum
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "PowerBASIC",300,300,400,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ButtonOpenOSK,"Open", 20,10,100,20
Control Add Button, hDlg, %IDC_ButtonCloseOSK,"Close", 230,10,100,20
Control Add TextBox, hDlg, %IDC_Textbox, "", 10,50,380,140
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static v_lngOldValue As Long, hWnd As Dword
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_ButtonOpenOSK
fn_Wow64DisableWow64FsRedirection v_lngOldValue
SHELLEXECUTE(%HWND_Desktop, "open", "osk.exe", "", "", %SW_Show)
fn_Wow64RevertWow64FsRedirection v_lngOldValue
Control Set Focus hDlg, %IDC_TextBox
Case %IDC_ButtonCloseOSK
hWnd = FindWindow("OSKMainClass","On-Screen Keyboard")
' ? Str$(hWnd)
SendMessage hWnd, %WM_SysCommand, %SC_Close, 0
'close the keyboard
End Select
End Select
End Function
Function fn_Wow64DisableWow64FsRedirection Alias "Wow64DisableWow64FsRedirection" ( OldValue As Long ) Export As Long
' Credit to Cliff Nichols
' www.powerbasic.com/support/pbforums/showthread.php?t=50581
Local RealFunction As Long 'Variable for procedure address
Local ApiResults As Long
RealFunction = GETPROCADDRESS( GETMODULEHANDLE( "KERNEL32.DLL" ), FuncName$ ) 'Get Procedure Address (FuncName$ can be used since our alias for this procedure is the name we are looking for)
If RealFunction <> 0 Then Call Dword RealFunction Using fn_Wow64DisableWow64FsRedirection( OldValue ) To ApiResults
Function = ApiResults
End Function
Function fn_Wow64RevertWow64FsRedirection Alias "Wow64RevertWow64FsRedirection" ( OldValue As Long ) Export As Long
' Credit to Cliff Nichols
' www.powerbasic.com/support/pbforums/showthread.php?t=50581
Local ApiResults As Long
Local RealFunction As Long 'Variable for procedure address
RealFunction = GETPROCADDRESS( GETMODULEHANDLE( "KERNEL32.DLL" ), FuncName$ ) 'Get Procedure Address (FuncName$ can be used since our alias for this procedure is the name we are looking for)
If RealFunction <> 0 Then Call Dword RealFunction Using fn_Wow64RevertWow64FsRedirection( OldValue ) To ApiResults 'Call Function
Function = ApiResults
End Function
http://www.garybeene.com/sw/gbsnippets.htm