|
Are you returning the correct value when processing WM_PAINT messages?
|
|
|
|
|
well as im fairly new to child forms I dont know what value i should be returning
ive tried
UpdateWindow(hWnd) in case WM_ACTIVATE:
but that didnt really do anything,
its when i put another child window infront of another and click on the one behind it doesnt redraw and half the window is missing
i really dont ahve a clue how to sort that
|
|
|
|
|
|
well before that i found a semi way of sorting my problem but it caused tremendous flickering
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint( hWnd, &ps );
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
EndPaint( hWnd, &ps );
}
return 0;
break;
i even tried
but im still having no luck
|
|
|
|
|
No no no!
The call to InvalidateRect() triggers the generation of a WM_PAINT message so that definately needs to come out.
UpdateWindows() does the same but the window procedure is called rather than letting the message run through the normal message queue so that call also needs removing.
The code you've shown doesn't actually do anything so I'm not surprised the window doesn't change on screen. Is that it or have you removed the painting code to make things clearer?
|
|
|
|
|
I wish i could paste a picture in here lol
I removed those lines and im aware that the paint method i have set doesnt do anything
but even without the WM_PAINT and using the updatewindow etc it still causes overlapping and no redrawing
|
|
|
|
|
|
no, i tried that at one point and all the windows when they gained focus just passes under the background of the other child windows, its very weird
|
|
|
|
|
What Steve meant to say was NO NO NO!!
You're causing infinite recursive WM_PAINT messages there.
Sarriss wrote: but even without the WM_PAINT and using the updatewindow etc it still causes overlapping and no redrawing
No redrawing will be done unless you do some drawing.
If you call BeginPaint/EndPaint without doing any drawing, then
even if you pass the message to the default window proc, nothing
will happen.
You need to either draw the window contents or let the default
window proc draw the window contents in response to WM_PAINT.
Of course, you can always let the default window proc do its drawing
then draw on top of that if you'd like.
Just don't call any invalidate/update/redraw window functions from your
WM_PAINT handler!! All those messages cause WM_PAINT messages.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yeah I noticed that after I tried it,
eitherway I still need help with WM_PAINT, im still trying to get it so when i bring it as the focus window it redraws and doesnt leave half of the window with the image of the window that was infront of it
|
|
|
|
|
Sarriss wrote: im still trying to get it so when i bring it as the focus window it redraws and doesnt leave half of the window with the image of the window that was infront of it
Did you specify NULL for the background brush in the window class?
If so, you are responsible for drawing the window background yourself.
The system will give you the messages - you just need to
respond to them correctly.
I would start simple - do nothing in your window proc except call the
default window proc. If that doesn't work right then you haven't
implemented your window proc correctly.
Then maybe add in a simple WM_PAINT handler:
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
}
return 0;
break;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
no the background brush was not null thats what is confusing me, there is a background but its dont redrawing anything properly
|
|
|
|
|
If the background brush is null then nothing will draw in the client
area of the window unless YOU draw it. You can do that in response to
the WM_ERASEBKGND (typically) or WM_PAINT message.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
am i being thick or is it no one is understanding me
I have a background
I have child windows
how do i force them to redraw when i set the focus
the imprint of the form that sits infront of the one i click, is still there, its a refresh problem,
can anyone please just tell me the code to just redraw/refresh the whole lot.
|
|
|
|
|
I already stated:
The system will send the appropriate messages. If it's not redrawing properly
you are doing something wrong.
I suppose you could try to figure out all the possible messages
received when your window gets focused/activated and force an
invalidate/update/redraw but it would be a hack covering up an existing
problem. Even then, I doubt it would redraw properly since it already isn't.
Back to the drawing: AFAIK, and I could be wrong, you stated the
background brush for the window class is NULL, you have no WM_ERASEBKGND
handler, and WM_PAINT handler does nothing. What do you expect to be drawn then?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I said the hbrBackground Brush IS NOT NULL as in it has a value
i dont have WMERASEBKGND or WM_PAINT at the moment but the background is being drawn
ill go through whats happeneing properly
i create a child window(window 1)
i then create another child window(window 2) and place half of that over (window 1)
i then click and drag the (window 1) from behind
and where (window 2) overlapped (window 1) it is still being drawn on (window 1)
They both have backgrounds, i just need something to refresh, i do all my windows the same way and
it normally works, its just when i made these child forms they dont do it anymore.
|
|
|
|
|
Sarriss wrote: said the hbrBackground Brush IS NOT NULL as in it has a value
My mistake, sorry. And the value is valid?
Sarriss wrote: its just when i made these child forms they dont do it anymore.
Then something is done wrong. The system will send the appropriate
messages to refresh the exposed areas of windows.
What does the window class and window procedure look like for the
window that's not refreshing properly?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also, what are the window style flags used to create the windows?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here is the register
void RegWnd::RegChildWindow(HINSTANCE hInstance, char *ClassName, WNDPROC WndProc, LPCTSTR MenuName)
{
wcc.cbSize = sizeof(WNDCLASSEX);
wcc.style = CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS;
wcc.lpfnWndProc = WndProc;
wcc.cbClsExtra = 0;
wcc.cbWndExtra = 0;
wcc.hInstance = hInstance;
wcc.hIcon = static_cast<hicon>(LoadImage( hInstance,
MAKEINTRESOURCE(IDI_MAIN),
IMAGE_ICON,
255,
255,
LR_DEFAULTCOLOR));
wcc.hCursor = LoadCursor(NULL, IDC_ARROW);
wcc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcc.lpszMenuName = MenuName;
wcc.lpszClassName = ClassName;
wcc.hIconSm = static_cast<hicon>(LoadImage( hInstance,
MAKEINTRESOURCE(IDI_MAIN),
IMAGE_ICON,
16,
16,
LR_DEFAULTCOLOR));
}</hicon></hicon>
here is the create
HWND CreateChild(HINSTANCE hInstance,
LPCTSTR ClassName,
LPCTSTR WndName,
HWND parent,
DWORD dStyle = WS_OVERLAPPEDWINDOW|WS_CHILD,
DWORD dXStyle = 0L,
int xPos = CW_USEDEFAULT,
int yPos = CW_USEDEFAULT,
int Width = 400,
int height = 400);
|
|
|
|
|
Try adding the WS_CLIPSIBLINGS style to the child windows.
Also, you may find adding the WS_CLIPCHILDREN flag to the parent window
results in more pleasing updates during resizing (the children won't flicker).
You may get better results using overlapped windows as child windows if you
use the Multiple Document Interface[^].
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
well im trying to stay form MDI thats the whole point of this exercise
those two did how ever stop the issue now it keeps the window behind the other till i let go, presumably need to put a refresh on the WM_LBUTTONDOWN but thats an issue i can ignore for now thank you for your help mate
|
|
|
|
|
Hi
I want to create directory in hierarcy. For example I want to create c:\Test\Temp directory. Both test and temp directory do not exist.
Thanks
|
|
|
|
|
and what have you tried so far to achieve this ?
have you searched MSDN ?
|
|
|
|
|
I bet what he's looking for is an obscure function called something like ::DoMySpecialThingRightNow() instead of an intuitive name like ::CreateDirectory() ....
I mean, who would ever think of that...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
certainly
|
|
|
|