WM_PAINT

Started by
6 comments, last by derek7 17 years, 10 months ago
class Cmydialog :public CDialog { OnInitDialog() { ................ SendMessage(WM_PAINT);which will call OnPaint() UpdateWindow();//which will call nothing; why??? // } };
Advertisement
Quote:Original post by derek7
class Cmydialog :public CDialog
{
OnInitDialog()
{
................
SendMessage(WM_PAINT);which will call OnPaint()
UpdateWindow();//which will call nothing; why???

//
}

};


You don't send WM_PAINT messages. Rather, what you want to do, is invalidate the rectangle of the window you want redrawn (in this case, the dialog), to force a redraw.
Not too sure about MFC but Win32 API UpdateWindow will sent an WM_PAINT message to the window only if the window's update region is not empty so I guess if you call UpdateWindow directly after sending the window WM_PAINT, there is nothing to update so nothing happens.

[EDIT: Too slow. Nyteguard made more sense anyway]
You want to look at InvalidateRect (That's the Win32 version, the MFC version is almost identical. And as others have said, you don't want to send WM_PAINT directly, Windows will do that for you when it needs updated.

If you just call InvalidateRect(), windows will queue up a WM_PAINT message. If you need it updated immediately, you can use UpdateWindow().
a idea just jump out of my mind.

record the register (I remember some register push function name and function parameter before call function)and translate it to symbol(function name).

does it work?
Quote:Original post by derek7
a idea just jump out of my mind.

record the register (I remember some register push function name and function parameter before call function)and translate it to symbol(function name).

does it work?
For what function? You won't be able to get the address of a function and get a name for it (not easily anyway).

And why on earth would you want to though? MFC is designed so you don't have to do things like this...
UpdateWindow() just forces the WM_PAINT message (if there's an invalid region) to be processed immediatelty, as steve already mentioned.

- xeddiex
one..
Quote:Original post by Evil Steve
Quote:Original post by derek7
a idea just jump out of my mind.

record the register (I remember some register push function name and function parameter before call function)and translate it to symbol(function name).

does it work?
For what function? You won't be able to get the address of a function and get a name for it (not easily anyway).

And why on earth would you want to though? MFC is designed so you don't have to do things like this...



make a mistake. should the link

This topic is closed to new replies.

Advertisement