Quote:Well some people have asked that for what Gui is. Here's a litle example: www.hot.ee/wizgui/wiz2-se_calc.zip
It's a Calculator program what uses my WizGui 2 SE windowing engine. Source code is also included.
So I would really glad if you would look at it and tell what you think. Sorry in code there's no comment line's but I think that for qb expert's it's code is not difficult at all.
Some improvements from WizGui 2 (Not SE)
*Possibility to use all 8 bit colors (GetColor(0 to 255) -is't gives easy way to program a program what would look same in all bit dephs(8, 15, 16, 24, 32)
*Faster windowsing engine -In my Test it was about 4 times faster.
*Takes less Conv. Memory
*Is smaller
So Please people tell what you think or if you have suggestion or etc.
www.hot.ee/wizgui
Hi Von,
I read your code and was disappointed. I was hoping you would improve but you are using the same old logic again and again in a more complex manner than before. Unfortunately your prog is running much slower on my comp than the previous.
Here is the low-down of somethings you are doing inefficiently. The trick to making your prog faster in qb is not to make use of interrupts or increasing the refresh rate but to make your prog more efficient. This point was presented by Seph(I think).
Lets look at your code a bit ok?
Spawing windows is cool.(Like an OOP language)
Code:
Win1 = NewWindow(Center, Center, 243, 197, "Calculator")
Spawing buttons/objs is cool.(again, like an OOP language)
Code:
NumPad = NewButton(42, 25, 0)
The only objection I have with this kinda spawing is that you are considering all the buttons in your system at once. But you need to consider only those buttons which are present on your active form. So I feel u should add a frmHandle variable to your button TYPE so your system knows that the button is being added to which form. By implementing this you will be able to search much faster for a 'CLICK' event. Because you need to check only those objects which are on the active form.
Another inefficient thing about your prog is that you keep passing values again and again.
Code:
CalcBut(1) = GetButtonValue(NumPad, NumPadX, NumPadY, Win1, "1", 0, CalcBut(1))
CalcBut(2) = GetButtonValue(NumPad, NumPadX + ButXSize, NumPadY, Win1, "2", 0, CalcBut(2))
CalcBut(3) = GetButtonValue(NumPad, NumPadX + 2 * ButXSize, NumPadY, Win1, "3", 0, CalcBut(3))
CalcBut(11) = GetButtonValue(NumPad, NumPadX + 3 * ButXSize, NumPadY, Win1, "+", 0,
Why in the world do you need to pass the X,Y,W,H values all over again?
An object defination in my GUI would look:
ObjHandle1 = Def_Obj(WinHandle, x, y,....)
ObjHandle2 = Def_Obj(WinHandle, x, y,....)
ObjHandle3 = Def_Obj(WinHandle, x, y,....)
ObjHandle4 = Def_Obj(WinHandle, x, y,....)
ObjHandle5 = Def_Obj(WinHandle, x, y,....)
Def_Obj will return the index where the object info has been stored. You wont need this lest you want to do something immediately to the object.
When programming a GUI the logic is simple. All you need to follow are these steps:
1. Make a form
2. Register an object on the form
3. Call the form.draw to display the form on the screen
4. Check whether the mouse pointer is on any of the objects of the active form
4a. if yes, then do the hover/mouse down event depending on the state of the mouse button(exit from the for...next loop)
4b. if no, check other objects
(Steps 4, 4a, 4b will be put in a loop)
Now when my GUI code is executed it will be(This is just pseudo code):
Code:
Win.Draw WinHandle
'Win.Draw would look something like this:
SUB Win.Draw(Handle%)
For i% = 1 to Win(Handle%).Total_No_Of_Objs
ObjType = Object(Handle%, i%).Typ
If ObjType = Button then
PutObj.Button
ElseIf ObjType = TextBox then
...
End If
Next
END SUB
When I want to check for a mouse down/up/over event:
Code:
DO
Active_Win_Hdl = GetActiveWin
return% = Obj.Check%(Active_Win_Hdl)
LOOP UNTIL ...
'Obj.Check would look something like this:
FUNCTION Obj.Check%(Handle%)
For i% = 1 to Win(Handle%).Total_No_Of_Objs
If IsInsideBox(Object(Handle%, i%).X, Object(Handle%, i%).Y, Object(Handle%, i%).W, Object(Handle%, i%).H = True then
Obj.down Object(Handle%, i%).Hdl
Exit for*
End If
Next
Obj.Check = i%
END FUNCTION
* = this is very important! because you exit the for...next loop as soon as you find that the mouse pointer is on some object. Since checking further is of no use! Its just donkey work! Thats why M$ products require so high computing power
I hope this lllllooooonnnnnggggg..... reply will be helpful. Ask away any doubts 8)
P.S: Object is a double dimensioned array of TYPE ObjectType.
To store info on a particular object:
Object(WinHandle, ObjHandle).Whatever_value = ...