Re: Windows API `Hello World!`
Hi Michael...
I don't believe everything what he saying but this time i think
that is true.It looks that is Cbasic limited in this concret problem.
I have source code from VB6 for API Window but I don't try them
yet.As i see thinBasic can do that with oxygen modul and with
oxygen .dll .
Maby it's posible directly - that would be cool.
Zlatko
Re: Windows API `Hello World!`
Ok, I thought he ment in general not possible.
Re: Windows API `Hello World!`
Hi I must say that is very interesting problematic and like Charles say
i find something very interesting on Free Basic Forum.Look code:
Code:
#Include "windows.bi"
Dim As MSG msg ' Message variable (stores massages)
Dim As HWND hWnd ' Window variable
' Create window
hWnd = CreateWindowEx( 0, "#32770", "Hello", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 500, 300, 0, 0, 0, 0 )
While GetMessage( @msg, 0, 0, 0 ) ' Get message from window
TranslateMessage( @msg )
DispatchMessage( @msg )
Select Case msg.hwnd
Case hWnd ' If msg is window hwnd: get messages from window
Select Case msg.message
Case 273 ' Get message when 'X' was pressed
End
End Select
End Select
Wend
You must say that look very simple. :roll:
And little bit weird.So i try something similiar on CBasic and work
but not properly.I can open new window,without focus and can not
be closed with closebox button"X".One interesting thing ,window is
like standalone compiled app :shock:
I don't try on thinBasic bacose i don't know shape of APi-s.
Is the same like this or different?
Code:
DECLARE "user32",CreateWindowExA(dwExStyle AS INT,lpClassName AS STRING,lpWindowName AS STRING,dwStyle AS INT,x AS INT,y AS INT,nWidth AS INT,nHeight AS INT,hWndParent AS INT,hMenu AS INT,hInstance AS INT,lpParam AS INT),INT
DECLARE "user32",GetMessageA(lpMsg AS MSG,hwnd AS INT,wMsgFilterMin AS INT,wMsgFilterMax AS INT),INT
DECLARE "user32",TranslateMessage(lpMsg AS MSG),INT
DECLARE "user32",DispatchMessageA(lpMsg AS MSG),INT
DECLARE "user32", PostQuitMessage(nExitCode AS INT)
Re: Windows API `Hello World!`
Hi Zlatco,
Try 256 instead of 273. 256 is the WM_KEYDOWN message -
this is what I tried in o2h (wm is the message variable)
[code=thinbasic]
while GetMessage &wm,0,0,0
TranslateMessage &wm
DispatchMessage &wm
'
select wm.hwnd
case hwnd
if wm.message=256 then print `key down` : exit do
end select
'
wend
[/code]
Re: Windows API `Hello World!`
Hi Charles...
I always recive error that Argument is wrong type in
Code:
While GetMessageA( wmsg,0, 0, 0 ) :' Get message from window
So which message close window?
Or what argument is wrong ,hmm it looks very tricky.
Re: Windows API `Hello World!`
GetMessage needs the address of the message: varptr(msg) &msg or @msg, whatevever syntax Cbasic uses.
I am assuming the Win header files follow the standard C version.
Charles
Re: Windows API `Hello World!`
Aha I see ...
So there is the main problem .
CBasic can't pass or see adress so only I can try with pointer.
But i think that is not posible.
Whatever thanks on all answers,Charles.
Zlatko