WindowMenu refresh on a canvas

BlitzMax Forums/MaxGUI Module/WindowMenu refresh on a canvas

Kistjes(Posted 2007) [#1]
Help!!! I have a very strange problem here with window menus.
I have 4 menus: file, edit, view & help.
If I have an empty window, there are no problems but if I make a canvas the size of the window, then something strange happens: the first menu I select appears but when I move the mouse cursor over another menu the first will not disappear (only the dropshadow disappears). With all the other menus there are no problems, just with the first one (no matter which menu is the first). I found out that the whole application is 'on hold' when the mouse is on a menu, so there is no possibility of refreshing the canvas, or something and the application does not receive any EventID's.

Is this a bug?


Kistjes(Posted 2007) [#2]
Here is an example illustrating the bug.
Any ideas how to solve this?




grable(Posted 2007) [#3]
This can be solved by using hooks.

Look at the paint function ;)



Kistjes(Posted 2007) [#4]
Thanks a lot!
I'll look at the code more closer later to see how it works.


Kistjes(Posted 2007) [#5]
The problem is not completely solved yet :(

Run the code below. It's part of a project I'm doing. I have an application window with a canvas and I have a (fake) printer driver window (also with a canvas). Via the file-menu you can call the printer driver window or by pressing Ctrl-P.
If you do not use any setScale, setRotation or setTransform code it seems to work. But I have to do a lot of imaging stuff within the draw method of the printer window. And within the application window I need to be able to offer 4 different views (in this example I use colors, but that will be 4 images).

Modify the code as explained in the code to see the strange effects.
Tell me... what am I doing wrong???



grable(Posted 2007) [#6]
It locks up on my puter, but adding the EVENT_GADGETPAINT to the hook makes it responsive.

About the SetTransform.. I assume your resetting it here?
SetTransform 1, 0, 0
' should be
SetTransform 0, 1,1
' or just
SetTransform
Scaling something to 0,0 just makes it disappear ;)

And when your doing SetTransform (or any of the other transform commands), its a good idea to reset it each loop so you know your starting point.

Heres the modified code:



Kistjes(Posted 2007) [#7]
Yes, you're right about setTransform. Stupid mistake!!

First of all, thanks again for your advice. I have to solve this stupid problem!
But about the modification you made. As soon as I open the printer driver it draws the image and mouse location in both windows. When I move the Printer driver window the Application windows refreshes.

I'll try to solve this myself, but I hope you can give me a clue. I still do not really understand how it works with the hook-thing (BlitzMax help is very poor on this item).


grable(Posted 2007) [#8]
Oh, didnt notice that. But its only the first frame just before the window is opened it seems.

Hooks work by intercepting Events (and other stuff) before they reach their destination.
The hook can also stop the event from reaching the event queue by returning Null.

Make sure both Canvases are updated each timer tick, and that they are separated properly.
Passing the whole TEvent object to your Application class instead of just the ID might help, as it has a Source field containing the Gadget the event originated from and some other goodies.


Kistjes(Posted 2007) [#9]
I tried my best but I'm getting more and more confused about the behavior of the events.
As long as I do not move or close the printer driver window the content of both windows remains the same. Why?


grable(Posted 2007) [#10]
I modified the code to my suggestions above, so now the Update method takes a TEvent and filters its actiond depending on the Source field.

I also changed the Hook to reflect this, and removed the code from the main loop as its no longer needed.

Hope this helps =)



Kistjes(Posted 2007) [#11]
I checked the code and everythings works the way it should. You are a hero!
I have to go now. I'll try your modifications in my real project to night and let you know the results!
Thanks again!


Kistjes(Posted 2007) [#12]
Ok. Modified my project conform your suggestions and now everything works great!
It all started with a windows menu that did not refresh properly. I still wonder if needs to be that complicated to accomplish what I want, although the finel result shows some nice clean code.
Many thanks for all your effort! Now I can focus on the rest of the project.