Question

LokanathNayak on Fri, 12 Feb 2016 09:23:32


Hi,

I want to understand the MFC OnPaint drawing on below aspect.

Ex. My client Rect is CRect(0,0,500,500). And i am drawing a grid of size CRect(0,0,1000,1000).

I observed that, only a portion of the grid(0,0,500,500) is displayed and the remaining is not visible. I understand this is because my paint area is only CRect(0,0,500,500);

But i want to understand, is it something like, the entire grid is drawn and only paint area is visible or only the paint area is drawn and remaining is not drawn.

When i am changing the SetWindowOrg, then the different portion of the grid is displayed. So i feel all the grid is drawn, but only the paint/view area is visible. Please confirm

Thanks.


Sponsored



Replies

RLWA32 on Fri, 12 Feb 2016 10:27:59


See The WM_PAINT Message and the discussion of clipping and clipping regions.

Igor Tandetnik on Sat, 13 Feb 2016 02:03:06


On 2/12/2016 4:23 AM, LokanathNayak wrote:

But i want to understand, is it something like, the entire grid is drawn and only paint area is visible or only the paint area is drawn and remaining is not drawn.

I'm not sure I understand the alleged difference between "drawn but is not visible" and "is not drawn". The observable behavior is, no change to any pixel outside of the client area. In what way is this information insufficient?

In other words: suppose you somehow obtain an answer to your question - what next? What do you plan to do differently depending on this answer?

Hart Wang on Mon, 15 Feb 2016 06:03:27


Hi,

>> When i am changing the SetWindowOrg, then the different portion of the grid is displayed. So i feel all the grid is drawn, but only the paint/view area is visible.

According to my search. If you want to mark the point in the device coordinate system to which GDI maps the window origin. You need to use the SetViewportOrg function .

SetViewportOrg is device coordinate system.

SetWindowOrg is logical coordinate system.

I think you can try to use the SetViewportOrg function.

Best Regards,

Hart

LokanathNayak on Mon, 15 Feb 2016 17:26:30


Dear All,

I just wanted to understand whether OnPaint draws everything i coded in OnPaint. As i mentioned in the above example, my client rect is 500x500 but i am drawing a 1000x1000 grid. 

After reading the WM_PAINT in msdn, i understood that, OnPaint draws only the view/client area and ignores the rest. In the above example it can only draw the 500x500 rect which can be visible and ignores rest.

Thanks a lot.

Hart Wang on Tue, 16 Feb 2016 03:30:33


Dear All,

I just wanted to understand whether OnPaint draws everything i coded in OnPaint. As i mentioned in the above example, my client rect is 500x500 but i am drawing a 1000x1000 grid. 

After reading the WM_PAINT in msdn, i understood that, OnPaint draws only the view/client area and ignores the rest. In the above example it can only draw the 500x500 rect which can be visible and ignores rest.

Thanks a lot.


Hi,

It is not clear that you retrieves the coordinate of a window's client area by GetClientRect function?

>> my client rect is 500x500 but i am drawing a 1000x1000 grid. 

client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0). If you have free time you can refer to the link: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx

when you want to Calculates the required size of the window rectangle, based on the desired client-rectangle size. You can use the AdjustWindowRect function :https://msdn.microsoft.com/en-us/library/ms632665(VS.85).aspx

 

For the butter support. Could you please a demo for us to test.

Regards,

Hart