Highlighted
Absent Member.
Absent Member.
704 views

[archive] Draw a vertical gradient and stretch background image on a window

[Migrated content. Thread originally posted on 14 March 2005]

Some have asked about drawing a vertical gradient and stretching a background image on a window, so I attempted it this weekend using the Windows API to see if it was possible.

The answer: Yes and No.
Yes, the gradient can be drawn and yes the stretched background image can be drawn, however, they will be erased when the runtime has to redraw the window. For instance when minimizing the window and then redisplaying it.

The problem is we don't have access to the window events that will allow us to redraw the gradient and background image. To do this we would have to get a pointer to the windows old process handler, assign a new process handler, run the old handler from within the new handler first then run some redraw code. This would probably have to be done in C and linked into the runtime. Not straightforward to say the least.

If I'm wrong and there is an easiar way, please tell me. That would be great!

My thoughts are if the runtime could expose more window events to us it may be possible to get things redrawn again without the need for overriding the window process event handler. Same issue applies to toolbars which behave similiar to windows.

In general, I would like to see many more events available to us for all graphical controls. I sent in an enhancement request for this. Well, at least I think I did. I can't remember for sure! 😄

When running the sample, keep in mind I slowed down the speed of the gradient drawing using C$SLEEP so that you can see the affect. Normally, the gradient drawing is fast enough to not see a delay.

Also, stretching an image doesn't always look very good, I think tiling the image on a background is better, provided the image pattern looks right when tiled. Tiling can be slower though. The sample I wrote should be able to be adjusted to tiling the image into the rectangle.
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Draw a vertical gradient and stretch background image on a window

the window the color are not there anymore!
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Draw a vertical gradient and stretch background image on a window

That's correct, I explained this in the original post.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.