|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Suhai Gyorgy
|
Sep 28, 2005 - 2:56 AM
|
Hi! I`m trying to make a static for my GUI that has a faded background, meaning lighter on the top and darker on the bottom. The only way I`ve found so far is using a bitmap. But of course that means: when I change UI Theme, I should change the bitmap as well. That would be fine (since there is only 4 UI Themes) as long as the user won`t change the theme/color of the Windows OS. Your Prof-UIS background follows the theme, but my bitmap can’t. How could I make a faded background for my static without using bitmap, somehow getting the momentary color of the background/toolbar`s dark and light color and using those as faded colors? Thank you in advance: Chris
|
|
Technical Support
|
Sep 28, 2005 - 7:17 AM
|
We guess you want to code a static window with a gradient fill from top to bottom. It would be nice to receive some screenshot (support@prof-uis.com) to avoid any misunderstanding. The solution is to catch the event when the theme/color scheme changed and it’s not difficult. All the windows in your application, including your "faded" static, are repainted when the theme (the Prof-UIS Paint Manager component or Windows desktop theme) and colors are changed. So, the painting code of your static should do the following:
1) Analyze whether the colors were changed and recreate a bitmap or anything else which is used in your static control’s background painting when the colors are changed.
2) Paint the background/foreground of your static control.
This means your CStatic -derived class (or a CExtLabel -derived class) should have one or more COLORREF members which are used in gradient painting or background bitmap generation. These COLORREF properties must be initialized with the COLORREF(-1) value in your class constructor. The OnPaint() method queries the Prof-UIS Paint Manager component for these COLORREF values using the g_PaintManager->GetColor() API. If the returned color values are not equal to those kept in your class, then you should regenerate your background bitmap. After that, your OnPaint() method should draw the static control.
|
|
Suhai Gyorgy
|
Sep 28, 2005 - 7:41 AM
|
I would be interested in that "gradient painting" rather than in bitmap generation. Anyway, right now I do the bitmap-painting in OnCtlColor() function, so I’m guessing if gradient painting wouldn’t be possible, I could do the bitmap generation in that function as well. But would be very happy to see how that gradient painting is possible. Thank you: Chris.
|
|
Technical Support
|
Sep 29, 2005 - 2:50 AM
|
We already have a method which fills a rectangle with a color that smoothly fades from one side to another. To add smooth fading to a rectangle, just call the CExtPaintManager::stat_PaintGradientRect() static method with the upper-left and lower-right coordinates of the rectangle. There are two modes used when drawing a rectangle. When the rectangle is oriented horizontally, it is shaded from left to right and, when oriented vertically, the rectangle is shaded from top to bottom. The following code draws a gradient for the vertical mode: CExtPaintManager::stat_PaintGradientRect(
dc,
rcPaintGradient, // rectangle
clrTop, // top color
clrBottom, // bottom color
true // vertical mode
);
|
|
Suhai Gyorgy
|
Sep 30, 2005 - 6:32 AM
|
Thank you for your quick response! I tried the way you had advised but for some reason it didn’t work. Anyway, you don’t have to bother to find out why that happens, because I have found just what I needed! I was looking for the kind of gradient painting the Outlook uses for its dark blue caption, and looking at the samples and sources I found g_PaintManager->PaintPageNavigatorItemCaption. With this method I could reach exactly what I needed. So no more question from me on this subject, just a little update, maybe someone else can use it. Regards: Chris.
|
|