Page 1 of 1

Posted: Sat Mar 22, 2003 9:03 pm
by BackupUser
Restored from previous forum. Originally posted by effigy.

I need to color a rectangle area on the window. There will be gadgets
on top of this area. I thought initialy that I would take a Frame3dgadget
and change it's color. That didn't work. Although I can change the
color of my textgadgets using API the same command (using a callback) doesn't seem to work for the Frame3dGadget. I guess another option
would be to just draw a colored rectangle on the window but that would
then require directx (which I'd rather not use).

Any ideas would be welcome.

Thanks
Derek

Posted: Sat Mar 22, 2003 9:18 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Using the 2DDrawing functions on a window (with WindowOutput() ) doesn't use any DirectX at all.
PB is smart enough to realize you are drawing on a Window, and uses the GDI functions to do the drawing.

I would suggest make an Image (CreateImage()) and color it as you want, and then display that in a ImageGadget inside your window. Then you do not have to redraw it everytime, your winwow is moved under another window.

Make sure you create the ImageGadget first and then the Gadgets that should be on top of it.

Timo

Posted: Sat Mar 22, 2003 9:51 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

Try this:

#Image = 3
#ImageGadget = 4
CreateImage(#Image, 800,600)
UseImage(#Image)
StartDrawing(ImageOutput())
FrontColor(212, 208, 200)
Box(0, 0, 100, 600)
StopDrawing()
ImageGadget(#ImageGadget, 0, 0, 200, 600, UseImage(#Image))
CreateGadgetList(WindowID())
ButtonGadget(1, 10, 255, 75, 30, "Button")

The reason you are creating an image and then using that image is that when you draw to the screen, if you minimize or alt-tab and then come back to the screen, your buttons will be drawn but not the box. Also notice that you create the buttons after drawing to the screen.

Posted: Sat Mar 22, 2003 9:55 pm
by BackupUser
Restored from previous forum. Originally posted by effigy.

Thanks Guys...

I just bought PureBasic today... so I'm just trying to figure things out. Thanks for the tip.

Until my next question :wink:

Thanks
Derek

Posted: Sun Mar 23, 2003 3:59 pm
by BackupUser
Restored from previous forum. Originally posted by Denis.

Hi effigy,

this is another way to do that.

This code used 2 external libs with the following procedures :

SetWindowStyles() and SetWindowParent() are procedures from the lib Written by Roger Beausoleil (merci Roger) (lib WindowEx)

SetWinBackgroundColor() is a procedure written by Danilo (Your examples miss us...) witch set the background color of a window for example. Lib skinwin10

You'll find them on the resource site
http://www.reelmediaproductions.com/pb/asmlibrary.html


This code runs well under Win98 SE.

Denis



Code: Select all

MainWindow.l = OpenWindow(1,0,0,440,220,#PB_Window_ScreenCentered," This is a try")     If MainWindow
        GetWindowRect_([url]mailto:MainWindow,@Var.RECT[/url]\left) 
        width.l = Var\right - Var\left  
        If CreateGadgetList(MainWindow)
           ButtonGadget(500 , 40, 180, 85, 25, "Cancel")
           TextGadget(600,10,135,230,15,"PUREBASIC - FEEL THE... PURE... POWER")
        EndIf

;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
;here is the child white window creation

        If OpenWindow(2,0,0,width,80,#PB_Window_Invisible,"")
           WhiteWindow = WindowID(2)
           SetWindowStyles(WhiteWindow, #WS_CLIPCHILDREN | #WS_CHILD, #WS_VISIBLE)
           SetWindowParent(WhiteWindow,MainWindow)
           SetWinBackgroundColor(WhiteWindow,#White) ; set the color to the child window
           HideWindow(2,0) ; schow white window
        EndIf

;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
;here is the child red window creation

        If OpenWindow(3,300,130,90,40,#PB_Window_Invisible,"")
           RedWindow = WindowID(3)
           SetWindowStyles(RedWindow , #WS_CLIPCHILDREN | #WS_CHILD, #WS_VISIBLE)
           SetWindowParent(RedWindow,MainWindow)
           SetWinBackgroundColor(RedWindow ,#red) ; set the color to the child window
           HideWindow(3,0) ; schow red window
        EndIf
        
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

        UseWindow(1) ; main windows is the current window

     EndIf 
     
     
    Repeat

     If WaitWindowEvent() = #PB_EventGadget And EventGadgetID() = 500
        Quit = 1
     EndIf 

    Until quit = 1