Page 1 of 1

How to get the real window background color

Posted: Wed Jul 14, 2010 10:09 am
by MyTrial
Hi

just a simple question, i thought, but no answer found: How to get the background color of a window?

If i set the window background color with

Code: Select all

SetWindowColor(0,-1)
and want to get the real window background color with

Code: Select all

GetWindowColor(0)
i get "-1" but not the real background color.

Code: Select all

#PB_Gadget_BackColor
is set to "2" but not to a color.

How do i get it?
Is there a constant i did not found?

Thanks for help.
Sigi

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 10:15 am
by Trond
The problem is that the default background colour can be a texture and not a colour, especially on Linux and Mac. This should give you the colour (if it's not a texture) on windows only: GetSysColor_(#COLOR_3DFACE).

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 10:24 am
by MyTrial
Thank you, Trond.
I didn't think of that texture possibilities.

I did it now in this way:

Code: Select all

StartDrawing(WindowOutput(0))
WindowBackColor = Point(5,5)
StopDrawing()
I asked because i have to draw a image which is set with a image gadget on the window to get the same background. So it would be better to draw a transparent image. ;)

Thanks for your help.
Sigi

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 10:44 am
by Trond
You can use an image with alpha channel to make the background transparent:

Code: Select all


CreateImage(0, 100, 100, 32)
StartDrawing(ImageOutput(0))
  DrawingMode(#PB_2DDrawing_AlphaChannel)
  Box(0, 0, 100, 100, RGBA(0, 0, 0, 0))
  DrawingMode(#PB_2DDrawing_AllChannels)
  Box(25, 25, 51, 51, RGBA(255, 0, 0, 255))
  DrawingMode(#PB_2DDrawing_AllChannels | #PB_2DDrawing_Outlined)
  Circle(50, 50, 45, RGBA(0, 192, 40, 255))
  Circle(51, 50, 45, RGBA(0, 192, 40, 255))
  Circle(50, 51, 45, RGBA(0, 192, 40, 255))
  Circle(49, 50, 45, RGBA(0, 192, 40, 255))
  Circle(50, 49, 45, RGBA(0, 192, 40, 255))
StopDrawing()


OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ImageGadget(0, 0, 0, 0, 0, ImageID(0))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver



Re: How to get the real window background color

Posted: Wed Jul 14, 2010 11:23 am
by MyTrial
Hi Trond

Thank you for your good help.

I did it another way, because i have to draw more than one image (part) and they are not changed. So i create an background image and draw all stuff on it. In that way i have the control on the background color and k now that there are no textures. I run in another problem, but that was discussed before. I need to have a look how to resolve it.

I draw a background image and set that as image gadget and disable that. But not all gadgets are drawn over the image gadget. Only if i put another window over this and put mine in front, then all gadgets are drawn. I have to search.

And i save your good help for the next time i need something like that. Thank you.

Thanks
Sigi

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 1:21 pm
by PB

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 5:02 pm
by MyTrial
Hi Trond

I found my old solution of that refreshing problem if i use a background image. By start and by every action which changes the background image or some other parts of the gadgets, i use the following to refresh. This works on windows and linux.

Code: Select all

HideGadget(#GUI_BACK,1)
HideGadget(#GUI_BACK,0)
#GUI_BACK is the handle of the imagegadget of the background image.

Thanks for your help.
Sigi

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 5:04 pm
by MyTrial
Hi PB

Thanks for your info. But maybe i'm a little confus, i do not know what you want to say to me with that link. I didn't found something interesting for me. I did i overlook something?

Sorry, but thanks
Sigi

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 6:05 pm
by PB
> i do not know what you want to say to me with that link

It's some code that shows how to get all system colors, including the constants used for them.
I was just trying to show that you could've got the code to get the window color from that. ;)

Re: How to get the real window background color

Posted: Wed Jul 14, 2010 11:19 pm
by MyTrial
Hi PB

Aaaah, now i understand. ;)
I got this old program working and it plays a lot of data and colors. They look like the theme of my computer. But i do not found the color which is played as background color when i produce a purebasic program.
Maybe i have tomatoes on my eyes. :shock:

Thank you for pointing to that. But it is only usefull for windows, not for linux. I must work in both parts, so i have to look always to a result which works on both. And i think my current design with a image gadget as background is good, because i have the control over the background and therefor of the whole design.

Thanks a lot for your help.
Sigi