Windows GUI wrapper for FreeBasic

User projects written in or related to FreeBASIC.
nastasa eodor
Posts: 131
Joined: Dec 18, 2018 16:37
Location: Germany, Hessdorf
Contact:

Windows GUI wrapper for FreeBasic

Postby nastasa eodor » Feb 23, 2021 7:45

I propose an idea of Windows GUI wrapper, you can download it here http://rqwork.de/forum/Upload/showthread.php?tid=235, who wants to participate is welcome. Here is repository https://github.com/eodor/FreeBasicWinGUI
some examples:
qbutton_test.bas

Code: Select all

#include once "../gui/kogaion_gui_standards.bas"

dim shared as QForm Form1
dim shared as QButton QButton2

sub BClick(sender as QObject)
    ShowMessage(sender.ClassName)
end sub

QButton2.Parent=Form1
QButton2.SetBounds(102,36,150,36)
QButton2.Text="Click me!"
QButton2.onClick=@BClick

Form1.SetBounds(6,129,400,143)
Form1.Parent=0
application.run

qform_test.bas

Code: Select all

#include once "../gui/kogaion_gui_standards.bas"

type QForm1 extends QForm
    as QButton Button
    declare static sub ButtonClick(sender as QObject)
    declare static sub FormClose(sender as QObject,byref action as integer)
    declare constructor
end type

sub QForm1.ButtonClick(sender as QObject)
    if MessageDlg("Enable " &sender.ClassName &"?","Application",mb_iconinformation or mb_yesno)=idno then
       Q_Button(sender).Enabled=0
    end if
end sub

sub QForm1.FormClose(sender as QObject,byref action as integer)
    select case MessageDlg("Close for sure?","Application",mb_iconquestion or mb_yesno)
    case idyes :action=1:application.Terminate
    case idno:action=0
    end select
end sub

constructor QForm1
    Button.Parent=@this
    Button.Text="Click me!"
    Button.onClick=@ButtonClick
    OnClose=@FormClose
    SetBounds(120,120,550,250)
    Parent=0
end constructor

var Form=QForm1

application.run


qform_dll.bas

Code: Select all

'compile as .dll file
#include once "../gui/kogaion_gui_standards.bas"

type QForm1 extends QForm
    as QButton Button
    declare static sub ButtonClick(sender as QObject)
    declare static sub FormClose(sender as QObject,byref action as integer)
    declare operator cast as any ptr
    declare constructor
end type

sub QForm1.ButtonClick(sender as QObject)
    if MessageDlg("Enable " &sender.ClassName &"?","Application",mb_iconinformation or mb_yesno)=idno then
       Q_Button(sender).Enabled=0
    end if
end sub

sub QForm1.FormClose(sender as QObject,byref action as integer)
    select case MessageDlg("Close for sure?","Application",mb_iconquestion or mb_yesno)
    case idyes :action=1:application.Terminate
    case idno:action=0
    end select
end sub

operator QForm1.cast as any ptr
    return @this
end operator

constructor QForm1
    Parent=0
    Button.Parent=@this
    Button.Text="Click me!"
    Button.onClick=@ButtonClick
    OnClose=@FormClose
    this.SetBounds(120,120,550,250)
    this.visible=1
end constructor

''''
    dim shared as QForm1 ptr F
   
sub init constructor
    QForm.Register
    QButton.Register
    F=new QForm1
end sub

application.run

'''mangled export
function DllForm as QForm1 ptr export
      return F
end function


qform_dll_test.bas

Code: Select all

#include once "windows.bi"

dim shared as hmodule dll=0
dll=dylibload("QForm_dll.dll"):
if dll then
  messagebox(0,"dll is loaded.","Application",0)
else
   ? GetLastError
end if

dylibfree(dll)
nastasa eodor
Posts: 131
Joined: Dec 18, 2018 16:37
Location: Germany, Hessdorf
Contact:

Re: Windows GUI wrapper for FreeBasic

Postby nastasa eodor » Feb 23, 2021 8:56

a more complicated QForm_dll.bas and his dealer with that dll, test_qform_dll.bas
QForm_dll.bas

Code: Select all

#include "../gui/kogaion_gui_standards.bas"

type QForm1 extends QForm
    as QButton Button
    declare static sub ButtonClick(sender as QObject)
    declare static sub FormClose(sender as QObject,byref action as integer)
    declare operator cast as any ptr
    declare constructor(as PFrame=0)
end type

sub QForm1.ButtonClick(sender as QObject)
    if MessageDlg("Enable " &sender.ClassName &"?","Application",mb_iconinformation or mb_yesno)=idno then
       Q_Button(sender).Enabled=0
    end if
end sub

sub QForm1.FormClose(sender as QObject,byref action as integer)
    select case MessageDlg("Close for sure?","Application",mb_iconquestion or mb_yesno)
    case idyes :action=1:application.Terminate
    case idno:action=0
    end select
end sub

operator QForm1.cast as any ptr
    return @this
end operator

constructor QForm1(v as PFrame=0)
    Parent=v
    Button.Parent=@this
    Button.Text="Click me!"
    Button.onClick=@ButtonClick
    OnClose=@FormClose
    this.SetBounds(120,120,550,250)
    this.visible=1
end constructor

''''
    dim shared as QForm1 ptr F
   
sub init constructor
    QForm.Register
    QButton.Register
    F=new QForm1
end sub

sub __Run export
    application.run
end sub

function Form(v as boolean=0) as QForm1 ptr export
    return new QForm1(iif(v,F,0))
end function



test_QForm_dll.bas

Code: Select all

#include once "windows.bi"
#include "..\gui\kogaion_gui.bas"

dim shared as hmodule dll=0
dll=dylibload("QForm_dll.dll"):
if dll then
  dim as sub __run
  __run=dylibsymbol(dll,"__RUN@0")
  messagebox(0,"dll is loaded.","Application",0)
  dim as function(as Boolean=0) as QCustomForm ptr Form
  Form=dylIbsymbol(dll,"FORM@4")
  if Form then : ? "dll form=",Form
      dim as QCustomForm ptr frm=Form(1)
      Frm->Text="form"
  end if
  /'if __Run then __Run()'/
  application.run
else
   ? GetLastError
end if

dylibfree(dll)
Xusinboy Bekchanov
Posts: 388
Joined: Jul 26, 2018 18:28

Re: Windows GUI wrapper for FreeBasic

Postby Xusinboy Bekchanov » Feb 23, 2021 10:09

Good work. It's good that it's on Github now.
nastasa eodor
Posts: 131
Joined: Dec 18, 2018 16:37
Location: Germany, Hessdorf
Contact:

Re: Windows GUI wrapper for FreeBasic

Postby nastasa eodor » Feb 23, 2021 10:51

Xusinboy Bekchanov wrote:Good work. It's good that it's on Github now.

thank you, yes it is, i will update there too

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 4 guests