From: ShiroNeko on 15 Mar 2010 08:15 Hi, recently I wrote a DLL to make javas windows transparent in win32. The file works partially, thats the weird thing. When setting the window to transparent, the window becomes transparent, and drawing to its Graphics works as long as you don't use drawImage, if you use drawImage, the window stops being transparent. Any ideas on whats wrong? JNI makeTransparent: SetWindowLong(hwnd, GWL_EXSTYLE, oldGWL_EXSTYLE | WS_EX_LAYERED); SetLayeredWindowAttributes(hwnd, color, alpha, flags); Java: class Wnd extends Window{ public void paint(Graphics g){ g.drawRect(10, 10, 10, 10); // <-- Works fine g.drawImage(image, 0, 0, null); // <-- results in a non transparent window 80% of the time. } public static void main(String[] vArgs){ Window w = new Wnd(); int hwnd = JNI.getWindowHandle(w); int color = new Color(0xff, 0x00, 0xff).getRGB(); JNI.makeTransparent(hwnd, color, 0, JNI.LWA_COLORKEY); } } //Regards --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Roedy Green on 16 Mar 2010 02:59 On Mon, 15 Mar 2010 13:15:30 +0100, ShiroNeko <honoka(a)ridorana.se> wrote, quoted or indirectly quoted someone who said : > g.drawImage(image, 0, 0, null); // <-- results in a non >transparent window 80% of the time. Some thoughts. What do you mean by transparent? Do you mean those milky bars at the top of the windows or a truly transparent window that shows the background until painted on? A transparent image feature would have to be "transparent" to the application drawing code, otherwise legacy Windows programs could not be transparent. Java supports transparency of its own windows, but I don't think has any notion of transparency over the OS. It would not know anything about what your JNI did. Java would have no compunction about painting the background of a windows as it reworked the window. It might leave it alone when it first got it from the OS. That reworking would be opaque. -- Roedy Green Canadian Mind Products http://mindprod.com Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question. ~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming.
|
Pages: 1 Prev: What to do if anything bites. Next: Initializing a Map in an Interface? |