Advertisement
5_2007-2008 Graphics/ Sound #181945

Translucent window under Win9x/ME/2000

This is a nice example which shows you how to create a translucent window under Windows 9X/ME. Windows 2000/XP has an own function for this. Windows 98 AlphaBlending functions, but Windows 95 has nothing, so I decided to use a external function for AlphaBlending (win9x) and I used for Windows2000 the SetLayeredWindowAttributes function. The functions in gdiu.cpp were written by Graus an other programmer who works for a Programmer's Journal. To use the code in your own applications copy the files win9Xtranslucent.cpp, win9Xtranslucent.h, win2000translucent.cpp, win2000translucent.h into your project and look at translucent.cpp, win9Xtranslucent.h, win2000translucent.h how to use the functions. IMPORTANT: The code is not perfect! So it can be optimized. If you want to optimize the code do it like you think it's good for your project :-) For best optimitation the code must be rewritten into DirectX code. HOW DOES IT WORK: When the application starts a copy of the desktop will be made (WM_CREATE). On the first WM_PAINT message a copy of the window will be made. The WM_PAINT message is the message where the most work is. First we calculate the size and position of the window, then we check the intersection between the backuped size, position and the new size, position. If there is a intersection we copy a section from our background backup bitmap into the new background bitmap to hide the old window. Then we copy the new position, size to the backup position, size. Now we create 2 bitmaps: the first is a copy of the window rectangle from the screen (without the window), the second is a copy of the window. This 2 bitmaps are the arguments of the AlphaBlendU function which will create a new bitmap. This bitmap will be drawn on the screen. And at last we create a new copy of the screen. The old copy is the background backup bitmap. On WM_WINDOWPOSCHANGED message we POST a WM_PAINT message to our window for updating. NEW: In this version the size of the window can be changed! _____________________________ Please vote it :-) Sorry for my bad english.

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
Upload
Původní komentáře (3)
Obnoveno z Wayback Machine