December 10th, 2012, 02:01 PM
Graphics glitches in Win32 main window Skinning while updating STATIC controls
Graphics glitches in Win32 main window Skinning while updating few STATIC controls periodically.
I am in desperate need of a solution or a pointer to what may be wrong.
I am skinning an app as follows:
DestroyCaption( hwnd,wWidth,wHeight );
// update window style
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, g_ColourKey, 0, LWA_COLORKEY);
And painting the bitmap in the **WM_PAINT** message :
HDC hdc = BeginPaint(hwnd, &ps);
PaintWindow( hwnd, hdc, wWidth, wHeight );
void PaintWindow( HWND hwnd, HDC hdc, int wWidth, int wHeight )
HDC dcSkin = CreateCompatibleDC( hdc );
SelectObject( dcSkin, hSkinBmp );
BitBlt( hdc, 0, 0, wWidth, wHeight, dcSkin, 0, 0, SRCCOPY );
DeleteDC( dcSkin );
SetTextColor( hdc, text_format.textcolor );
SetBkMode( hdc,TRANSPARENT );
HFONT hOldFont = (HFONT)SelectObject( hdc, text_format.hfont );
TextOut( hdc, text_format.x, text_format.y, text_format.data.c_str(), strlen( text_format.data.c_str() ) );
SelectObject( hdc, hOldFont );
Everything was working perfectly till I decided to update few **STATIC** controls' text with SetWindowText during an event which occurs in a different thread periodically, approximately once per second, the text on the STATIC controls gets updated only in every 10th iteration of this event. I am using SendMessage() to send WM_USER message to the main window which in turn updates the STATIC controls.
Now the skin of the window just goes away after a minute or so of running the app and there only remains grey rectangle, the buttons which have custom skins set with **BM_SETIMAGE** doesn't get affected by this error.
Now I am totally out of ideas on what would be going wrong. What you think I should be taking care of while doing something like this ?
**If I stop the update of the STATIC controls in the WM_USER handler, the graphic problem goes away.**
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!