GUI question
BlitzPlus Forums/BlitzPlus Programming/GUI question
| ||
I have some code that's not working, the problem is that the CreateWindow line reads and error saying "invalid group handle" I have no idea what the problem is. Graphics 640,480 ;Images point=LoadImage("Point.bmp") ;Fonts Global Cooper1fnt=LoadFont("Cooper Black",48,False,False,False) Global Cooper2fnt=LoadFont("Cooper Black",36,False,False,False) ;Events Const X_HIT=$803 Const APP_SUSPENDED=$2001 Const APP_RESUMED=$2002 ;Variables, things that'll change while the programs running Global iDesktopWidth=ClientWidth(Desktop()) Global iDesktopHeight=ClientHeight(Desktop()) ;Constants Const MAINWINDOW_WIDTH=420 Const MAINWINDOW_HEIGHT=320 Const MAINWINDOW_SETUP=42 While Not KeyDown(1) SetFont Cooper1fnt Start() Wend Function Start() Main=CreateWindow("Stock Tracker 1.0",(iDesktopWidth-MAINWINDOW_WIDTH)/2,(iDesktopHeight-MAINWINDOW_HEIGHT)/2,MAINWINDOW_WIDTH,MAINWINDOW_HEIGHT,True,MAINWINDOW_SETUP) MainMenu=CreateMenu("Create",MainMenu,Main) End Function |
| ||
Main=CreateWindow("Stock Tracker 1.0",(iDesktopWidth-MAINWINDOW_WIDTH)/2,(iDesktopHeight-MAINWINDOW_HEIGHT)/2,MAINWINDOW_WIDTH,MAINWINDOW_HEIGHT, True ,MAINWINDOW_SETUP) True? That's supposed to be a parent of the window? That ain't gonna work. btw, this thread should move to B+ I'd say.. |
| ||
You need to attach your menus to the result of windowmenu(main) not the window itself. See the createmenu example for details. |
| ||
Instead of True use Null (or I think I remember you could use 0 in BlitzPlus) instead. |
| ||
Thanks, also I don't know what I should do... to well get better at this I don't have quite enough skilll to make a game, so what can I program to get better? |
| ||
Lots and lots of small dumb test programs, don't bother for 500+ lines to start with. Also, try to spot repeating functionality which you could take apart to make a reusable function. You spend some lines in order to make a centralized window, instead you should create a function called CreateCenterWindow which does this for you. You could reuse this function in other programs and you never need to bother about it again. Ohwell, use this one perhaps.. :P Function CreateCWindow(t$="untitled",w=640,h=480,flags=15,cw=0) dw=ClientWidth(Desktop()) dh=ClientHeight(Desktop()) If cw=0 Return CreateWindow(t$,dw/2-w/2,dh/2-h/2,w,h,Null,flags) Else win=CreateWindow(t$,dw/2-w/2,dh/2-h/2,w,h,Null,flags) _w=ClientWidth(win) _h=ClientHeight(win) SetGadgetShape win,dw/2-w/2-(w-_w)/2,dh/2-h/2-(h-_h)/2,w+(w-_w),h+(h-_h) Return win EndIf End Function Let's hope it works, I manually trimmed it down from Max to B+ in notepad, didn't check.. :D |
| ||
Oh yeah, about that well um er Sebs hint worked :/ sorry for all your unnesecary toil! |
| ||
You've gone through this and this ? |
| ||
iirc he uses B+ .. and those are Max tuts .. |
| ||
Yeah I don't have Max yet, after I'm finished with Blitz+ I'll make the jump to B3D, but that'll be in a few more years. I'll try to do those little tests though CS_TBL, ya know make my own functions and just learn the ropes of GUI... just experiment right? And work out the bugs yourself, unless your absolutely stuck. One last question? Do you absolutely need the While/Wend loops to make a decent runnable program? I don't know how to make one without using that. |
| ||
Am I right? |
| ||
. |
| ||
You're going to need 'some' sort of loop whether it's waitevent (if b+ has it), while/wend, repeat/until(forever) or by looping routines/functions. |
| ||
Thanks |
| ||
Isn't Desktop() the correct thing to use? |