VisualFBEditor - IDE for FreeBasic

User projects written in or related to FreeBASIC.
Post Reply
Avata
Posts: 102
Joined: Jan 17, 2021 7:27

Re: VisualFBEditor - IDE for FreeBasic

Post by Avata »

I think it is a intersting project to make a notepad project as a examples.
Welcome everybody to come improving the code.

In My last code showing how to design a menu inncluding hotkey and showing ico on menu items.
Last edited by Avata on Aug 16, 2022 17:06, edited 1 time in total.
Xusinboy Bekchanov
Posts: 783
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

flaviofornazier wrote: Aug 15, 2022 21:37 Requests:

- The name of the currently component as a "Caption" on top of the Properties/Events window would be interesting to avoid confusion.
Added: Showing Selected Control Name in Properties and Events Windows
https://github.com/XusinboyBekchanov/Vi ... fbb06480ef
flaviofornazier wrote: Aug 15, 2022 21:37 - A new menu and/or toolbar option like "Add Sub and/or Function" inside the active code window. The general doubt is "where declare and write a sub and/or function inside the form code".
We also do this when we have time.
flaviofornazier wrote: Aug 15, 2022 21:37 - Assuming that you have total control under code inside form #Region and #End Region, an option to review/reescan forms code and delete all references to components that no longer exist.
Maybe there are only procedures. We can remove the empty procedures of already removed components.
flaviofornazier wrote: Aug 15, 2022 21:37 Questions inside form code:

- Where is the right place to declare a sub or function at form level and write its code? (a procedure that can access all form components )
Inside Type Form1Type ... End Type
flaviofornazier wrote: Aug 15, 2022 21:37 - Where is the right place to define a shared variable?
If you want not to be visible outside the form then declare inside Type Form1Type ... End Type
flaviofornazier wrote: Aug 15, 2022 21:37 - If I have an invisible command button named cmdList in the form, can I call its default event like a sub? e.g.: cmdList_Click(cmdList).
Yes.
flaviofornazier wrote: Aug 15, 2022 21:37 The sender is the name of control?
Yes.
flaviofornazier wrote: Aug 15, 2022 21:37 - How to dynamically create a new modal instance of a form?

Thank you in advanced.
Like this:

Code: Select all

Private Sub Form1Type.Form_Click(ByRef Sender As Control)
	Dim frm As Form
	frm.ShowModal Form1
End Sub
Avata
Posts: 102
Joined: Jan 17, 2021 7:27

Re: VisualFBEditor - IDE for FreeBasic

Post by Avata »

Could you please add some commennts in the Templates files. And could replace to locale language when add from templates.

Code: Select all

'Place code here to declare a sub or function at form level!
Dim Shared As frmFind fFind
pfFind = @fFind

flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Xusinboy Bekchanov wrote: Aug 16, 2022 9:00
flaviofornazier wrote: Aug 15, 2022 21:37 Requests:

- The name of the currently component as a "Caption" on top of the Properties/Events window would be interesting to avoid confusion.
Added: Showing Selected Control Name in Properties and Events Windows
https://github.com/XusinboyBekchanov/Vi ... fbb06480ef

Done. I think that really does make things clearer. Thank you.
flaviofornazier wrote: Aug 15, 2022 21:37 - A new menu and/or toolbar option like "Add Sub and/or Function" inside the active code window. The general doubt is "where declare and write a sub and/or function inside the form code".
We also do this when we have time.

It sounds silly, but I would also suggest a box that asks for all possible sub/function characteristics.
flaviofornazier wrote: Aug 15, 2022 21:37 - Assuming that you have total control under code inside form #Region and #End Region, an option to review/reescan forms code and delete all references to components that no longer exist.
Maybe there are only procedures. We can remove the empty procedures of already removed components.

Well, I think that is the most important, if programmers delete a form component and does not have the necessary knowledge about the framework, they will give up easily.
flaviofornazier wrote: Aug 15, 2022 21:37 Questions inside form code:

- Where is the right place to declare a sub or function at form level and write its code? (a procedure that can access all form components )
Inside Type Form1Type ... End Type

Can you give me more info? There's a "sub test" in the project that I sent you, please note that sub does not recognize forms components, except if you reference a form, e.g.: Form1.TextBox1.Text = ...
flaviofornazier wrote: Aug 15, 2022 21:37 - Where is the right place to define a shared variable?
If you want not to be visible outside the form then declare inside Type Form1Type ... End Type

Thank you.
flaviofornazier wrote: Aug 15, 2022 21:37 - If I have an invisible command button named cmdList in the form, can I call its default event like a sub? e.g.: cmdList_Click(cmdList).
Yes.

Thank you.

flaviofornazier wrote: Aug 15, 2022 21:37 The sender is the name of control?
Yes.

Thank you.

flaviofornazier wrote: Aug 15, 2022 21:37 - How to dynamically create a new modal instance of a form?

Thank you in advanced.
Like this:

Code: Select all

Private Sub Form1Type.Form_Click(ByRef Sender As Control)
	Dim frm As Form
	frm.ShowModal Form1
End Sub
Just a small correction: the above code just create a new blank form. The correct would be:

Code: Select all

Private Sub Form1Type.Form_Click(ByRef Sender As Control)
	Dim frm As Form1Type
	frm.ShowModal Form1
End Sub
[/i]

Thank you for your patience.
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Avata wrote: Aug 16, 2022 12:10 Could you please add some commennts in the Templates files. And could replace to locale language when add from templates.

Code: Select all

'Place code here to declare a sub or function at form level!
Dim Shared As frmFind fFind
pfFind = @fFind

I think it's a good idea. :mrgreen:
Xusinboy Bekchanov
Posts: 783
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

flaviofornazier wrote: Aug 17, 2022 20:30 It sounds silly, but I would also suggest a box that asks for all possible sub/function characteristics.
Added: Add Procedure Form:
https://github.com/XusinboyBekchanov/Vi ... d54a1497ce

You can see the form. There was no time to add internal functions yet.
flaviofornazier wrote: Aug 15, 2022 21:37 Can you give me more info? There's a "sub test" in the project that I sent you, please note that sub does not recognize forms components, except if you reference a form, e.g.: Form1.TextBox1.Text = ...
So:

Code: Select all

#ifdef __FB_WIN32__
	#cmdline "Form1.rc"
#endif

'#Region "Form"
	#include once "mff/Form.bi"
	#include once "SQLite3Component.bi"
	#include once "mff/ListControl.bi"
	#include once "mff/CommandButton.bi"
	#include once "mff/TextBox.bi"
	#include once "mymodule.bas"
	#include once "mff/Menus.bi"
	
	Using My.Sys.Forms
	
	Type Form1Type Extends Form
		Declare Static Sub _Form_Show(ByRef Sender As Form)
		Declare Sub Form_Show(ByRef Sender As Form)
		Declare Static Sub _cmdInsert_Click(ByRef Sender As Control)
		Declare Sub cmdInsert_Click(ByRef Sender As Control)
		Declare Static Sub _Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		Declare Sub Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		Declare Static Sub _db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		Declare Sub db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		Declare Static Function _db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Declare Function db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Declare Static Sub _cmdDelete_Click(ByRef Sender As Control)
		Declare Sub cmdDelete_Click(ByRef Sender As Control)
		Declare Static Sub _cmdflst_Click(ByRef Sender As Control)
		Declare Sub cmdflst_Click(ByRef Sender As Control)
		Declare Static Sub _MenuItem2_Click(ByRef Sender As MenuItem)
		Declare Sub MenuItem2_Click(ByRef Sender As MenuItem)
		Declare Constructor
		Declare Sub Test()
		
		Dim As SQLite3Component db
		Dim As ListControl ListName
		Dim As CommandButton cmdInsert, cmdflst, cmdDelete
		Dim As TextBox txtName
		Dim As MainMenu MainMenu1
		Dim As MenuItem MenuItem1, MenuItem2
	End Type
	
	Constructor Form1Type
		' Form1
		With This
			.Name = "Form1"
			.Text = "SQLite Tests"
			.Designer = @This
			.OnShow = @_Form_Show
			.OnClose = @_Form_Close
			.DefaultButton = @cmdInsert
			.StartPosition = FormStartPosition.CenterScreen
			.Caption = "SQLite Tests"
			.Menu = @MainMenu1
			.SetBounds 0, -4, 350, 299
		End With
		' db
		With db
			.Name = "db"
			.SetBounds 319, 156, 16, 16
			.Designer = @This
			.OnErrorOut = @_db_ErrorOut
			.OnSQLString = @_db_SQLString
			.Parent = @This
		End With
		' ListName
		With ListName
			.Name = "ListName"
			.Text = "ListControl1"
			.TabIndex = 2
			.Anchor.Top = 1
			.Anchor.Right = 1
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Names list"
			.SetBounds 16, 17, 296, 108
			.Designer = @This
			.Parent = @This
		End With
		' cmdInsert
		With cmdInsert
			.Name = "cmdInsert"
			.Caption = "Insert"
			.Text = "Insert"
			.Default = True
			.TabIndex = 1
			.Anchor.Right = 0
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Click to insert a name"
			.SetBounds 43, 182, 69, 25
			.Designer = @This
			.OnClick = @_cmdInsert_Click
			.Parent = @This
		End With
		' txtName
		With txtName
			.Name = "txtName"
			.Text = ""
			.TabIndex = 0
			.Anchor.Right = 1
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Type name here"
			.SetBounds 18, 137, 294, 26
			.Designer = @This
			.Parent = @This
		End With
		' cmdflst
		With cmdflst
			.Name = "cmdflst"
			.Text = "List"
			.TabIndex = 5
			.BackColor = 16777215
			.ControlIndex = 3
			.Default = True
			.Hint = "Click to open form list"
			.SetBounds 242, 181, 69, 25
			.Designer = @This
			.OnClick = @_cmdflst_Click
			.Parent = @This
		End With
		' cmdDelete
		With cmdDelete
			.Name = "cmdDelete"
			.Text = "Delete"
			.TabIndex = 5
			.Caption = "Delete"
			.SetBounds 144, 182, 64, 24
			.Designer = @This
			.OnClick = @_cmdDelete_Click
			.Parent = @This
		End With
		' MainMenu1
		With MainMenu1
			.Name = "MainMenu1"
			.SetBounds 15, 218, 16, 16
			.Designer = @This
			.Parent = @This
		End With
		' MenuItem1
		With MenuItem1
			.Name = "MenuItem1"
			.Designer = @This
			.Caption = "File"
			.Parent = @MainMenu1
		End With
		' MenuItem2
		With MenuItem2
			.Name = "MenuItem2"
			.Designer = @This
			.Caption = "Open	"
			.onClick = @_MenuItem2_Click
			.Parent = @MenuItem1
		End With
	End Constructor
	
	Private Sub Form1Type._MenuItem2_Click(ByRef Sender As MenuItem)
		*Cast(Form1Type Ptr, Sender.Designer).MenuItem2_Click(Sender)
	End Sub
	
	Private Sub Form1Type._cmdflst_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdflst_Click(Sender)
	End Sub
	

	Private Sub Form1Type._cmdDelete_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdDelete_Click(Sender)
	End Sub
	
	Private Function Form1Type._db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Return *Cast(Form1Type Ptr, Sender.Designer).db_SQLString(Sender, Sql_Utf8)
	End Function
	
	Private Sub Form1Type._db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		*Cast(Form1Type Ptr, Sender.Designer).db_ErrorOut(Sender, ErrorTxt)
	End Sub
	
	Private Sub Form1Type._Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		*Cast(Form1Type Ptr, Sender.Designer).Form_Close(Sender, Action)
	End Sub
	
	Private Sub Form1Type._cmdInsert_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdInsert_Click(Sender)
	End Sub
	
	
	Private Sub Form1Type._Form_Show(ByRef Sender As Form)
		*Cast(Form1Type Ptr, Sender.Designer).Form_Show(Sender)
	End Sub
	
	
	
	Dim Shared Form1 As Form1Type
	
	#ifndef _NOT_AUTORUN_FORMS_
		#define _NOT_AUTORUN_FORMS_
		
		Form1.Show
		
		App.Run
	#endif
'#End Region

Declare Sub Test()
#include once "Form2.frm"
#include once "Form3.frm"


Private Sub Form1Type.Form_Show(ByRef Sender As Form)
    On Error Goto ErrorHandler
    
	
	'If FileExists("database.sqlite") = -1 Then Exit Sub
	'MsgBox ExePath()
	Dim ret As Long
	ret = db.Open(ExePath() + "\database.sqlite")
	'MsgBox "Open " + Str$(ret)
	Test()
	If FileExists("database.sqlite") Then Exit Sub
	ret = db.CreateTable("persons")
	MsgBox "CreateTable " + Str$(ret)
	ret = db.AddField("persons", "id", "integer", , -1)
	MsgBox "AddField id " + Str$(ret)
	db.AddField("persons", "name", "text", , -1)
	MsgBox "AddField name " + Str$(ret)
	db.CreateIndex("persons", "name", "name", -1)
	MsgBox "CreateIndex name " + Str$(ret)
	MsgBox "AddItem " + Str$(ret)
	MsgBox "Errmsg = " + db.ErrMsg
	'ret = db.Exec("INSERT INTO persons (name) VALUES ('FLAVIO');")
	'MsgBox "Exec " + Str$(ret)
	' If db.Open("database.sqlite")  = -1 Then
	'	MsgBox("Create and/or Open Database OK")
	'Else
	'	MsgBox("Create and/or Open Database fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'If db.CreateTable("persons") = 0 Then
	'	MsgBox("Create Table OK")
	'Else
	'	MsgBox("Create Table fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'
	'If db.AddField("persons", "id", "integer,primary key", "", 1) Then
	'	MsgBox("Create field 'id' OK")
	'Else
	'	MsgBox("Create field 'id' fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'
	'If db.AddField("persons", "name", "text,60,unique", , 1) Then
	'	MsgBox("Create field 'name' OK")
	'Else
	'	MsgBox("Create field 'name' fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
	End
End Sub



Private Sub Form1Type.cmdInsert_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Dim As String rs()
	Dim As String xname
	Dim As Long x
	Dim As Long y
	xname = Trim$(UCase(txtName.Text))
	If Len(xname) < 1 Then
		MsgBox "Name is required"
		Exit Sub
	End If
	If db.FindOne("persons", "name = '" + xname + "'", rs(), "name") Then
		For y = 0 To UBound(rs)
			For x = 0 To UBound(rs, 2)
			Next
		Next
		MsgBox "Name already exist"
		Exit Sub
	Else
		If db.Insert("persons", "name = '" + xname + "'") Then
			MsgBox xname + " added"
		Else
			MsgBox "Fail to insert " + xname
		End If
	End If
	'
	Test()
	MsgBox Str(db.Count("persons")) + " record(s)"
	Form1.txtName.Clear
	Form1.txtName.SetFocus
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.Form_Close(ByRef Sender As Form, ByRef Action As Integer)
	db.Close()
End Sub

Private Sub Form1Type.db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
	'MsgBox "ErrorOut Event: " + ErrorTxt
End Sub

Private Function Form1Type.db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
	'MsgBox "SQLString Event: " + Sql_Utf8	
	Function = False
End Function



Private Sub Form1Type.cmdDelete_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Form3.Show Form1
	Exit Sub
	If ListName.ItemIndex < 0 Then
		MsgBox "Select a name"
		Exit Sub
	Else
		Dim As String xname
		xname = ListName.Item(ListName.ItemIndex)
		db.DeleteItemUtf("persons", "name = '" + xname + "'")
		Test()
		MsgBox xname + " deleted " + " (" + Str(db.Count("persons", "id > 0")) + " record(s)"
		Form1.txtName.Clear
		Form1.txtName.SetFocus
	End If
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.cmdflst_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Form2.Show Form1
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.Test()
    On Error Goto ErrorHandler
	Dim As String ls()
	Dim As Long x, y
	ListName.Clear
	If db.Find("persons", "name is NOT NULL", ls(), "name", "name") Then
		For y = 0 To UBound(ls)
			For x = 0 To UBound(ls, 2)
				If y > 0 Then ListName.AddItem(ls(y, x))
			Next
		Next
	End If
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.MenuItem2_Click(ByRef Sender As MenuItem)
    On Error Goto ErrorHandler
	Form3.Show Form1
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub
flaviofornazier wrote: Aug 17, 2022 20:30 Just a small correction: the above code just create a new blank form. The correct would be:

Code: Select all

Private Sub Form1Type.Form_Click(ByRef Sender As Control)
	Dim frm As Form1Type
	frm.ShowModal Form1
End Sub
[/i]
I didn't know you wanted to create Form1Type.
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Avata wrote: Aug 16, 2022 7:43 I think it is a intersting project to make a notepad project as a examples.
Welcome everybody to come improving the code.

In My last code showing how to design a menu inncluding hotkey and showing ico on menu items.
Mr.Avatar,

Please post your project with its resources.

Thank you in advanced.
Xusinboy Bekchanov
Posts: 783
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

Avata wrote: Aug 16, 2022 12:10 Could you please add some commennts in the Templates files. And could replace to locale language when add from templates.

Code: Select all

'Place code here to declare a sub or function at form level!
Dim Shared As frmFind fFind
pfFind = @fFind

To do this, we must add two files at once: Form1.frm and Form1.bi.

Form1.bi will have the following code (to compile with makefile):

Code: Select all

Common Shared pForm1 As Form1Type Ptr
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Xusinboy Bekchanov wrote: Aug 17, 2022 21:05
flaviofornazier wrote: Aug 17, 2022 20:30 It sounds silly, but I would also suggest a box that asks for all possible sub/function characteristics.
Added: Add Procedure Form:
https://github.com/XusinboyBekchanov/Vi ... d54a1497ce

Thank you.

You can see the form. There was no time to add internal functions yet.

Don't worried, I fully understand you.
flaviofornazier wrote: Aug 15, 2022 21:37 Can you give me more info? There's a "sub test" in the project that I sent you, please note that sub does not recognize forms components, except if you reference a form, e.g.: Form1.TextBox1.Text = ...
So:

Code: Select all

#ifdef __FB_WIN32__
	#cmdline "Form1.rc"
#endif

'#Region "Form"
	#include once "mff/Form.bi"
	#include once "SQLite3Component.bi"
	#include once "mff/ListControl.bi"
	#include once "mff/CommandButton.bi"
	#include once "mff/TextBox.bi"
	#include once "mymodule.bas"
	#include once "mff/Menus.bi"
	
	Using My.Sys.Forms
	
	Type Form1Type Extends Form
		Declare Static Sub _Form_Show(ByRef Sender As Form)
		Declare Sub Form_Show(ByRef Sender As Form)
		Declare Static Sub _cmdInsert_Click(ByRef Sender As Control)
		Declare Sub cmdInsert_Click(ByRef Sender As Control)
		Declare Static Sub _Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		Declare Sub Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		Declare Static Sub _db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		Declare Sub db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		Declare Static Function _db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Declare Function db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Declare Static Sub _cmdDelete_Click(ByRef Sender As Control)
		Declare Sub cmdDelete_Click(ByRef Sender As Control)
		Declare Static Sub _cmdflst_Click(ByRef Sender As Control)
		Declare Sub cmdflst_Click(ByRef Sender As Control)
		Declare Static Sub _MenuItem2_Click(ByRef Sender As MenuItem)
		Declare Sub MenuItem2_Click(ByRef Sender As MenuItem)
		Declare Constructor
		Declare Sub Test()
		
		Dim As SQLite3Component db
		Dim As ListControl ListName
		Dim As CommandButton cmdInsert, cmdflst, cmdDelete
		Dim As TextBox txtName
		Dim As MainMenu MainMenu1
		Dim As MenuItem MenuItem1, MenuItem2
	End Type
	
	Constructor Form1Type
		' Form1
		With This
			.Name = "Form1"
			.Text = "SQLite Tests"
			.Designer = @This
			.OnShow = @_Form_Show
			.OnClose = @_Form_Close
			.DefaultButton = @cmdInsert
			.StartPosition = FormStartPosition.CenterScreen
			.Caption = "SQLite Tests"
			.Menu = @MainMenu1
			.SetBounds 0, -4, 350, 299
		End With
		' db
		With db
			.Name = "db"
			.SetBounds 319, 156, 16, 16
			.Designer = @This
			.OnErrorOut = @_db_ErrorOut
			.OnSQLString = @_db_SQLString
			.Parent = @This
		End With
		' ListName
		With ListName
			.Name = "ListName"
			.Text = "ListControl1"
			.TabIndex = 2
			.Anchor.Top = 1
			.Anchor.Right = 1
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Names list"
			.SetBounds 16, 17, 296, 108
			.Designer = @This
			.Parent = @This
		End With
		' cmdInsert
		With cmdInsert
			.Name = "cmdInsert"
			.Caption = "Insert"
			.Text = "Insert"
			.Default = True
			.TabIndex = 1
			.Anchor.Right = 0
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Click to insert a name"
			.SetBounds 43, 182, 69, 25
			.Designer = @This
			.OnClick = @_cmdInsert_Click
			.Parent = @This
		End With
		' txtName
		With txtName
			.Name = "txtName"
			.Text = ""
			.TabIndex = 0
			.Anchor.Right = 1
			.Anchor.Left = 1
			.Anchor.Bottom = 1
			.Hint = "Type name here"
			.SetBounds 18, 137, 294, 26
			.Designer = @This
			.Parent = @This
		End With
		' cmdflst
		With cmdflst
			.Name = "cmdflst"
			.Text = "List"
			.TabIndex = 5
			.BackColor = 16777215
			.ControlIndex = 3
			.Default = True
			.Hint = "Click to open form list"
			.SetBounds 242, 181, 69, 25
			.Designer = @This
			.OnClick = @_cmdflst_Click
			.Parent = @This
		End With
		' cmdDelete
		With cmdDelete
			.Name = "cmdDelete"
			.Text = "Delete"
			.TabIndex = 5
			.Caption = "Delete"
			.SetBounds 144, 182, 64, 24
			.Designer = @This
			.OnClick = @_cmdDelete_Click
			.Parent = @This
		End With
		' MainMenu1
		With MainMenu1
			.Name = "MainMenu1"
			.SetBounds 15, 218, 16, 16
			.Designer = @This
			.Parent = @This
		End With
		' MenuItem1
		With MenuItem1
			.Name = "MenuItem1"
			.Designer = @This
			.Caption = "File"
			.Parent = @MainMenu1
		End With
		' MenuItem2
		With MenuItem2
			.Name = "MenuItem2"
			.Designer = @This
			.Caption = "Open	"
			.onClick = @_MenuItem2_Click
			.Parent = @MenuItem1
		End With
	End Constructor
	
	Private Sub Form1Type._MenuItem2_Click(ByRef Sender As MenuItem)
		*Cast(Form1Type Ptr, Sender.Designer).MenuItem2_Click(Sender)
	End Sub
	
	Private Sub Form1Type._cmdflst_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdflst_Click(Sender)
	End Sub
	

	Private Sub Form1Type._cmdDelete_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdDelete_Click(Sender)
	End Sub
	
	Private Function Form1Type._db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
		Return *Cast(Form1Type Ptr, Sender.Designer).db_SQLString(Sender, Sql_Utf8)
	End Function
	
	Private Sub Form1Type._db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
		*Cast(Form1Type Ptr, Sender.Designer).db_ErrorOut(Sender, ErrorTxt)
	End Sub
	
	Private Sub Form1Type._Form_Close(ByRef Sender As Form, ByRef Action As Integer)
		*Cast(Form1Type Ptr, Sender.Designer).Form_Close(Sender, Action)
	End Sub
	
	Private Sub Form1Type._cmdInsert_Click(ByRef Sender As Control)
		*Cast(Form1Type Ptr, Sender.Designer).cmdInsert_Click(Sender)
	End Sub
	
	
	Private Sub Form1Type._Form_Show(ByRef Sender As Form)
		*Cast(Form1Type Ptr, Sender.Designer).Form_Show(Sender)
	End Sub
	
	
	
	Dim Shared Form1 As Form1Type
	
	#ifndef _NOT_AUTORUN_FORMS_
		#define _NOT_AUTORUN_FORMS_
		
		Form1.Show
		
		App.Run
	#endif
'#End Region

Declare Sub Test()
#include once "Form2.frm"
#include once "Form3.frm"


Private Sub Form1Type.Form_Show(ByRef Sender As Form)
    On Error Goto ErrorHandler
    
	
	'If FileExists("database.sqlite") = -1 Then Exit Sub
	'MsgBox ExePath()
	Dim ret As Long
	ret = db.Open(ExePath() + "\database.sqlite")
	'MsgBox "Open " + Str$(ret)
	Test()
	If FileExists("database.sqlite") Then Exit Sub
	ret = db.CreateTable("persons")
	MsgBox "CreateTable " + Str$(ret)
	ret = db.AddField("persons", "id", "integer", , -1)
	MsgBox "AddField id " + Str$(ret)
	db.AddField("persons", "name", "text", , -1)
	MsgBox "AddField name " + Str$(ret)
	db.CreateIndex("persons", "name", "name", -1)
	MsgBox "CreateIndex name " + Str$(ret)
	MsgBox "AddItem " + Str$(ret)
	MsgBox "Errmsg = " + db.ErrMsg
	'ret = db.Exec("INSERT INTO persons (name) VALUES ('FLAVIO');")
	'MsgBox "Exec " + Str$(ret)
	' If db.Open("database.sqlite")  = -1 Then
	'	MsgBox("Create and/or Open Database OK")
	'Else
	'	MsgBox("Create and/or Open Database fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'If db.CreateTable("persons") = 0 Then
	'	MsgBox("Create Table OK")
	'Else
	'	MsgBox("Create Table fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'
	'If db.AddField("persons", "id", "integer,primary key", "", 1) Then
	'	MsgBox("Create field 'id' OK")
	'Else
	'	MsgBox("Create field 'id' fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	'
	'If db.AddField("persons", "name", "text,60,unique", , 1) Then
	'	MsgBox("Create field 'name' OK")
	'Else
	'	MsgBox("Create field 'name' fails " + db.ErrMsg)
	'	Exit Sub
	'End If
	
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
	End
End Sub



Private Sub Form1Type.cmdInsert_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Dim As String rs()
	Dim As String xname
	Dim As Long x
	Dim As Long y
	xname = Trim$(UCase(txtName.Text))
	If Len(xname) < 1 Then
		MsgBox "Name is required"
		Exit Sub
	End If
	If db.FindOne("persons", "name = '" + xname + "'", rs(), "name") Then
		For y = 0 To UBound(rs)
			For x = 0 To UBound(rs, 2)
			Next
		Next
		MsgBox "Name already exist"
		Exit Sub
	Else
		If db.Insert("persons", "name = '" + xname + "'") Then
			MsgBox xname + " added"
		Else
			MsgBox "Fail to insert " + xname
		End If
	End If
	'
	Test()
	MsgBox Str(db.Count("persons")) + " record(s)"
	Form1.txtName.Clear
	Form1.txtName.SetFocus
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.Form_Close(ByRef Sender As Form, ByRef Action As Integer)
	db.Close()
End Sub

Private Sub Form1Type.db_ErrorOut(ByRef Sender As SQLite3Component, ErrorTxt As String)
	'MsgBox "ErrorOut Event: " + ErrorTxt
End Sub

Private Function Form1Type.db_SQLString(ByRef Sender As SQLite3Component, Sql_Utf8 As String) As Long
	'MsgBox "SQLString Event: " + Sql_Utf8	
	Function = False
End Function



Private Sub Form1Type.cmdDelete_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Form3.Show Form1
	Exit Sub
	If ListName.ItemIndex < 0 Then
		MsgBox "Select a name"
		Exit Sub
	Else
		Dim As String xname
		xname = ListName.Item(ListName.ItemIndex)
		db.DeleteItemUtf("persons", "name = '" + xname + "'")
		Test()
		MsgBox xname + " deleted " + " (" + Str(db.Count("persons", "id > 0")) + " record(s)"
		Form1.txtName.Clear
		Form1.txtName.SetFocus
	End If
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.cmdflst_Click(ByRef Sender As Control)
    On Error Goto ErrorHandler
	Form2.Show Form1
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.Test()
    On Error Goto ErrorHandler
	Dim As String ls()
	Dim As Long x, y
	ListName.Clear
	If db.Find("persons", "name is NOT NULL", ls(), "name", "name") Then
		For y = 0 To UBound(ls)
			For x = 0 To UBound(ls, 2)
				If y > 0 Then ListName.AddItem(ls(y, x))
			Next
		Next
	End If
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub

Private Sub Form1Type.MenuItem2_Click(ByRef Sender As MenuItem)
    On Error Goto ErrorHandler
	Form3.Show Form1
    Exit Sub
ErrorHandler:
    MsgBox ErrDescription(Err) & " (" & Err & ") " & _
        "in line " & Erl() & " (Handler line: " & __LINE__ & ") " & _
        "in function " & ZGet(Erfn()) & " (Handler function: " & __FUNCTION__ & ") " & _
        "in module " & ZGet(Ermn()) & " (Handler file: " & __FILE__ & ") "
End Sub
Now it's clear. Thank you.
flaviofornazier wrote: Aug 17, 2022 20:30 Just a small correction: the above code just create a new blank form. The correct would be:

Code: Select all

Private Sub Form1Type.Form_Click(ByRef Sender As Control)
	Dim frm As Form1Type
	frm.ShowModal Form1
End Sub
[/i]
I didn't know you wanted to create Form1Type.
Don't worried. Just to avoid bad practices. I'll write you a private email.

Thank you very much.
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Mr.Bekchanov,

I sent you two private emails.

When you have time please check your spam folder.

Thank you in advanced.
Xusinboy Bekchanov
Posts: 783
Joined: Jul 26, 2018 18:28

Re: VisualFBEditor - IDE for FreeBasic

Post by Xusinboy Bekchanov »

flaviofornazier wrote: Aug 18, 2022 5:14 Mr.Bekchanov,

I sent you two private emails.

When you have time please check your spam folder.

Thank you in advanced.
The letter has not arrived. I also checked spam folders.
Avata
Posts: 102
Joined: Jan 17, 2021 7:27

Re: VisualFBEditor - IDE for FreeBasic

Post by Avata »

flaviofornazier wrote: Aug 17, 2022 21:06
Avata wrote: Aug 16, 2022 7:43 I think it is a intersting project to make a notepad project as a examples.
Welcome everybody to come improving the code.

In My last code showing how to design a menu inncluding hotkey and showing ico on menu items.
Mr.Avatar,

Please post your project with its resources.

Thank you in advanced.
Form1.rc

Code: Select all

1 24 "Manifest.xml"
1 ICON "VisualFBEditor.ico"
New PNG ".\Resources\New.png"
About PNG ".\Resources\About.png"
Cut PNG ".\Resources\Cut.png"
Exit PNG ".\Resources\Exit.png"
File PNG ".\Resources\File.png"
Open PNG ".\Resources\Open.png"
Paste PNG ".\Resources\Paste.png"
Save PNG ".\Resources\Save.png"
SaveAll PNG ".\Resources\SaveAll.png"

#define APP_TITLE_STR               "\0"
#define VER_FILEDESCRIPTION_STR     "\0"

#define VER_FILEVERSION             0,0,0,106
#define VER_FILEVERSION_STR         "0.0.0.106\0"

#define VER_LEGALCOPYRIGHT_STR      "\0"

#define VER_INTERNALNAME_STR        "\0"
#define VER_ORIGINALFILENAME_STR    "\0"
#define VER_PRODUCTNAME_STR         "\0"

#define VER_PRODUCTVERSION          0,0,0,0
#define VER_PRODUCTVERSION_STR      "0.0.0\0"
#define VER_COMPANYNAME_STR         "\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION
FILEOS          VOS__WINDOWS32
FILETYPE        VFT_APP
FILESUBTYPE     VFT2_UNKNOWN
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
        	VALUE "ApplicationTitle", APP_TITLE_STR
            VALUE "FileDescription",  VER_FILEDESCRIPTION_STR
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     VER_INTERNALNAME_STR
            VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
            VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
            VALUE "ProductName",      VER_PRODUCTNAME_STR
            VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
            VALUE "CompanyName",      VER_COMPANYNAME_STR
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        /* The following line should only be modified for localized versions.     */
        /* It consists of any number of WORD,WORD pairs, with each pair           */
        /* describing a language,codepage combination supported by the file.      */
        /*                                                                        */
        /* For example, a file might have values "0x409,1252" indicating that it  */
        /* supports English language (0x409) in the Windows ANSI codepage (1252). */
        VALUE "Translation", 0x409, 1252
    END
END
Copy the following file from "VisualFBEditor\Resources" to Folder "Resources\" as project resources
About.png
Cut.png
Exit.png
File.png
Open.png
Paste.png
Save.png
SaveAll.png
Last edited by Avata on Aug 18, 2022 6:07, edited 1 time in total.
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Avata wrote: Aug 18, 2022 5:41
flaviofornazier wrote: Aug 17, 2022 21:06
Avata wrote: Aug 16, 2022 7:43 I think it is a intersting project to make a notepad project as a examples.
Welcome everybody to come improving the code.

In My last code showing how to design a menu inncluding hotkey and showing ico on menu items.
Mr.Avatar,

Please post your project with its resources.

Thank you in advanced.
Copy the following file from "VisualFBEditor\Resources" to Folder "Resources\" as project resources
About.png
Cut.png
Exit.png
File.png
Open.png
Paste.png
Save.png
SaveAll.png
Mr.Avatar,

Thank you for your instructions.

Cheers.
Avata
Posts: 102
Joined: Jan 17, 2021 7:27

Re: VisualFBEditor - IDE for FreeBasic

Post by Avata »

also need the following file.
Form1.rc

Code: Select all

1 24 "Manifest.xml"
1 ICON "VisualFBEditor.ico"
New PNG ".\Resources\New.png"
About PNG ".\Resources\About.png"
Cut PNG ".\Resources\Cut.png"
Exit PNG ".\Resources\Exit.png"
File PNG ".\Resources\File.png"
Open PNG ".\Resources\Open.png"
Paste PNG ".\Resources\Paste.png"
Save PNG ".\Resources\Save.png"
SaveAll PNG ".\Resources\SaveAll.png"

#define APP_TITLE_STR               "\0"
#define VER_FILEDESCRIPTION_STR     "\0"

#define VER_FILEVERSION             0,0,0,106
#define VER_FILEVERSION_STR         "0.0.0.106\0"

#define VER_LEGALCOPYRIGHT_STR      "\0"

#define VER_INTERNALNAME_STR        "\0"
#define VER_ORIGINALFILENAME_STR    "\0"
#define VER_PRODUCTNAME_STR         "\0"

#define VER_PRODUCTVERSION          0,0,0,0
#define VER_PRODUCTVERSION_STR      "0.0.0\0"
#define VER_COMPANYNAME_STR         "\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION
FILEOS          VOS__WINDOWS32
FILETYPE        VFT_APP
FILESUBTYPE     VFT2_UNKNOWN
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
        	VALUE "ApplicationTitle", APP_TITLE_STR
            VALUE "FileDescription",  VER_FILEDESCRIPTION_STR
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     VER_INTERNALNAME_STR
            VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
            VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
            VALUE "ProductName",      VER_PRODUCTNAME_STR
            VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
            VALUE "CompanyName",      VER_COMPANYNAME_STR
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        /* The following line should only be modified for localized versions.     */
        /* It consists of any number of WORD,WORD pairs, with each pair           */
        /* describing a language,codepage combination supported by the file.      */
        /*                                                                        */
        /* For example, a file might have values "0x409,1252" indicating that it  */
        /* supports English language (0x409) in the Windows ANSI codepage (1252). */
        VALUE "Translation", 0x409, 1252
    END
END
flaviofornazier
Posts: 59
Joined: Oct 10, 2015 7:19
Location: Brazil

Re: VisualFBEditor - IDE for FreeBasic

Post by flaviofornazier »

Avata wrote: Aug 18, 2022 8:59 also need the following file.
Form1.rc

Code: Select all

1 24 "Manifest.xml"
1 ICON "VisualFBEditor.ico"
New PNG ".\Resources\New.png"
About PNG ".\Resources\About.png"
Cut PNG ".\Resources\Cut.png"
Exit PNG ".\Resources\Exit.png"
File PNG ".\Resources\File.png"
Open PNG ".\Resources\Open.png"
Paste PNG ".\Resources\Paste.png"
Save PNG ".\Resources\Save.png"
SaveAll PNG ".\Resources\SaveAll.png"

#define APP_TITLE_STR               "\0"
#define VER_FILEDESCRIPTION_STR     "\0"

#define VER_FILEVERSION             0,0,0,106
#define VER_FILEVERSION_STR         "0.0.0.106\0"

#define VER_LEGALCOPYRIGHT_STR      "\0"

#define VER_INTERNALNAME_STR        "\0"
#define VER_ORIGINALFILENAME_STR    "\0"
#define VER_PRODUCTNAME_STR         "\0"

#define VER_PRODUCTVERSION          0,0,0,0
#define VER_PRODUCTVERSION_STR      "0.0.0\0"
#define VER_COMPANYNAME_STR         "\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION
FILEOS          VOS__WINDOWS32
FILETYPE        VFT_APP
FILESUBTYPE     VFT2_UNKNOWN
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
        	VALUE "ApplicationTitle", APP_TITLE_STR
            VALUE "FileDescription",  VER_FILEDESCRIPTION_STR
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     VER_INTERNALNAME_STR
            VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
            VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
            VALUE "ProductName",      VER_PRODUCTNAME_STR
            VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
            VALUE "CompanyName",      VER_COMPANYNAME_STR
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        /* The following line should only be modified for localized versions.     */
        /* It consists of any number of WORD,WORD pairs, with each pair           */
        /* describing a language,codepage combination supported by the file.      */
        /*                                                                        */
        /* For example, a file might have values "0x409,1252" indicating that it  */
        /* supports English language (0x409) in the Windows ANSI codepage (1252). */
        VALUE "Translation", 0x409, 1252
    END
END
Hi Mr.Bekchanov, Mr.Avata...

I will intend to combine Mr.Avata's MDIForm example with a real database app.
I will need an easy example to manipulate blob fields using SQLite3Box and
UpdateByteUtf method.

Thank you in advanced.
Post Reply