From: winapi on
Hello,

When I use GetOpenFileName(), it seems that "this dialog box" is causing my
toolbar "custom draw" buttons to dissapear. I have checked, and this is
definitely
the problem. Has anyone else encountered this strange problem and been able
to fix it? That is strange behavior in regards to GetOpenFileName() and
GDI..

When I drag the GetOpenFileName() dialog box over my custom buttons they are
painted over/erased. If I press the "cancel button" on the
GetOpenFileName() dialog box,
then the buttons "reappear", but if I "continue" to select a file and "open
it", then the
buttons "dissapear" and "do not" come back/repaint.

Thanks.


From: Preben Friis on
"winapi" <apiwin(a)hotmail.com> wrote in message
news:hvok57$c8d$1(a)speranza.aioe.org...
> When I drag the GetOpenFileName() dialog box over my custom buttons they
> are
> painted over/erased. If I press the "cancel button" on the
> GetOpenFileName() dialog box,
> then the buttons "reappear", but if I "continue" to select a file and
> "open it", then the

You are probably not paiting your buttons the right way you are supposed to.
While the common dialog is displayed, it owns the message loop and is only
sending paint messages to your main loop. If you do not process them the
right way, your controls does not get painted.

To rephrase: There is nothing wrong with the GetOpenFileName() function.

/Preben Friis

From: winapi on
> You are probably not paiting your buttons the right way you are supposed
> to. While the common dialog is displayed, it owns the message loop and is
> only sending paint messages to your main loop. If you do not process them
> the right way, your controls does not get painted.

In my custom draw statement I am using BitBlt to place a bit map
on the button. This works fine with no artifacts, apart from when using
GetOpenFileName(), then the BitBlt will dissapear. What might one
suggest?

Thanks.


From: winapi on
> You are probably not paiting your buttons the right way you are supposed
> to.

I managed to solve this problem. I was setting up the hdc & hdcMem for the
BitBlt()
in the "function itself". This was then being called/created in my custom
draw switch
statement. This is incorrect.

In "my case" the HDC has to be created at the same time
as the window creation eg. . . . . . .


case WM_CREATE:

hdc = GetDC(hwnd);
hdcMem = CreateCompatibleDC(hdc);

return 0;




From: Preben Friis on
"winapi" <apiwin(a)hotmail.com> wrote in message
news:hvp2vj$863$1(a)speranza.aioe.org...
> In "my case" the HDC has to be created at the same time
> as the window creation eg. . . . . . .
>
> case WM_CREATE:
>
> hdc = GetDC(hwnd);
> hdcMem = CreateCompatibleDC(hdc);
>
> return 0;

It is perfectly legal to create a memory DC in the paint handler...

.... but now you are leaking at least one device context... which might give
you another problem another day.

Hint: ReleaseDC(hwnd, hdc);

/Preben