Page 1 of 1
Posted: Fri Mar 14, 2003 5:55 am
by BackupUser
Restored from previous forum. Originally posted by LJ.
I have a screen drawn with an image, a BOX gray strip, then with buttons on the gray strip and with text drawn on the gray strip. When the application is minimized, or ALT-TAB key press to switch to another application, or Window moved, then buttons are drawn okay on the screen along with the image, but the gray strip drawn with the BOX command is gone and so is the text that was drawn on the gray strip. How do I restore the screen or better, prevent ALT-TAB from being used or from the user moving the window?
Posted: Fri Mar 14, 2003 7:55 am
by BackupUser
Restored from previous forum. Originally posted by freak.
The Gadgets are automatically redrawn by Windows, but you need to redraw your own drawings yourself.
Check, if WaitWindowEvent() returns #PB_EventRepaint, which indicates, that the Window needs to be redrawn, and then draw all stuff again.
If you want to avoid that, you need to draw everything in an Image, and then display it in an ImageGadget() like this:
Code: Select all
#Image = 1
#ImageGadget = 1
CreateImage(#Image, 100,100)
UseImage(#Image)
StartDrawing(ImageOutput())
;
; draw everything here...
;
StopDrawing()
ImageGadget(#ImageGadget, 10, 10, 100, 100, UseImage(#Image))
If you want to change anything of your drawings later, you can do it like that:
Code: Select all
UseImage(#Image)
StartDrawing(ImageOutput())
;
; do your changes here...
;
StopDrawing()
SetGadgetState(#ImageGadget, UseImage(#Image)) ; <- Updates the Image in the Gadget
This would be a better solution because then, Windows redraws everything, everytime, and you'll never have to worry about that.
Hope, that helps...
Timo
Posted: Fri Mar 14, 2003 5:03 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.
That is very helpful Tito, thank you. That is fascinating to assign all the drawings to an image. Now the problem is that the screen is redrawn like you said, but now the image appears over my buttons. So the gray box rectangle is under the buttons when first drawn. When I hit minimize or ALT-TAB and then come back to the screen, the gray box is over the buttons. If I move the mouse over the gray box and just click where the button should appear, suddenly the button appears. Is there a way to make the image not appear over my buttons when the screen is redrawn using your image method?
Posted: Fri Mar 14, 2003 8:27 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
This seems to work:
Code: Select all
Global ButtonGadget
Procedure PaintCallback(hWnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
If uMsg=#WM_PAINT
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 0, 0, WindowWidth(), WindowHeight())
StopDrawing()
RedrawWindow_(ButtonGadget, 0, 0, #RDW_INVALIDATE)
EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(0, 128, 96, 320, 256, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
If CreateGadgetList(WindowID())
CreateImage(0, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
SetWindowCallback(@PaintCallback())
Repeat
Until WaitWindowEvent()=#PB_EventCloseWindow
EndIf
EndIf
End
Bye,
El_Choni
Posted: Sat Mar 15, 2003 12:10 am
by BackupUser
Restored from previous forum. Originally posted by freak.
If you first create the ImageGadget, and then the other ones, it should work fine.
Timo
Posted: Sat Mar 15, 2003 1:35 am
by BackupUser
Restored from previous forum. Originally posted by LJ.
Thank you El_Choni this is very interesting. I have saved your code in my examples folder.
Tito, thank you, that did it, you da man! Thank you so much.
Posted: Sat Mar 15, 2003 1:44 am
by BackupUser
Restored from previous forum. Originally posted by freak.
My Name is Timo
