Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WizGui 2 SE - 1st program!
#1
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
url]http://fbide.sourceforge.net/[/url]
Reply
#2
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 Tongue

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 = ...
Reply
#3
Huh where to begin...
First thanks for the repley.

Code:
Win1 = NewWindow(Center, Center, 243, 197, "Window"

Win1 here is Window ID. Function returns number of window.
My first relise of WizGui 2 -was something like you said. It used Object Arrays. In fact all data was stored IN the object arrays. Look at WizGui 2 demo 3 code for example.


Code:
CalcBut(1) = GetButtonValue(NumPad, NumPadX, NumPadY, Win1, "1", 0, CalcBut(1))

Well it passes data to window specified by Win1. My system is set up so: If Mouse Cursor is not on the currect window then sys. automatically exit sub. Same is if Mouse cursor hasn't been moved. And if MouseCursor is on some button then it will not check the rest buttons.

But yeah you are right about putting buttons into Object system and to accociate easch of this with currect window.

Strange that it was slower on your comp then previous.

Code:
StartTest! = TIMER
DO
   TestCount! = TestCount! + 1
   RunGui 'or Run.GUI
LOOP UNTIL Key$ > ""
EndTest! = TIMER

EndGUI 'Or End.GUI

PRINT TestCount! / (EndTest! - StartTest!)

I used that kind of routine to check speed. So cycles per second.
I got with two windows on the screen about 16 000 cycles per second. While with same seting on older Gui I got only 5000 cycles per second.

Ok I'll check your suggestion over again and maybe I'll take your advice!

Thanks -it's just a bit hard to think everything alone that's why I want someone to make a gui with me.
url]http://fbide.sourceforge.net/[/url]
Reply
#4
Another thing: Button = NewButton (XSize, YSize, Style[ 0 - system select's (active Interface) ¦ WindowsXP (force a button to look Xp style) ¦ Windows95])

It makes just a picture into the memory of button. Nothing more. Where you realy use it is when you call getButtonValue. This routine does all "work" what is with button.
url]http://fbide.sourceforge.net/[/url]
Reply
#5
Ok, I am ready to help you. I will make a GUI with you. We can discuss it. Just be online tonight.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)