GUI library for Windows \ Linux (window9)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

@VANYA
It wasn't meant as a criticism, just pointing out that it wasn't there. I appreciate the size of the library and its documentation, so I think every bit of help that you can be given to make it as complete as possible should be given. Keep up the good work!
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

I've modified a bit of code that was originally written for Lothar Schirm's excellent Simple WinAPI GUI library. This simply sets up two identical grids of StringGadgets (5 rows x 9 columns) and sets up headings in the top row and first column. The user then enters data in the top grid and this is copied into the equivalent StringGadget in the second grid. This is done by either clicking the "Click Me!" button or clicking in another StringGadget in the first grid. If anyone can find a way to limit the data transfer to solely clicking the button, I would appreciate it.

Code: Select all

'=============================================================================
'GridTransfer.bas
'Author: RNBW 
'1 August 2017
'Shows a grid of InputBoxes in 5 rows AND 9 columns
'Includes Row AND Column Headings
'Transfers values from one grid to another
'Original code contributions gratefully received from Lothar Schirm,
'MrSwiss AND fxm for program using WinGUI.bas library
'-----------------------------------------------------------------------------
'Based on code from GridTransfer.bas using Lothar Schirm's WinGui.bas Library
'=============================================================================
'
' INSTRUCTIONS:
' -------------------
' ENTER DATA INTO THE TOP GRID. WHEN YOU CLICK IN NEXT CELL
' OR CLICK <Click me!> Button, DATA WILL BE TRANSFERRED 
' FROM TOP GRID TO BOTTOM GRID
'=============================================================================

#INCLUDE "window9.bi"

DIM AS LONG NumOfRows=5, NumOfCols=9, id1, id2
DIM AS STRING sRows, sCols, stRow, stCol, stID1, stID2

DIM SHARED AS HWND Window_Main, Button_Click
DIM SHARED AS MSG msg
DIM AS STRING text, text2
DIM AS HWND event
DIM AS LONG vPos, hPos, wide, rHt, row, col

'---------------------
' MAIN WINDOW
'---------------------
OpenWindow("Multi-Column Grid",100,100,950,400)
ButtonGadget(1,10,10,100,20, "Click me!")

'-------------------------------
'  SET UP THE FIRST GRID
'-------------------------------
vPos = 40: rHt = 20
FOR row = 1 TO NumOfRows
	FOR col = 1 TO 9
		SELECT CASE col
			CASE 1
				hPos = 10: wide = 65
			CASE 2
				hPos = 75: wide = 380
			CASE 3 TO 8
				hPos = col*65+(455-65*3) : wide = 65
			CASE 9
				hPos = (10+65+380)+(col-3)*65 : wide = 75
		END SELECT
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		StringGadget(id1, hPos, vPos+rHt*(row-1), wide+1, rHt+1, "", WS_BORDER)
	NEXT
NEXT

'----------------------------------
'  SET UP THE SECOND GRID
'----------------------------------
rHt = 20
vPos = 40 + rHt * (NumOfRows + 3)
FOR row = 1 TO NumOfRows
	FOR col = 1 TO 9
		SELECT CASE col
			CASE 1
				hPos = 10: wide = 65
			CASE 2
				hPos = 75: wide = 380
			CASE 3 TO 8
				hPos = col*65+(455-65*3) : wide = 65
			CASE 9
				hPos = (10+65+380)+(col-3)*65 : wide = 75
		END SELECT
		stRow = STR(row): stCol = STR(col)
		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		StringGadget(id2, hPos, vPos+rHt*(row-1), wide+1, rHt+1,"", WS_BORDER)
	NEXT
NEXT

'-----------------------------------
' SET UP HEADINGS IN ROW 1
' IN BOTH GRIDS
'-----------------------------------
row = 1
FOR row = 1 TO 1
	FOR col = 2 TO NumOfCols
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		SetGadgetText(id1,"Col"+STR(col-1))
		
		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		SetGadgetText(id2,"Col"+STR(col-1))
	NEXT
NEXT

'----------------------------------
' SET UP HEADINGS IN COL 1
' IN BOTH GRIDS
'----------------------------------

col = 1
FOR row = 2 TO NumOfRows
	FOR col = 1 TO 1
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		SetGadgetText(id1,"Row"+STR(row-1))
		
		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		SetGadgetText(id2,"Row"+STR(row-1))
	NEXT
NEXT

'-----------------------------------------
'TRANSFER DATA ENTERED IN THE FIRST GRID
'INTO THE SECOND GRID.
'-----------------------------------------
DO
	event=  WaitEvent()
	IF event=WM_LBUTTONDOWN THEN
		'-----------------------------------------
		' GET VALUES FROM FIRST GRID
		' AND TRANSFER TO SECOND GRID
		'-----------------------------------------
		FOR row AS INTEGER = 2 TO NumOfRows
			FOR col AS INTEGER = 2 TO 9

				stRow = STR(row): stCol = STR(col)
				stID1 = "1" + stRow+stCol
				id1 = VAL(stID1)
				stID2 = "2" + stRow+stCol
				id2 = VAL(stID2)
				SetGadgetText(id2,GetGadgetText(id1))

			NEXT col
		NEXT row
	END IF
	IF event=EventClose THEN END
LOOP

END
I hope someone finds the code useful.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: FBGUI library for windows 2

Post by BasicCoder2 »

RNBW wrote:I've modified a bit of code that was originally written for Lothar Schirm's excellent Simple WinAPI GUI library. ...
I hope someone finds the code useful.
For some reason I get a compiler error,
File not found, "window9.bi" in #INCLUDE "window9.bi"
Although I extracted it in the same folder as your example.
.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

If anyone can find a way to limit the data transfer to solely clicking the button, I would appreciate it.

Code: Select all

'=============================================================================
'GridTransfer.bas
'Author: RNBW
'1 August 2017
'Shows a grid of InputBoxes in 5 rows AND 9 columns
'Includes Row AND Column Headings
'Transfers values from one grid to another
'Original code contributions gratefully received from Lothar Schirm,
'MrSwiss AND fxm for program using WinGUI.bas library
'-----------------------------------------------------------------------------
'Based on code from GridTransfer.bas using Lothar Schirm's WinGui.bas Library
'=============================================================================
'
' INSTRUCTIONS:
' -------------------
' ENTER DATA INTO THE TOP GRID. WHEN YOU CLICK IN NEXT CELL
' OR CLICK <Click me!> Button, DATA WILL BE TRANSFERRED
' FROM TOP GRID TO BOTTOM GRID
'=============================================================================

#INCLUDE "window9.bi"

DIM AS LONG NumOfRows=5, NumOfCols=9, id1, id2
DIM AS STRING sRows, sCols, stRow, stCol, stID1, stID2

DIM SHARED AS HWND Window_Main, Button_Click
DIM SHARED AS MSG msg
DIM AS STRING text, text2
DIM AS HWND event
DIM AS LONG vPos, hPos, wide, rHt, row, col , iActiveGadget

'---------------------
' MAIN WINDOW
'---------------------
OpenWindow("Multi-Column Grid",100,100,950,400)
ButtonGadget(1,10,10,100,20, "Click me!")

'-------------------------------
'  SET UP THE FIRST GRID
'-------------------------------
vPos = 40: rHt = 20
FOR row = 1 TO NumOfRows
	FOR col = 1 TO 9
		SELECT CASE col
			CASE 1
				hPos = 10: wide = 65
			CASE 2
				hPos = 75: wide = 380
			CASE 3 TO 8
				hPos = col*65+(455-65*3) : wide = 65
			CASE 9
				hPos = (10+65+380)+(col-3)*65 : wide = 75
		END SELECT
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		StringGadget(id1, hPos, vPos+rHt*(row-1), wide+1, rHt+1, "", WS_BORDER)
	NEXT
NEXT

'----------------------------------
'  SET UP THE SECOND GRID
'----------------------------------
rHt = 20
vPos = 40 + rHt * (NumOfRows + 3)
FOR row = 1 TO NumOfRows
	FOR col = 1 TO 9
		SELECT CASE col
			CASE 1
				hPos = 10: wide = 65
			CASE 2
				hPos = 75: wide = 380
			CASE 3 TO 8
				hPos = col*65+(455-65*3) : wide = 65
			CASE 9
				hPos = (10+65+380)+(col-3)*65 : wide = 75
		END SELECT
		stRow = STR(row): stCol = STR(col)
		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		StringGadget(id2, hPos, vPos+rHt*(row-1), wide+1, rHt+1,"", WS_BORDER)
	NEXT
NEXT

'-----------------------------------
' SET UP HEADINGS IN ROW 1
' IN BOTH GRIDS
'-----------------------------------
row = 1
FOR row = 1 TO 1
	FOR col = 2 TO NumOfCols
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		SetGadgetText(id1,"Col"+STR(col-1))

		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		SetGadgetText(id2,"Col"+STR(col-1))
	NEXT
NEXT

'----------------------------------
' SET UP HEADINGS IN COL 1
' IN BOTH GRIDS
'----------------------------------

col = 1
FOR row = 2 TO NumOfRows
	FOR col = 1 TO 1
		stRow = STR(row): stCol = STR(col)
		stID1 = "1" + stRow+stCol
		id1 = VAL(stID1)
		SetGadgetText(id1,"Row"+STR(row-1))

		stID2 = "2" + stRow+stCol
		id2 = VAL(stID2)
		SetGadgetText(id2,"Row"+STR(row-1))
	NEXT
NEXT

'-----------------------------------------
'TRANSFER DATA ENTERED IN THE FIRST GRID
'INTO THE SECOND GRID.
'-----------------------------------------
DO
	event=  WaitEvent()

	select Case event

		Case eventgadget

				Select Case EventNumber

					Case 122 To 129,132 To 139, 142 To 149, 152 To 159

						iActiveGadget = EventNumber
						
					Case 1
						
						If iActiveGadget > 0 Then
							
							SetGadgetText(iActiveGadget+100,GetGadgetText(iActiveGadget))
							
						EndIf						

				End Select

		Case 	EventClose

			End

	End Select

Loop
BasicCoder2 wrote:For some reason I get a compiler error,
File not found, "window9.bi" in #INCLUDE "window9.bi"
Although I extracted it in the same folder as your example.
If the file window9.bi lies in the same folder and record #INCLUDE "window9.bi" does not contain errors, then I do not know where this error will appear from...
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

@VANYA
Thank you. That solves the immediate problem. My next problem is to deal with a varying number of rows and columns and how to transfer data from those. I am working on it.

@BasicCoder2
I always put .bi files in the <inc> folder and find this usually works for me (or at least, it has to date).
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: FBGUI library for windows 2

Post by BasicCoder2 »

RNBW wrote:I always put .bi files in the <inc> folder and find this usually works for me (or at least, it has to date).
Nope that didn't work. The lib folder has a win32 folder full of .dll files.
The contents of the ExamplesWindow9 folder that came with the download work only when I move them out of their folder into the folder to which I extracted the download itself which contains the window9.bi file.
Your example also works in that folder.
.
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

@BasicCoder2
I put the window9.bi file in the <inc> folder not the <lib> folder. As you say this is full of dll files. The reason I put it on the <inc> folder is that, for some projects, I open a specific folder and it would mean putting all the associated .bi files in each of the folders. Much better to put all .bi files in the <inc> folder.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: FBGUI library for windows 2

Post by BasicCoder2 »

RNBW wrote:@BasicCoder2
I put the window9.bi file in the <inc> folder not the <lib> folder. As you say this is full of dll files. The reason I put it on the <inc> folder is that, for some projects, I open a specific folder and it would mean putting all the associated .bi files in each of the folders. Much better to put all .bi files in the <inc> folder.
Oops :)
After placing it into FreeBasic's include folder the compiler apparently found it but then threw up new errors.
I give up.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

BasicCoder2!

1) Download LIBFB

2) Put files libwindow9.a, libz.a , libLinked_Lists.a in the folder: compilier\lib\win32

3) Put files Linked_Lists.bi , Window9.bi in the folder: compilier\inc

Everything should work with the compiler: FreeBASIC-1.05.0-win32

The source files when compiled with the library must be stored in the encoding ASCII. Unicode not supported!
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: FBGUI library for windows 2

Post by BasicCoder2 »

Ok. Thank you VANYA that worked.
Must try and remember to put those kinds of files into those folders.
It would be neat if you could run a script to do that automatically when you down load a library so it just works.
.
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

@VANYA
I had put the files where you suggested, but more by luck than judgement. As BasicCoder2 says, it might be useful if there was a little script that moved all the files in the appropriate locations. I spent a lot of time banging my head up against a wall until it became clear, for example, that LIBFB only ran with the FB 32bit compiler. I'm slowly but surely coming to terms with your library, working through your help file (with the help of Google Translate) and also looking at the PureBASIC help files and in particular the code archives in PureArea.net. The latter, I find very useful.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

It would be neat if you could run a script to do that automatically when you down load a library so it just works.
As BasicCoder2 says, it might be useful if there was a little script that moved all the files in the appropriate locations.
Friends!

On Windows, different people can have a compiler in any folder. And some people may have several compilers of different versions in the system. I can not imagine how to create a BAT file so that it automatically finds the right folder :) . In the java script I do not understand at all. Creating a program on Freebasic is easy for this case, but many people are afraid to run other people's EXE files. I'm just in the first post I'll give a link to the post where I described the installation.
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: FBGUI library for windows 2

Post by RNBW »

@VANYA
I think that is a satisfactory approach.
maachal
Posts: 33
Joined: Jul 21, 2017 21:11
Location: czech

Re: FBGUI library for windows 2

Post by maachal »

Привет VANYA!
Function GetSystemDir return:
32bit app on 32bit system: ..\System32
32bit app on 64bit system: ..\System32 (Wouldn't it be better if returned ..\SysWOW64?)
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: FBGUI library for windows 2

Post by BasicCoder2 »

Tried to run OpenGLGadget_3D.bas resulting in a get a glut32.dll not found compiler error.
Downloaded the glut32.dll and put it into lib/win32 folder it still couldn't find it.
I notice the inc folder is full of dll.a files not plain .dll files?
What is a dll.a file?
It did however compile when I copied the glut32.dll to the ExamplesWindow9 folder.
.
Post Reply