Code: Select all
#include once "windows.bi"
declare function WinMain ( byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval szCmdLine as string, _
byval iCmdShow as integer ) as integer
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )
'':::::
function WndProc ( byval hWnd as HWND, _
byval wMsg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM ) as LRESULT
function = 0
select case( wMsg )
CASE WM_HOTKEY
MessageBox( null, "Hotkey is press", "Hotkey!!!", MB_ICONINFORMATION )
case WM_CREATE
exit function
case WM_PAINT
dim rct as RECT
dim pnt as PAINTSTRUCT
dim hDC as HDC
hDC = BeginPaint( hWnd, @pnt )
GetClientRect( hWnd, @rct )
DrawText( hDC, _
"Hello, World!", _
-1, _
@rct, _
DT_SINGLELINE or DT_CENTER or DT_VCENTER )
EndPaint( hWnd, @pnt )
exit function
case WM_KEYDOWN
if( lobyte( wParam ) = 27 ) then
PostMessage( hWnd, WM_CLOSE, 0, 0 )
end if
case WM_DESTROY
PostQuitMessage( 0 )
exit function
end select
function = DefWindowProc( hWnd, wMsg, wParam, lParam )
end function
'':::::
function WinMain ( byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval szCmdLine as string, _
byval iCmdShow as integer ) as integer
dim wMsg as MSG
dim wcls as WNDCLASS
dim hWnd as HWND
Dim nID1 As Integer
Dim nID2 As Integer
Dim nID3 As Integer
'Dim iRet As Long
nID1 = 33000
nID2 = 33001
nID3 = 33002
function = 0
with wcls
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( NULL, IDI_APPLICATION )
.hCursor = LoadCursor( NULL, IDC_ARROW )
.hbrBackground = GetStockObject( WHITE_BRUSH )
.lpszMenuName = NULL
.lpszClassName = @"HelloWin"
end with
if( RegisterClass( @wcls ) = FALSE ) then
MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
exit function
end if
hWnd = CreateWindowEx( 0, _
@"HelloWin", _
"Press F10 to F12 to the hotkey", _
WS_OVERLAPPEDWINDOW, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
NULL, _
NULL, _
hInstance, _
NULL )
'iRet = RegisterHotKey(hWnd, nID1, 0, VK_F10)
'If iRet = 0 Then
If RegisterHotKey(hWnd, nID1, 0, VK_F10) = 0 Then
MessageBox(null, "RegisterHotKey F10 fail!!", "Fail", MB_ICONERROR)
End If
'iRet = RegisterHotKey(hWnd, nID2, 0, VK_F11)
'If iRet = 0 Then
If RegisterHotKey(hWnd, nID2, 0, VK_F11) = 0 Then
MessageBox(null, "RegisterHotKey F11 fail!!", "Fail", MB_ICONERROR)
End If
'iRet = RegisterHotKey(hWnd, nID3, 0, VK_F12)
'If iRet = 0 Then
If RegisterHotKey(hWnd, nID3, 0, VK_F12) = 0 Then
MessageBox(null, "RegisterHotKey F12 fail!!", "Fail", MB_ICONERROR)
End If
ShowWindow( hWnd, iCmdShow )
UpdateWindow( hWnd )
while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )
TranslateMessage( @wMsg )
DispatchMessage( @wMsg )
wend
UnregisterHotKey(hWnd, nID1)
UnregisterHotKey(hWnd, nID2)
UnregisterHotKey(hWnd, nID3)
function = wMsg.wParam
end function