Article View: comp.os.ms-windows.programmer.misc
Article #1634refreshing client area with different hdc
From: John Grant
Date: Fri, 16 Oct 1992 01:13
Date: Fri, 16 Oct 1992 01:13
54 lines
2397 bytes
2397 bytes
When I paint my client area in response to WM_PAINT, I scale my 'world' co-ordinates (~1e6 metres) to logical units of 0.1 mm and then paint with MM_LOMETRIC. This is fine. Up until now, I have ignored the clipping rectangle in PAINTSTRUCT, just to get it working (slow). Now I want to use the rect to redraw only what is required. Now I'm confused about how to use this clipping rectangle because it is provided for the default hdc of MM_TEXT and I work in MM_LOMETRIC. How do I convert those MM_TEXT co-ordinates to MM_LOMETRIC co-ordinates? I thought of using screen co-ordinates as an intermediate, i.e.: case WM_PAINT: hdc=BeginPaint(hwnd,&ps); LPtoDP(hdc,(LPPOINT)&ps.rcPaint,2); //to pixels //now set up my co-ordinate system SetMapMode(hdc,MM_LOMETRIC); SetWindowExt... SetViewport... SetViewportOrg... //convert pixels back to 0.1 mm logical units DPtoLP(hdc,(LPPOINT)&ps.rcPaint,2); //convert again to get world co-ordinates ... //paint my picture using world co-ordinates to clip ... //finish up EndPaint(hwnd,&ps); Is this the correct way to do this? I was hoping there would be a more transparent way. Preferences... It appears that there are several cases where a redraw is required: (a) WM_SIZE/WM_PAINT Since the window has changed size, the only way to do this is to read the data all over again and redraw the whole client area from scratch. True? (b) WM_MOVE/WM_PAINT (possibly not as common) (c) WM_PAINT after an occluding window is removed If I BitBlt a copy of the picture to memory after each WM_SIZE/WM_PAINT or initial WM_PAINT, then I could repaint a part of it by just BitBlting from memory to the client area? Is it better to redraw the rectangle by reading the data and drawing it again or attempt to BitBlt the picture to memory the first time, so that subsequent times it can be redrawn with more BitBlts. Is the BitBlt seamless? Sorry for the rambling - I can't seem to keep it short for this one.
Technical Details
Message-ID:
<1992Oct16.011314.2273@emr1.emr.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrantShow Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrant From: jagrant@emr1.emr.ca (John Grant) Subject: refreshing client area with different hdc Message-ID: <1992Oct16.011314.2273@emr1.emr.ca> Organization: Dept. of Energy, Mines, and Resources, Ottawa Date: Fri, 16 Oct 1992 01:13:14 GMT Lines: 54