I'm using CreateWindowEx() to create a button as a groupbox.
When the groupbox is created, i change the fontsize/face.
The problem is that the original font displays behind the new font.
What can i do to prevent this?
I'm using CreateWindowEx() to create a button as a groupbox.
When the groupbox is created, i change the fontsize/face.
The problem is that the original font displays behind the new font.
What can i do to prevent this?
I am not really sure of what is happening, but you could try to force a repaint of the window you are changing. A button is just a window like any other, so you should be able to invalidate it.
Did invalidating the window work, knutso? Sorry, I'm curious.
No, i tried that before i asked...
I tried InvalidateRect(), but with the same result..
I'm handling the WM_CTLCOLORSTATIC message, but i do no painting.Code:// Invalidate GetWindowRect(tp[FRM], &r1); InvalidateRect(tp[FRM], &r1, 1); // Create buttonframe HWND CreateFrame(HINSTANCE *pInst, HWND hWnd, char *achTxt, int x, int y, int w, int h, char chFontSz){ HWND hwBuf; if((hwBuf=CreateWindowEx(0, "BUTTON", achTxt, WS_CHILD|BS_GROUPBOX, x, y, w, h, hWnd, 0, *pInst, 0))!=NULL){ SetFont(hwBuf, chFontSz, "Ms Sans Serif"); ShowWindow(hwBuf, SW_SHOW); return(hwBuf); }else return(0); }
I was about to tell you that you needn't call GetWindowRect(), as you can pass NULL (for pointer to RECT) to InvalidateRect() to invalidate the entire window, but this is not true. It just invalidates the entire client area. InvalidateRect() is only used for the purpose of invalidating the client area of windows, unless you pass NULL as the window handle, which invalidates all windows, and sends every window a WM_ERASEBKGND and WM_NCPAINT. Can you try doing that, instead? If the window refreshes itself properly, then you will know you just need to invalidate the non client area part of the window (even though InvalidateRect() is not the way to do this for a single window).
Same result:
InvalidateRect(0, 0, TRUE);
I also tried to SW_HIDE/SW_SHOW the frames.
It seems the control paints the original font, and then paints the new, smaller font on top..?
Drag another window over top of it, and then move it out of the way. This way the OS is handling the painting of both the client and non-client areas. Let us know what happens.
Give WS_CLIPCHILDREN & WS_CLIPSIBLINGS a try.
None of variables has hwnd as part of it's name,Originally posted by knutso
No, i tried that before i asked...
I tried InvalidateRect(), but with the same result..
I'm handling the WM_CTLCOLORSTATIC message, but i do no painting.Code:// Invalidate GetWindowRect(tp[FRM], &r1); InvalidateRect(tp[FRM], &r1, 1);
but, I suppose tp[FRM] is of type HWND?
What you are doing is Getting the Rect of a control,
and invalidating that area within control. Maybe you
should InvalidateRect on the parent window, like
And for GetWindowRect MSDN sais:Code:GetWindowRect(tp[FRM], &r1); InvalidateRect(GetParent(tp[FRM]), NULL, 1);
hWnd - in: Handle to the window.
lpRect - out: Pointer to a RECT structure that receives the screen
coordinates of the upper-left and lower-right corners of the window.
So if you don't send NULL to InvalidateRect(), you
should convert r1 from screen coordinates to client values
with ScreenToClient()
Delf
HWND tp[xx]; == Array with hWnd's to keep the tabposition
I'll give ScreenToClient() a try, but i tried InvalidateRect(0, 0, 1) with the same result.
I'll come back when i've tried ScreenToClient()..