Window is not repainted.

Windows specific forum
tricky
New User
New User
Posts: 2
Joined: Wed Aug 10, 2005 4:51 am

Window is not repainted.

Post by tricky »

Use "Image.pb" as an example. If I have two windows, one is "Image" and another is any window which overlaps "Image". First, make "Image" on the top, then click 2nd window in the task bar so that it overlaps "Image", and then click 2nd window in the task bar again to minimize it.
Now you will find "Image" is not repainted, i.e. it doesn't receive #WM_PAINT message. So, what is the correct way to repaint window if I don't use a ImageGadget?

I just found it depends on what the 2nd windows is. Sometime it get repainted, sometimes not. In my case, if 2nd window is IE, then it is not repainted.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

You must use a callback, but better use an image gadget.
tricky
New User
New User
Posts: 2
Joined: Wed Aug 10, 2005 4:51 am

Post by tricky »

The "Image.pb" example provided by purebasic do have a callback. Besides, I have heard someone say ImageGadget isn't good for dynamic graphics.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

You are right.

On my box, if I click the task bar and open another (any) window maximised, and then minimise it again, there is no repaint.

But if I open a non-maximised window to overlap or fully cover (or move a window across) there is repaint.

If I click the example in the taskbar to get it back on top, it redraws. But not if it is already on top.


(Just re-inforcing your statement, I have no idea why this is so.)


BTW, using an image gadget is simpler and surer and AFAIK has no real detrimental effect.
@}--`--,-- A rose by any other name ..
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Any time you do 2d drawing directly to a window you have to add a tiny step to your main loop:

Code: Select all

Procedure DrawStuff()
  ;here do your non-gadget drawing
Endprocedure

Repeat
  EventID = WaitWindowEvent()
  Select EventID
     Case #WM_PAINT
         DrawStuff()
      Case #Anothermessage
         ;handle that one
  EndSelect
Until EventID = #PB_Event_CloseWindow
With this step added to your loop your drawing will get repainted every time the gadgets do.
BERESHEIT
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The problem is that it ISN'T!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I can't reproduce it. I ran Image.pb that comes with b11 and put all manner of windows, maximized and otherwise, covering it partially and fully and it won't give problems. @Dare2, have you upgraded from Windows 3.1 yet? :twisted:
BERESHEIT
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

netmaestro wrote:@Dare2, have you upgraded from Windows 3.1 yet? :twisted:
:D

I am testing the beta for 3.2 - been at it for years! Wore out more floppies than you have had birthdays!
@}--`--,-- A rose by any other name ..
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

netmaestro wrote:I can't reproduce it. I ran Image.pb that comes with b11 and put all manner of windows, maximized and otherwise, covering it partially and fully and it won't give problems. @Dare2, have you upgraded from Windows 3.1 yet? :twisted:
Run this code:

Code: Select all

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
        Circle(100, 100, 100, 100)
      StopDrawing()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Move the window so that part of the circle goes out of the screen and back. The circle should now be cut in half.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

You're quite right, if the test isn't in a callback it isn't catching that repaint. I didn't know that before. But I don't understand why people should be experiencing repaint problems with Image.pb from the examples folder as the code is in a callback and it is redrawing on my box.
BERESHEIT
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Yep, wierd. But there it is.

Simple test that fails for me:

Load image.pb into the IDE, which is opened and maximised.
Run it (with or without debug).
Click the taskbar to bring the IDE to the fore.
Click again to minimise.
Window is blank and stays that way.
Close


Simple test that works for me:

Load image.pb into the IDE, which is opened and maximised.
Run it (with or without debug).
Click the taskbar to bring the IDE to the fore.
Click the taskbar to bring the image.pb window to the fore.
Window is painted nicely
Close
@}--`--,-- A rose by any other name ..
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

.. however, add this code:

Code: Select all

    If EventID =#WM_PAINT
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(0), 20, 10)
        DrawImage(ImageID(1), 320, 80)
        DrawImage(ImageID(2), 320, 200)
      StopDrawing()
    EndIf
right after

Code: Select all

EventID = WaitWindowEvent()
And the problem goes away. So here it is callback isn't getting called.

Edit:
I am no windows guru, but if that isn't PB then it suggests that all apps that survive a maximise/minimise event are using the #WM_PAINT check in their main window processing loop and don't rely on callbacks for that one case.

Edit again:
I just realised what I said. Fortunately I have already dissed myself as a windows guru. :D
@}--`--,-- A rose by any other name ..
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I can reproduce your "simple test that fails" - off to the bug reports forum with you!
BERESHEIT
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

netmaestro wrote:I even got a cpu-usage compliment from psychopanta and that's not easy to get!
:shock:

True!

An impressive compliment and quite a feather in your cap. (I'm not kidding either)

tricky or trond or you can post a bug - I don't like posting there unless I have to (that is, if, after several decades, nobody else appears to have posted the bug or discussed it).

edit:
Begger! Where did the rest of your post go! :D
@}--`--,-- A rose by any other name ..
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I just checked it and that's not what I ended up doing. So it isn't quite accurate. I'm trying to decipher my own code now but apparently I subscribe to the traumatic system and it's tough sleddin' :oops:
BERESHEIT
Post Reply