gui_chung an easy way to make gui windows
gui_chung an easy way to make gui windows
gui_chung is a compact freeware to program easy gui windows in freebasic .
click there => http://chungswebsite.blogspot.com/search/label/gui
example of windows programmed with gui_chung :
click there => http://chungswebsite.blogspot.com/search/label/gui
example of windows programmed with gui_chung :
Last edited by chung on Jan 22, 2012 11:19, edited 3 times in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
(02/10/2010) colors and fonts control added
example of windows programmed :
[/img]
example of sample program :
example of windows programmed :
[/img]
example of sample program :
Last edited by chung on Oct 03, 2010 15:39, edited 2 times in total.
When I compile with “fbc.exe -exx -w pedantic”, I get the following warnings...
gui_chung.bi(138) warning 16(0): No explicit BYREF or BYVAL, at parameter 8 (userflags) of button()
gui_chung.bi(426) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(431) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(432) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(433) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKCOLOR()
gui_chung.bi(434) warning 5(0): Implicit conversion
gui_chung.bi(435) warning 5(0): Implicit conversion
gui_chung.bi(438) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(440) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(441) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKMODE()
gui_chung.bi(442) warning 5(0): Implicit conversion
gui_chung.bi(443) warning 5(0): Implicit conversion
gui_chung.bi(449) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(450) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(451) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKCOLOR()
gui_chung.bi(452) warning 5(0): Implicit conversion
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guibackgroundcolor()
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guibackgroundcolor()
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guibackgroundcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guiedittextbackcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guiedittextbackcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guiedittextbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guilistboxbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guilistboxbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guilistboxbackcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guiedittextinkcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guiedittextinkcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guiedittextinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guilistboxinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guilistboxinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guilistboxinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guistatictextinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guistatictextinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guistatictextinkcolor()
gui_chung.bi(601) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 1 (windowname) of openwindow()
gui_chung.bi(601) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 2 (windowtext) of openwindow()
gui_chung.bi(641) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 1 (opt) of guiclose()
gui_chung.bi(784) warning 16(0): No explicit BYREF or BYVAL, at parameter 7 (userflags) of statictext()
gui_chung.bi(792) warning 16(0): No explicit BYREF or BYVAL, at parameter 8 (userflags) of edittext()
gui_chung.bi(891) warning 16(0): No explicit BYREF or BYVAL, at parameter 7 (userflags) of listbox()
gui_chung.bi(997) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (usersub) of addusersub()
gui_chung.bi(1012) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (usersub) of changeusersub()
gui_chung.bi(138) warning 16(0): No explicit BYREF or BYVAL, at parameter 8 (userflags) of button()
gui_chung.bi(426) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(431) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(432) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(433) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKCOLOR()
gui_chung.bi(434) warning 5(0): Implicit conversion
gui_chung.bi(435) warning 5(0): Implicit conversion
gui_chung.bi(438) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(440) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(441) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKMODE()
gui_chung.bi(442) warning 5(0): Implicit conversion
gui_chung.bi(443) warning 5(0): Implicit conversion
gui_chung.bi(449) warning 1(1): Passing scalar as pointer, at parameter 1 of SELECTOBJECT()
gui_chung.bi(450) warning 1(1): Passing scalar as pointer, at parameter 1 of SETTEXTCOLOR()
gui_chung.bi(451) warning 1(1): Passing scalar as pointer, at parameter 1 of SETBKCOLOR()
gui_chung.bi(452) warning 5(0): Implicit conversion
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guibackgroundcolor()
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guibackgroundcolor()
gui_chung.bi(512) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guibackgroundcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guiedittextbackcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guiedittextbackcolor()
gui_chung.bi(515) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guiedittextbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guilistboxbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guilistboxbackcolor()
gui_chung.bi(521) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guilistboxbackcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guiedittextinkcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guiedittextinkcolor()
gui_chung.bi(529) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guiedittextinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guilistboxinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guilistboxinkcolor()
gui_chung.bi(533) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guilistboxinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 1 (r) of guistatictextinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (g) of guistatictextinkcolor()
gui_chung.bi(537) warning 16(0): No explicit BYREF or BYVAL, at parameter 3 (b) of guistatictextinkcolor()
gui_chung.bi(601) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 1 (windowname) of openwindow()
gui_chung.bi(601) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 2 (windowtext) of openwindow()
gui_chung.bi(641) warning 34(0): 'BYVAL AS STRING' actually behaves like 'BYREF AS ZSTRING' (this is hoped to change in future releases), at parameter 1 (opt) of guiclose()
gui_chung.bi(784) warning 16(0): No explicit BYREF or BYVAL, at parameter 7 (userflags) of statictext()
gui_chung.bi(792) warning 16(0): No explicit BYREF or BYVAL, at parameter 8 (userflags) of edittext()
gui_chung.bi(891) warning 16(0): No explicit BYREF or BYVAL, at parameter 7 (userflags) of listbox()
gui_chung.bi(997) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (usersub) of addusersub()
gui_chung.bi(1012) warning 16(0): No explicit BYREF or BYVAL, at parameter 2 (usersub) of changeusersub()
i dont know what pedantic is but i compile with
D:\FreeBASIC\fbc -s gui "gui_chung_test.bas" "icon.rc"
("windows GUI" option of fbEdit)
D:\FreeBASIC\fbc -s gui "gui_chung_test.bas" "icon.rc"
("windows GUI" option of fbEdit)
Last edited by chung on Oct 03, 2010 13:06, edited 2 times in total.
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
@chung
I would be concerned over the "passing scalar as pointer" and "implicit conversion".
byval/byref is an optimization. Everything is passed by reference in FB unless otherwise specified. Forving BYVAL will break compatibility with earlier BASICS, but it should give yyou a bit of a boost in speed.
I would be concerned over the "passing scalar as pointer" and "implicit conversion".
byval/byref is an optimization. Everything is passed by reference in FB unless otherwise specified. Forving BYVAL will break compatibility with earlier BASICS, but it should give yyou a bit of a boost in speed.
rolliebollocks wrote:... Everything is passed by reference in FB unless otherwise specified...
FB docu wrote:Dialect Differences
In the -lang fb dialect, ByVal is the default parameter passing convention for all built-in types except String; String and user-defined Types are passed ByRef by default.
In -lang qb and -lang fblite dialects, ByRef is the default parameter passing convention.
-
- Posts: 489
- Joined: Apr 18, 2008 4:09
- Location: Los Angeles, CA
- Contact:
Here's an example of how to draw on the window, using LineTo.
The Gui_Chung.BI file takes away a lot of the gory details, but this approach still requires more knowledge of Win API than I care to master. I'll stick with a retro-engineered GUI constructed from native FB commands via FB_GUI.
BasicScience
The Gui_Chung.BI file takes away a lot of the gory details, but this approach still requires more knowledge of Win API than I care to master. I'll stick with a retro-engineered GUI constructed from native FB commands via FB_GUI.
BasicScience
Code: Select all
'sample test program for gui_chung , an easy way to make windows
#Include Once "windows.bi"
#Include Once "gui_chung.bi"
Declare sub MyDraw
SUB End_GUI
guiclose
guiquit
end sub
' Program start
guibackgroundcolor(240,240,240)
button("Win_Main.button1","Exit",@End_GUI,10,10,60,20)
button("Win_Main.button2","Draw",@MyDraw,10,40,60,20)
openwindow("Win_Main","Test Window",100,400,600,400,WS_OVERLAPPEDwindow)
dim shared as hWnd hWin_Draw
hWin_Draw = guihwindow(1) 'default set to first window = Win_Main
DO while NOT guitestKey(vk_escape)
guiwait 'wait for msg
loop
End_GUI
END
SUB MyDraw
Dim As Integer xleft, ytop, wd, ht
xleft = 50
ytop = 80
wd = 400
ht = 200
Dim hDC As HDC
hDC = GetDC( hWin_Draw )
Rectangle hDC, xleft, ytop, xleft+wd, ytop+ht
Dim As HPEN greenPen=CreatePen(PS_solid, 3, &h0000ff00)
Dim As HPEN BluePen=CreatePen(PS_solid, 3, &h00ff0000)
SelectObject (hDC, greenPen)
MoveToEx hDC, xleft, ytop+ht/2, Null
For i As Integer = 0 To wd-1
If i = wd/2 Then SelectObject (hDC, BluePen)
LineTo hDC, xleft+i, ytop + (ht/2)*(1+ Sin(6.28*i/20)*Exp(-i/70))
Next i
ReleaseDC hWin_Draw, hDC
DeleteObject(GreenPen)
DeleteObject(BluePen)
end sub
(07/10/2010) graphicbox : gfx freebasic support added
graphicbox created with graphtype="gfx" (default) generate a buffer compatible with native freebasic gfx commands + support multi graphicbox windows.
(07/10/2010) trapleftmouse, traprightmouse added.works with statictext,staticbmp,graphicbox (trap mouse clicks)
(08/10/2010) guistartopenGL, guicloseopenGL, guirefreshopenGL added
sample program :
sample openGL program :
graphicbox created with graphtype="gfx" (default) generate a buffer compatible with native freebasic gfx commands + support multi graphicbox windows.
(07/10/2010) trapleftmouse, traprightmouse added.works with statictext,staticbmp,graphicbox (trap mouse clicks)
(08/10/2010) guistartopenGL, guicloseopenGL, guirefreshopenGL added
sample program :
Code: Select all
#Include Once "windows.bi"
#Include Once "gui_chung.bi"
Declare Sub subdraw
Declare Sub subquit
Dim Shared As Integer quit=0
Dim Shared As Any Ptr buffer,buffer2
graphicbox("win4.graph",10,10,200,200)
graphicbox("win4.graph2",220,10,200,200)
button("win4.button","Draw",@subdraw,10,220,70,27)
openwindow("win4","my window4",600,330,450,280)
trapclose("win4",@subquit)
buffer=getguigfxbuffer("win4.graph")
buffer2=getguigfxbuffer("win4.graph2")
While quit=0 And guitestkey(vk_escape)=0
guirefreshwindow("win4")
guiwait
Wend
guiclose
guiquit
End
Sub subdraw
Paint buffer,(1,1),0,999
Line buffer,(100+Rnd*50,50+Rnd*50)-(100+Rnd*50,50+Rnd*50),RGB(Rnd*255,Rnd*255,Rnd*255),bf
Color RGB(0,255,0)
Circle buffer,(150,100),100
Circle buffer,(100,100),100
Circle buffer,(200,100),100
Line buffer2,(50+Rnd*50,50+Rnd*50)-(100+Rnd*50,50+Rnd*50),RGB(Rnd*255,Rnd*255,Rnd*255),bf
Color RGB(250,0,0)
Circle buffer2,(100,100),100
End Sub
Sub subquit
quit=1
End Sub
Code: Select all
'sample test openGL program for gui_chung , an easy way to make windows
#Include Once "windows.bi"
#Include Once "gui_chung.bi"
#include Once "GL/gl.bi"
#include Once "GL/glu.bi"
Sub notice(ByRef msg As string,ByRef title As String ="notice")
messagebox(0,msg,title,0)
End Sub
Sub confirm(ByRef msg As string,ByRef title As string,ByRef resp As String)
Dim i As Integer
i=messagebox(0,msg,title,1)
If i=1 Then resp="yes" Else resp="no"
End Sub
Dim Shared As Integer itime,quit=0,restart=0
Dim Shared As Single rottri,rotquad
Sub mysubquit
quit=1
End Sub
Sub mysubrestart
quit=1
restart=1
End Sub
Declare Sub initgl
Declare Sub drawgl
'
' Program start
guibackgroundcolor(0,240,240)
debut:
quit=0
button("win.button1","click here",NULL,10,10,100,40)
button("win.button2","restart",@mysubrestart,120,10,100,40)
statictext("win.text1","",240,10,80,30)
graphicbox("win.graph",10,60,640,480,"opengl")
openwindow("win","my window",100,100,700,600)
trapclose("win",@mysubquit)
Dim As hwnd wintext1h=getguih("win.text1")
guistartOpenGL("win.graph")
initgl
While quit=0 And Not guitestKey(vk_escape)
itime+=1
guiscan 'scan for input and continue
'guiwait 'wait for msg
drawgl
guirefreshopenGL
Sleep 20
printgui("win.button1",Str(itime))
printguih(wintext1h,Str(guitestKey(vk_k))+" ")'faster with guih than with name
Wend
guicloseOpenGL
guiclose'("msg")
If restart=1 Then
restart=0:itime=0
'notice("restart")
guibackgroundcolor(Rnd*255,Rnd*255,Rnd*255)
guireset:GoTo debut
EndIf
guiquit
End
Sub initgl
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, 640.0/480.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity
glShadeModel GL_SMOOTH
glClearColor 0.0, 0.0, 0.0, 1.0
glClearDepth 1.0
glEnable GL_DEPTH_TEST
glDepthFunc GL_LEQUAL
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
End Sub
Sub drawgl
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glLoadIdentity
glTranslatef -1.5, 0.0, -6.0
glRotatef rottri, 0, 1, 0
glBegin GL_TRIANGLES
glColor3f 1.0, 0.0, 0.0
glVertex3f 0.0, 1.0, 0.0
glColor3f 0.0, 1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glColor3f 0.0, 0.0, 1.0
glVertex3f 1.0, -1.0, 0.0
glEnd
glLoadIdentity
glTranslatef 1.5, 0.0, -6.0
glColor3f 0.5, 0.5, 1.0
glRotatef rotquad, 1, 0, 0
glBegin GL_QUADS
glVertex3f -1.0, 1.0, 0.0
glVertex3f 1.0, 1.0, 0.0
glVertex3f 1.0, -1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glEnd
rottri += 0.5
rotquad += 0.5
End Sub
Looks easy
This looks easy by far. Kind of like BCX.
-
- Posts: 489
- Joined: Apr 18, 2008 4:09
- Location: Los Angeles, CA
- Contact:
@ Chung,
Nice implementation of the GFX buffer.
In your example, shouldn't you move the
guirefreshwindow("win4")
statement out of the main WEND loop and instead place it at the end of the Draw subroutine? The GUI refresh doesn't need to be done with each cycle through the WEND... but only if the image buffers have changed in Draw.
Nice implementation of the GFX buffer.
In your example, shouldn't you move the
guirefreshwindow("win4")
statement out of the main WEND loop and instead place it at the end of the Draw subroutine? The GUI refresh doesn't need to be done with each cycle through the WEND... but only if the image buffers have changed in Draw.