Weired GDI+ and/or Layered Window Behaviour - Please Help!
From: Atif (anonymous_at_discussions.microsoft.com)
Date: Tue, 9 Mar 2004 21:26:07 -0800
I am using GDI+ on Layered Window, I create a compatible DC from which I create the GDI+ Graphics object and I use that Graphics object for drawing on the DC and in the end I call updatelayeredwindow(). Everything works fine till now, the window is drawn fine and I am not worried about slow drawing on the window since i won't be animating anything. The real problem is that when I DON'T have to redraw AND I JUST HAVE TO move the layered window on the screen, I call updatelayered window() providing only the the new x-y position then sometimes it works really fine & fast and at other times it beats the hell of out my system (very slow, almost full CPU usage), for just moving the window. I am not sure which part is causing the problem, the layered window or GDI+.
Futher, During past 3 weeks of trying to understand the cause of this error and hence remove it, I have noticed a strange thing - All times I have been successfully able to generate this slow window move behaviour by doing the following.
i) Starting the Windows Media Player 9 Series and play a song w/ visualizations (bars).
ii) Start 2-3 instances of MSDN Library 2003
iii) Open few browser windows & browse them to any location
iv) Now when I start the program, It sucks!
However, If I don't do any of these and just start my program it works fine (fast) 90% of the time but no gurantee that it would always! I know about GDI & GDI+ interoperatiblity issues so before issuing the move command ( I issue a about 200 along x-axis in a for loop with 5 milli-second Sleep() call in each iteration) I always call Graphics->GetHDC & after moving I call Graphics->ReleaseHDC(hdc).
I have tried using MoveWindow API
I am not handling any of the WM_PAINT or WM_ERSEBKGRND messages
I am using Transparency in LayeredWindow - a little
I am using GDI+ on W2K system with GDI+ installed. I have Gdiplus.dll copied to my program's directory and I have also rebased the Gdiplus.dll
I have tried above mentioned behaviour regeneration test - BRT ;) - on Windows XP system and same thing happens.
Please guys F1 (Help)!
Thanks & Best Regards,