click there => http://chungswebsite.blogspot.com/search/label/gui
example of windows programmed with gui_chung :
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.
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
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
Users browsing this forum: classd2008, RNBW and 12 guests