RE: GUI app and winAPI calls - aurel - 03-22-2023
Ok ..but which offset variable is wrong
can anyone compile this code :
Code: (Select All) 'test 1 GUI win32 api in QB64pe v3.2.1 by Aurel
CONST IDC_ARROW = &H7F00
CONST COLOR_WINDOW = 5
CONST WS_OVERLAPPED = 0
CONST WS_CHILD = &H40000000
CONST WS_VISIBLE = &H10000000
CONST WS_MAXIMIZE = &H01000000
CONST WS_CAPTION = &H00C00000
CONST WS_VSCROLL = &H00200000
CONST WS_HSCROLL = &H00100000
CONST WS_SYSMENU = &H00080000
CONST WS_THICKFRAME = &H00040000
CONST WS_TABSTOP = &H00010000
CONST WS_MINIMIZEBOX = &H00020000
CONST WS_MAXIMIZEBOX = &H00010000
CONST WS_OVERLAPPEDWINDOW = WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_THICKFRAME OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX
CONST CW_USEDEFAULT = &H80000000
CONST BS_PUSHBUTTON = 0
CONST BS_AUTOCHECKBOX = 3
CONST BS_GROUPBOX = 7
CONST BS_AUTORADIOBUTTON = 9
CONST BS_TEXT = 0
CONST BN_CLICKED = 0
CONST BM_GETCHECK = &HF0
CONST ES_LEFT = 0
CONST ES_MULTILINE = 4
CONST ES_AUTOVSCROLL = &H0040
CONST ES_AUTOHSCROLL = &H0080
CONST ES_WANTRETURN = &H1000
CONST WM_DESTROY = 2
CONST WM_GETTEXT = &H000D
CONST WM_CLOSE = &H0010
CONST WM_COMMAND = &H0111
CONST SW_SHOWDEFAULT = &HA
CONST SW_SHOW = 5
DECLARE LIBRARY "win"
FUNCTION GetWindowProc%& ()
END DECLARE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SendMessageA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
FUNCTION DefWindowProcA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
SUB PostQuitMessage (BYVAL nExitCode&)
FUNCTION LoadCursorW%& (BYVAL hInstance%&, BYVAL lpCursorName%&)
FUNCTION RegisterClassA~% (BYVAL lpWndClass%&)
FUNCTION CreateWindowEx%& (ByVal dwExStyle As Long, byval lpClassName%&, byval lpWindowName%&, Byval dwStyle As Long, Byval x As Long, Byval y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As _OFFSET, Byval hMenu As Long, Byval hInstance As Long, Byval lpParam As Long )
FUNCTION ShowWindow& (BYVAL hWnd%&, BYVAL nCmdShow&)
FUNCTION UpdateWindow& (BYVAL hWnd%&)
FUNCTION GetMessageA& (BYVAL lpMsg%&, BYVAL hWnd%&, BYVAL wMsgFilterMin~&, BYVAL wMsgFilterMax~&)
FUNCTION TranslateMessage& (BYVAL lpMsg%&)
FUNCTION DispatchMessageA%& (BYVAL lpmsg%&)
END DECLARE
DECLARE DYNAMIC LIBRARY "kernel32"
FUNCTION GetModuleHandleW%& (BYVAL lpModuleName%&)
'FUNCTION GetLastError~& ()
END DECLARE
TYPE POINT
x AS LONG
y AS LONG
END TYPE
' $IF 32BIT THEN
TYPE MSG
hwnd AS LONG
message AS LONG
wParam AS LONG 'unsigned pointer sized integer
lParam AS _OFFSET 'pointer sized integer
time AS LONG
pt AS POINT
END TYPE
TYPE WNDCLASSA
style AS LONG
lpfnWndProc AS _OFFSET
cbClsExtra AS LONG
cbWndExtra AS LONG
hInstance AS _OFFSET
hIcon AS _OFFSET
hCursor AS _OFFSET
hbrBackground AS _OFFSET
lpszMenuName AS _OFFSET
lpszClassName AS _OFFSET
END TYPE
DIM SHARED hi AS _OFFSET
DIM SHARED bRet AS LONG
DIM SHARED hw AS LONG
DIM SHARED hwb0 AS _OFFSET
DIM SHARED hwb1 AS _OFFSET
DIM SHARED hwcb AS _OFFSET
DIM SHARED hwgb AS _OFFSET
DIM SHARED hwr0 AS _OFFSET
DIM SHARED hwr1 AS _OFFSET
DIM SHARED hwe AS _OFFSET
DIM SHARED wc AS WNDCLASSA
DIM SHARED wmsg AS MSG
DIM SHARED at AS _UNSIGNED INTEGER
DIM SHARED buf AS STRING * 4096
'DIM SHARED discardb AS LONG
'DIM SHARED discardp AS _OFFSET
DIM SHARED t0 AS STRING
DIM SHARED t1 AS STRING
DIM SHARED ClassName AS STRING
ClassName = "QB64pe" + CHR$(0)
'DIM SHARED crlf AS STRING * 2
'crlf = MKI$(&HA0D)
hi = GetModuleHandleW(0)
wc.style = 0
wc.lpfnWndProc = GetWindowProc
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hi
wc.hIcon = 0
wc.hCursor = LoadCursorW(0, IDC_ARROW)
wc.hbrBackground = COLOR_WINDOW + 1
wc.lpszMenuName = 0
wc.lpszClassName = _OFFSET(ClassName)
at = RegisterClassA(_OFFSET(wc)): 'IF 0 = at THEN SYSTEM
'create main window
t1 = "title" + CHR$(0)
hw = CreateWindowEx(0, _OFFSET(ClassName), _OFFSET(t1), WS_OVERLAPPEDWINDOW , 200, 200, 800, 600, 0, 0, hi, 0)
IF 0 = hw THEN SYSTEM
ShowWindow(hw, SW_SHOW)
UpdateWindow(hw)
'win message loop
While GetMessageA(_OFFSET(wmsg), 0, 0, 0) <> 0
TranslateMessage(_OFFSET(wmsg))
DispatchMessageA(_OFFSET(wmsg))
Wend
RE: GUI app and winAPI calls - SpriggsySpriggs - 03-22-2023
You might object, but perhaps you should put this into the actual QB64 IDE window so you can see some of the stuff in real-time. That might help you see where something isn't matching up. Also, if you don't attach "win.h", No one can compile it. I'd have to dig up all my old files to find my version of it.
RE: GUI app and winAPI calls - aurel - 03-22-2023
Quote:Also, if you don't attach "win.h
hmm...ok ..so i need to look into win.h
how i miss this thing...
I can bet that i compile something similar in the past ...i mean with old
qb64 but i forget all about that ..
Zak
is there any archived code on old forums or similar?
RE: GUI app and winAPI calls - aurel - 03-22-2023
well ok here is error in iDE
RE: GUI app and winAPI calls - SpriggsySpriggs - 03-22-2023
You're passing in "hi", which is an OFFSET but you've declared that parameter to be a LONG. You need to change your declaration to match the one I sent you so all the variable typing is correct.
RE: GUI app and winAPI calls - aurel - 03-23-2023
oK
now compile ..but stuck in memory
Code: (Select All) 'test 1 GUI win32 api in QB64pe v3.2.1 by Aurel
CONST IDC_ARROW = &H7F00
CONST COLOR_WINDOW = 5
CONST WS_OVERLAPPED = 0
CONST WS_CHILD = &H40000000
CONST WS_VISIBLE = &H10000000
CONST WS_MAXIMIZE = &H01000000
CONST WS_CAPTION = &H00C00000
CONST WS_VSCROLL = &H00200000
CONST WS_HSCROLL = &H00100000
CONST WS_SYSMENU = &H00080000
CONST WS_THICKFRAME = &H00040000
CONST WS_TABSTOP = &H00010000
CONST WS_MINIMIZEBOX = &H00020000
CONST WS_MAXIMIZEBOX = &H00010000
CONST WS_OVERLAPPEDWINDOW = WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_THICKFRAME OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX
CONST CW_USEDEFAULT = &H80000000
CONST BS_PUSHBUTTON = 0
CONST BS_AUTOCHECKBOX = 3
CONST BS_GROUPBOX = 7
CONST BS_AUTORADIOBUTTON = 9
CONST BS_TEXT = 0
CONST BN_CLICKED = 0
CONST BM_GETCHECK = &HF0
CONST ES_LEFT = 0
CONST ES_MULTILINE = 4
CONST ES_AUTOVSCROLL = &H0040
CONST ES_AUTOHSCROLL = &H0080
CONST ES_WANTRETURN = &H1000
CONST WM_DESTROY = 2
CONST WM_GETTEXT = &H000D
CONST WM_CLOSE = &H0010
CONST WM_COMMAND = &H0111
CONST SW_SHOWDEFAULT = &HA
CONST SW_SHOW = 5
DECLARE LIBRARY "win"
FUNCTION GetWindowProc%& ()
END DECLARE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SendMessageA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
FUNCTION DefWindowProcA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
SUB PostQuitMessage (BYVAL nExitCode&)
FUNCTION LoadCursorW%& (BYVAL hInstance%&, BYVAL lpCursorName%&)
FUNCTION RegisterClassA~% (BYVAL lpWndClass%&)
'FUNCTION CreateWindowEx%& (ByVal dwExStyle As Long, byval lpClassName%&, byval lpWindowName%&, Byval dwStyle As Long, Byval x As Long, Byval y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As Long, Byval hMenu As Long, Byval hInstance As _OFFSET, Byval lpParam As Long )
FUNCTION CreateWindowExA%& (BYVAL dwExStyle~&, BYVAL lpClassName%&, BYVAL lpWindowName%&, BYVAL dwStyle~&, BYVAL x&, BYVAL y&, BYVAL nWidth&, BYVAL nHeight&, BYVAL hWndParent%&, BYVAL hMenu%&, BYVAL hInstance%&, BYVAL lpParam%&)
FUNCTION ShowWindow& (BYVAL hWnd%&, BYVAL nCmdShow&)
FUNCTION UpdateWindow& (BYVAL hWnd%&)
FUNCTION GetMessageA& (BYVAL lpMsg%&, BYVAL hWnd%&, BYVAL wMsgFilterMin~&, BYVAL wMsgFilterMax~&)
FUNCTION TranslateMessage& (BYVAL lpMsg%&)
FUNCTION DispatchMessageA%& (BYVAL lpmsg%&)
END DECLARE
DECLARE DYNAMIC LIBRARY "kernel32"
FUNCTION GetModuleHandleA%& (BYVAL lpModuleName%&)
'FUNCTION GetLastError~& ()
END DECLARE
TYPE POINT
x AS LONG
y AS LONG
END TYPE
' $IF 32BIT THEN
TYPE MSG
hwnd AS _OFFSET
message AS _UNSIGNED LONG
wParam AS _UNSIGNED _OFFSET 'unsigned pointer sized integer
lParam AS _OFFSET 'pointer sized integer
time AS _UNSIGNED LONG
pt AS POINT
END TYPE
TYPE WNDCLASSA
style AS _UNSIGNED LONG
lpfnWndProc AS _OFFSET
cbClsExtra AS LONG
cbWndExtra AS LONG
hInstance AS _OFFSET
hIcon AS _OFFSET
hCursor AS _OFFSET
hbrBackground AS _OFFSET
lpszMenuName AS _OFFSET
lpszClassName AS _OFFSET
END TYPE
DIM SHARED hi AS _OFFSET
DIM SHARED bRet AS LONG
DIM SHARED hw AS _OFFSET
DIM SHARED hwb0 AS _OFFSET
DIM SHARED hwb1 AS _OFFSET
DIM SHARED hwcb AS _OFFSET
DIM SHARED hwgb AS _OFFSET
DIM SHARED hwr0 AS _OFFSET
DIM SHARED hwr1 AS _OFFSET
DIM SHARED hwe AS _OFFSET
DIM SHARED wc AS WNDCLASSA
DIM SHARED wmsg AS MSG
DIM SHARED at AS _UNSIGNED INTEGER
DIM SHARED buf AS STRING * 4096
DIM SHARED discardb AS LONG
DIM SHARED discardp AS _OFFSET
DIM SHARED t0 AS STRING
DIM SHARED t1 AS STRING
DIM SHARED ClassName AS STRING
ClassName = "QB64pe" + CHR$(0)
'DIM SHARED crlf AS STRING * 2
'crlf = MKI$(&HA0D)
hi = GetModuleHandleA(0)
wc.style = 0
wc.lpfnWndProc = GetWindowProc
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hi
wc.hIcon = 0
wc.hCursor = LoadCursorW(0, IDC_ARROW)
wc.hbrBackground = COLOR_WINDOW + 1
wc.lpszMenuName = 0
wc.lpszClassName = _OFFSET(ClassName)
at = RegisterClassA(_OFFSET(wc)): IF 0=at THEN SYSTEM
'create main window
t1 = "title" + CHR$(0)
hw = CreateWindowExA(0, _OFFSET(ClassName), _OFFSET(t1), WS_OVERLAPPEDWINDOW , 200, 200, 800, 600, 0, 0, hi, 0)
IF 0 = hw THEN SYSTEM
'ShowWindow(hw, SW_SHOW)
'UpdateWindow(hw)
discardb = ShowWindow(hw, SW_SHOW)
discardb = UpdateWindow(hw)
'win message loop..................................
DO
bRet = GetMessageA(_OFFSET(wmsg), 0, 0, 0)
SELECT CASE bRet
CASE 0, -1: EXIT DO
END SELECT
discardb = TranslateMessage(_OFFSET(wmsg))
discardp = DispatchMessageA(_OFFSET(wmsg))
'wend
LOOP
'..................................................
FUNCTION WindowProc%& (hWnd AS _OFFSET, uMsg AS _UNSIGNED LONG, wParam AS _UNSIGNED _OFFSET, lParam AS _OFFSET)
SELECT CASE uMsg
CASE WM_DESTROY
PostQuitMessage(0)
WindowProc=0 : EXIT FUNCTION
CASE ELSE
WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam): EXIT FUNCTION
END SELECT
'WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam)
END FUNCTION
RE: GUI app and winAPI calls - SpriggsySpriggs - 03-23-2023
I'll have to compare this to my Win32 Video Player code and get back to you
RE: GUI app and winAPI calls - aurel - 03-23-2023
OK
because i still not found what might goes wrong
RE: GUI app and winAPI calls - aurel - 03-23-2023
well it looks that i found ...i use wrong part of TYPE MSG and TYPE WNDCLASSA
even TYPE WNDCLASSA is old version from win98 times
should be like this o2 code:
'for 32 bit...
TYPE WNDCLASSEX
cbSize as LONG
Style as LONG
lpfnwndproc as _OFFSET
cbClsextra as LONG
cbWndExtra as LONG
hInstance as LONG
hIcon as LONG
hCursor as LONG
hbrBackground as LONG
lpszMenuName as STRING
lpszClassName as STRING
hIconSm AS LONG
END TYPE
anyway ..first working qin api GUI program
Code: (Select All) 'test 1 GUI win32 api in QB64pe v3.2.1 by Aurel
$SCREENHIDE
CONST IDC_ARROW = &H7F00
CONST COLOR_WINDOW = 5
CONST WS_OVERLAPPED = 0
CONST WS_CHILD = &H40000000
CONST WS_VISIBLE = &H10000000
CONST WS_MAXIMIZE = &H01000000
CONST WS_CAPTION = &H00C00000
CONST WS_VSCROLL = &H00200000
CONST WS_HSCROLL = &H00100000
CONST WS_SYSMENU = &H00080000
CONST WS_THICKFRAME = &H00040000
CONST WS_TABSTOP = &H00010000
CONST WS_MINIMIZEBOX = &H00020000
CONST WS_MAXIMIZEBOX = &H00010000
CONST WS_OVERLAPPEDWINDOW = WS_VISIBLE OR WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_THICKFRAME OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX
CONST CW_USEDEFAULT = &H80000000
CONST BS_PUSHBUTTON = 0
CONST BS_AUTOCHECKBOX = 3
CONST BS_GROUPBOX = 7
CONST BS_AUTORADIOBUTTON = 9
CONST BS_TEXT = 0
CONST BN_CLICKED = 0
CONST BM_GETCHECK = &HF0
CONST ES_LEFT = 0
CONST ES_MULTILINE = 4
CONST ES_AUTOVSCROLL = &H0040
CONST ES_AUTOHSCROLL = &H0080
CONST ES_WANTRETURN = &H1000
CONST WM_DESTROY = 2
CONST WM_GETTEXT = &H000D
CONST WM_CLOSE = &H0010
CONST WM_COMMAND = &H0111
CONST SW_SHOWDEFAULT = &HA
CONST SW_SHOW = 5
DECLARE LIBRARY "win"
FUNCTION GetWindowProc%& ()
END DECLARE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SendMessageA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
FUNCTION DefWindowProcA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
SUB PostQuitMessage (BYVAL nExitCode&)
FUNCTION LoadCursorW%& (BYVAL hInstance%&, BYVAL lpCursorName%&)
FUNCTION RegisterClassA~% (BYVAL lpWndClass%&)
'FUNCTION CreateWindowEx%& (ByVal dwExStyle As Long, byval lpClassName%&, byval lpWindowName%&, Byval dwStyle As Long, Byval x As Long, Byval y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As Long, Byval hMenu As Long, Byval hInstance As _OFFSET, Byval lpParam As Long )
FUNCTION CreateWindowExA%& (BYVAL dwExStyle~&, BYVAL lpClassName%&, BYVAL lpWindowName%&, BYVAL dwStyle~&, BYVAL x&, BYVAL y&, BYVAL nWidth&, BYVAL nHeight&, BYVAL hWndParent%&, BYVAL hMenu%&, BYVAL hInstance%&, BYVAL lpParam%&)
FUNCTION ShowWindow& (BYVAL hWnd%&, BYVAL nCmdShow&)
FUNCTION UpdateWindow& (BYVAL hWnd%&)
FUNCTION GetMessageA& (BYVAL lpMsg%&, BYVAL hWnd%&, BYVAL wMsgFilterMin~&, BYVAL wMsgFilterMax~&)
FUNCTION TranslateMessage& (BYVAL lpMsg%&)
FUNCTION DispatchMessageA%& (BYVAL lpmsg%&)
END DECLARE
DECLARE DYNAMIC LIBRARY "kernel32"
FUNCTION GetModuleHandleA%& (BYVAL lpModuleName%&)
'FUNCTION GetLastError~& ()
END DECLARE
TYPE POINT
x AS LONG
y AS LONG
END TYPE
' 64 bit
TYPE MSG
hwnd AS _OFFSET
message AS _OFFSET
wParam AS _UNSIGNED _OFFSET 'unsigned pointer sized integer
lParam AS _OFFSET 'pointer sized integer
time AS _INTEGER64
pt AS POINT
END TYPE
TYPE WNDCLASSA
style AS _INTEGER64
lpfnWndProc AS _OFFSET
cbClsExtra AS LONG
cbWndExtra AS LONG
hInstance AS _OFFSET
hIcon AS _OFFSET
hCursor AS _OFFSET
hbrBackground AS _OFFSET
lpszMenuName AS _OFFSET
lpszClassName AS _OFFSET
END TYPE
DIM SHARED hi AS _OFFSET
DIM SHARED bRet AS LONG
DIM SHARED hw AS _OFFSET
DIM SHARED hwb0 AS _OFFSET
DIM SHARED hwb1 AS _OFFSET
DIM SHARED hwcb AS _OFFSET
DIM SHARED hwgb AS _OFFSET
DIM SHARED hwr0 AS _OFFSET
DIM SHARED hwr1 AS _OFFSET
DIM SHARED hwe AS _OFFSET
DIM SHARED wc AS WNDCLASSA
DIM SHARED wmsg AS MSG
DIM SHARED at AS _UNSIGNED INTEGER
DIM SHARED buf AS STRING * 4096
DIM SHARED sw AS LONG
DIM SHARED uw AS _OFFSET
DIM SHARED t0 AS STRING
DIM SHARED t1 AS STRING
DIM SHARED ClassName AS STRING
ClassName = "QB64pe"
'DIM SHARED crlf AS STRING * 2
'crlf = MKI$(&HA0D)
hi = GetModuleHandleA(0)
wc.style = 0
wc.lpfnWndProc = GetWindowProc
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hi
wc.hIcon = 0
wc.hCursor = LoadCursorW(0, IDC_ARROW)
wc.hbrBackground = COLOR_WINDOW + 1
wc.lpszMenuName = 0
wc.lpszClassName = _OFFSET(ClassName)
at = RegisterClassA(_OFFSET(wc)): IF 0=at THEN SYSTEM
'create main window
t1 = "QB64pe_GUI_App"
hw = CreateWindowExA(0, _OFFSET(ClassName), _OFFSET(t1), WS_OVERLAPPEDWINDOW , 200, 200, 800, 600, 0, 0, hi, 0)
IF 0 = hw THEN SYSTEM
'ShowWindow(hw, SW_SHOW)
'UpdateWindow(hw)
sw = ShowWindow(hw, SW_SHOW)
sw = UpdateWindow(hw)
'win message loop..................................
DO
bRet = GetMessageA(_OFFSET(wmsg), 0, 0, 0)
SELECT CASE bRet
CASE 0, -1: EXIT DO
END SELECT
sw = TranslateMessage(_OFFSET(wmsg))
uw = DispatchMessageA(_OFFSET(wmsg))
'wend
LOOP
'..................................................
FUNCTION WindowProc%& (hWnd AS _OFFSET, uMsg AS _UNSIGNED LONG, wParam AS _UNSIGNED _OFFSET, lParam AS _OFFSET)
SELECT CASE uMsg
CASE WM_DESTROY
PostQuitMessage(0)
WindowProc=0 : EXIT FUNCTION
CASE ELSE
WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam): EXIT FUNCTION
END SELECT
'WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam)
END FUNCTION
RE: GUI app and winAPI calls - aurel - 03-23-2023
One this is also strange
for example most api function need handle or var and =
llike :
bRet = GetMessageA(_OFFSET(wmsg), 0, 0, 0)
when this one not need it :
PostQuitMessage(0)
ahh i get it this on is declared as SUB ...
oh snap
|