I would like to display message boxes at the least.
Also, would be nice open windows and create forms like static and button.
I know how to open/close consoles and graphics windows. I just need regular windows now.
Is there an approach for doing this under -lang qb? Is there a way to use windows.bi with -lang qb or is there some other way?
win api with -lang qb
-
- Posts: 19
- Joined: Mar 06, 2023 2:07
- Location: Arizona
- Contact:
win api with -lang qb
Last edited by lucidapogee on Mar 21, 2023 20:22, edited 1 time in total.
-
- Posts: 131
- Joined: Feb 11, 2013 12:23
Re: gui with -lang qb
One method is to bypass this with external libarys:
Step one:
Compile the libary with functionality that you are missing
Step two:
Compile the mainprogramm, dont forget to remove the '-dll' parameter
Step one:
Compile the libary with functionality that you are missing
Code: Select all
'save as msgbox.bas and compile with the -dll parameter first.
#lang "fb"
#include "windows.bi"
declare sub msgbox alias "msgbox" ( s as string,title as string)
Public Sub msgbox (s as string,title as string) export
MessageBox(NULL,s,title,MB_OK+MB_ICONINFORMATION)
End Sub
Compile the mainprogramm, dont forget to remove the '-dll' parameter
Code: Select all
#lang "qb"
#inclib "msgbox"
declare sub msgbox alias "msgbox" ( s as string, title as string)
msgbox "Hello World","HI"
Re: gui with -lang qb
If you need to go this route there's no need to make a dll. Just compile all the .bas files together in one go. The linker will put them all in one EXE, even if the different .bas files are for different dialects.
Re: gui with -lang qb
Hard work
You have to pick out winapi functions one by one
Example (not very neat)
To help, compile this
and use the pp file as a reference.
You have to pick out winapi functions one by one
Example (not very neat)
Code: Select all
#lang "qb"
#define lptstr __zstring __ptr
#define hwnd any __ptr
#define HINSTANCE hwnd
#define hmenu hwnd
#define LPVOID hwnd
#define ws_overlappedwindow 13565952
#define WS_VISIBLE 268435456
Type Point
As Long x
As Long y
End Type
Type MSG
hwn As HWND
message As __uinteger
wParam As __ulongint
lParam As __ulongint
Time As Long
pt As Point
End Type
'Declare Function SendMessageA(Byval hWn As HWND, Byval Mg As __uinteger, Byval wPara As __ulongint, Byval lPara As __ulongint) As __longint
declare function MessageBox stdcall alias "MessageBoxA"(byval hWn as HWND, byval lpText as LPTSTR, byval lpCaption as LPTSTR, byval uType as __uinteger) as long
Declare Function GetMessage Stdcall Alias "GetMessageA"(Byval lpMsg As msg __ptr, Byval hWn As HWND, Byval wMsgFilterMin As __uinteger, Byval wMsgFilterMax As __uinteger) As __boolean
Declare Function TranslateMessage Stdcall Alias "TranslateMessage"(Byval lpMsg As Const MSG __ptr) As __boolean
Declare Function DispatchMessage Stdcall Alias "DispatchMessageA"(Byval lpMsg As Const MSG __ptr) As __longint
Declare Function CreateWindowEx Stdcall Alias "CreateWindowExA"(Byval dwExStyle As Long, Byval lpClassName As lptstr, Byval lpWindowName As lptstr, Byval dwStyle As Long, Byval X As Long, Byval Y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As HWND, Byval Menu As HMENU, Byval Instance As HINSTANCE, Byval lpParam As LPVOID) As hwnd
Dim As hwnd mainwin
mainwin=createwindowex(0,"#32770","#Lang ""QB"" test window",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,800,600,0,0,0,0)
Dim As msg emsg
While getmessage(@emsg,0,0,0)
TranslateMessage(@emsg)
DispatchMessage(@emsg)
Select Case emsg.message
Case 273 'close by clicking X
messagebox(0,"OK to finish","Messageboxtest",0)
End
End Select
Wend
Sleep
Code: Select all
#cmdline "-pp"
#define winincludeall
#include "windows.bi"
Re: gui with -lang qb
@lucidapogee
why choose the QB dialect in the first place?
you get a lot more functionality with #lang FB
if you just want to compile old QB code then accept it's limitations or maybe use QB64
why choose the QB dialect in the first place?
you get a lot more functionality with #lang FB
if you just want to compile old QB code then accept it's limitations or maybe use QB64
-
- Posts: 19
- Joined: Mar 06, 2023 2:07
- Location: Arizona
- Contact:
Re: win api with -lang qb
I like this option if I want to create a custom portable library of all the functions I need.mrminecrafttnt wrote: ↑Mar 20, 2023 20:00 One method is to bypass this with external libarys:
Step one:
Compile the libary with functionality that you are missingStep two:Code: Select all
'save as msgbox.bas and compile with the -dll parameter first. #lang "fb" #include "windows.bi" declare sub msgbox alias "msgbox" ( s as string,title as string) Public Sub msgbox (s as string,title as string) export MessageBox(NULL,s,title,MB_OK+MB_ICONINFORMATION) End Sub
Compile the mainprogramm, dont forget to remove the '-dll' parameterCode: Select all
#lang "qb" #inclib "msgbox" declare sub msgbox alias "msgbox" ( s as string, title as string) msgbox "Hello World","HI"
I wasn't aware I could do this. This will be good for organizing large projects with many FB functions in a QB lang program.
This method appears to be exactly what I was looking for. Pure, simple, and straight forward. Thank you.dodicat wrote: ↑Mar 21, 2023 10:33 Hard work
You have to pick out winapi functions one by one
Example (not very neat)To help, compile thisCode: Select all
#lang "qb" #define lptstr __zstring __ptr #define hwnd any __ptr #define HINSTANCE hwnd #define hmenu hwnd #define LPVOID hwnd #define ws_overlappedwindow 13565952 #define WS_VISIBLE 268435456 Type Point As Long x As Long y End Type Type MSG hwn As HWND message As __uinteger wParam As __ulongint lParam As __ulongint Time As Long pt As Point End Type 'Declare Function SendMessageA(Byval hWn As HWND, Byval Mg As __uinteger, Byval wPara As __ulongint, Byval lPara As __ulongint) As __longint declare function MessageBox stdcall alias "MessageBoxA"(byval hWn as HWND, byval lpText as LPTSTR, byval lpCaption as LPTSTR, byval uType as __uinteger) as long Declare Function GetMessage Stdcall Alias "GetMessageA"(Byval lpMsg As msg __ptr, Byval hWn As HWND, Byval wMsgFilterMin As __uinteger, Byval wMsgFilterMax As __uinteger) As __boolean Declare Function TranslateMessage Stdcall Alias "TranslateMessage"(Byval lpMsg As Const MSG __ptr) As __boolean Declare Function DispatchMessage Stdcall Alias "DispatchMessageA"(Byval lpMsg As Const MSG __ptr) As __longint Declare Function CreateWindowEx Stdcall Alias "CreateWindowExA"(Byval dwExStyle As Long, Byval lpClassName As lptstr, Byval lpWindowName As lptstr, Byval dwStyle As Long, Byval X As Long, Byval Y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As HWND, Byval Menu As HMENU, Byval Instance As HINSTANCE, Byval lpParam As LPVOID) As hwnd Dim As hwnd mainwin mainwin=createwindowex(0,"#32770","#Lang ""QB"" test window",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,800,600,0,0,0,0) Dim As msg emsg While getmessage(@emsg,0,0,0) TranslateMessage(@emsg) DispatchMessage(@emsg) Select Case emsg.message Case 273 'close by clicking X messagebox(0,"OK to finish","Messageboxtest",0) End End Select Wend Sleep
and use the pp file as a reference.Code: Select all
#cmdline "-pp" #define winincludeall #include "windows.bi"
I was wondering how to send message in FB.
With FreeBasic, I would prefer to code the way dodicat demonstrated. I am coming here from Emergence Basic due to the fact that FreeBasic programs are a good bit faster in execution speed.
I have a large project that is written in both EBasic and QBasic. The best option is to port my code to FreeBasic -qb lang dialect. It's fast and compiles my code. I do not have the time to learn a new dialect and port my entire project over to it right now.
Otherwise, I fully agree. FreeBasic dialect is powerful.
Re: win api with -lang qb
Porting from the QB dialect to FB isn't actually that hard or onerous. I've done with several medium-size programs I had and it wasn't too bad really.