Sizing causes too many re-draws, want to trap and redraw on
Mike & Tina Dodd -- dodd@wilmington.net Saturday, December 07, 1996 Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike
Brad Wilson/Crucial Software -- crucial@pobox.com Monday, December 09, 1996 [Mini-digest: 9 responses] >>>>>> I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. <<<<<< Full motion drag causes that. You can trap: WM_ENTERSIZEMOVE WM_EXITSIZEMOVE to determine when it starts and ends, then repaint. -- Brad Wilson Custom software development & solutions crucial@pobox.com Internet and intranet consulting services The Brads' Consulting Windows NT/Windows 95 software development http://www.thebrads.com Web site planning, development and maintenance Content (C) 1996 Brad Wilson; no reproduction without authorization -----From: John LundyIn MFC, you can capture the messages WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE in your CFrameWnd class (CMainFrame usually). These messages to not arrive via the regular message map functionality so you will have to add add a WndProc handler to catch them. Like this: ========================================================================== LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class switch (message) { case WM_ENTERSIZEMOVE: { // set your flag and notify children break; } case WM_EXITSIZEMOVE: { // clear your flag and notify children } } return CMDIFrameWnd::WindowProc(message, wParam, lParam); } ========================================================================== This will fix the problem of notification to your app. John Lundy At 04:00 PM 12/7/96 GMT, you wrote: >Environment: VC++ 4.1b, NT 4.0 > >I have a project which draws numerous object on the screen using >Primatives. When the user sizes the window the objects are redrawn to >a relative size to the new window, larger or smaller. It is a nice >effect. Unfortunately, OnSize is called when I grab the grip and the >program attempts the long redraw at various stepping intervals. This >can take some time, so the net result is a jumpy, annoying, pause >between sizings. Eventually, the window is sized properly and drawn >properly, but it is a long boring process because of the intermediate >redraws. > >I have tried to improve the speed of redraws to the best of my >abilities, now I want to eliminate the intermediate redraws allowing >the user to resize a white screen, then on ButtonUp, redraw the screen >properly. > >My problem is : I cannot trap WM_LBUTTONDOWN because the message when >the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping >WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and >the resizing 'Corner' is there, but a plain-jane window grip >'apparently, has a differnt window handle and my message is skipped. > >I know there has to be a way to trap this, and set a flag, check the >flag, clear the flag, and redraw at the proper time, but it alludes >me. > >Any help is appreciated. > >Thanks > >Mike > > ==================================================== John Lundy, Windows (16/32 bit) Software Developer At Home Entertainment Specializing in GUI, Multimedia and Game Development ==================================================== -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.2 mQCNAzEjXTAAAAEEAMEhmrYJUYivDtyoFSjgDGpYVkOvFd7ycGZ7VE8lNWJiSqhd VMhcL3Cs/8EkToYC5FDzKk043S6tnYDl2M8Fed7TuEPlHFG/VwB05H6jxw0z5UPE Cex93oZNgjtmqCgR1ZdSe7m4q/A5xX1jjjpQjA3V8nZlPC25slPM/tF5FKiRAAUR tCBKb2huIEMuIEx1bmR5IDxqbHVuZHlAaWFkZncubmV0Pg== =GbKQ -----END PGP PUBLIC KEY BLOCK----- -----From: Dicky Singh See WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE Set a boolean on former and reset on latter message. Don't draw complex stuff when boolean is set. ---------- From: Mike Dodd Sent: Saturday, December 07, 1996 11:00 AM To: mfc-l@netcom.com Subject: Sizing causes too many re-draws, want to trap and redraw on buttonup. Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike -----From: "Arthur H. Warren" >Environment: VC++ 4.1b, NT 4.0 A quick look with Spy++ reveals the messages WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE being sent at the beginning and end of any resize. You can confirm this by searching the knowledge base for "Full Drag" which turns up the article "How to Override Full Drag" (PSS ID Number: Q121541). Hope this helps, Herb. ________________________________________________________________________ Herb Warren - Junior G-Man, Rocket Scientist. AM/FM/GIS Services James W Sewall Company Voice: 207-827-4456 147 Center Street Fax: 207-827-3641 Old Town, Maine 04468 Email: awarren@jws.com _________________________________________________________________________ -----From: "Dean Wiles" In WinNT and Win95 there are WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE messages that you should get when the size or move process begins and ends, so you don't have to process all the intermediate WM_SIZE messages. -------------------------------------------------------------------------- Dean Wiles (deanw@mail.isc-br.com) Olivetti North America Phone: (509)927-7037 22425 East Appleway Ave Fax: (509)927-2499 Liberty Lake, WA 99019-9534 If the Son sets you free, you will be free indeed. (John 8:36) ---------- From: Mike Dodd To: mfc-l@netcom.com Subject: Sizing causes too many re-draws, want to trap and redraw on buttonup. Date: Saturday, December 07, 1996 8:00 AM Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike ---------- -----From: Scott Colestock Try trapping WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE. That should give you = the ability to set whatever flags you need. This works even if "full = window-contents drag" is turned on. - Scott ---------- From: Mike Dodd[SMTP:dodd@wilmington.net] Sent: Saturday, December 07, 1996 10:00 AM To: mfc-l@netcom.com Subject: Sizing causes too many re-draws, want to trap and redraw on = buttonup. Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike -----From: hou@tfn.com (Bing Hou) Mike, In you OnDraw handler, do the following, int key = ::GetKeyState(VK_LBUTTON); if(key & 0x8000) { // left button is down, don't draw it. } else { // left button is up, draw your stuff. } It appears to behave as you desired, but you have to redraw your objects somehow when mouse button is released. Hope this will work for you. - Bing. ______________________________ Reply Separator _________________________________ Subject: Sizing causes too many re-draws, want to trap and redraw on Author: dodd@wilmington.net (Mike Dodd) at Internet Date: 12/7/96 4:00 PM Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike -----From: Hugh Robinson Have you considered drawing to a memory DC and then copying the memory bitmap into your DC. For an example, look at the MFC DRAWCLI sample (under the OLE samples) : look at the OnDraw() function there. That might speed things up for you... ---------- From: owner-mfc-l Sent: Saturday, December 07, 1996 4:00 PM To: mfc-l Subject: Sizing causes too many re-draws, want to trap and redraw on buttonup. Environment: VC++ 4.1b, NT 4.0 I have a project which draws numerous object on the screen using Primatives. When the user sizes the window the objects are redrawn to a relative size to the new window, larger or smaller. It is a nice effect. Unfortunately, OnSize is called when I grab the grip and the program attempts the long redraw at various stepping intervals. This can take some time, so the net result is a jumpy, annoying, pause between sizings. Eventually, the window is sized properly and drawn properly, but it is a long boring process because of the intermediate redraws. I have tried to improve the speed of redraws to the best of my abilities, now I want to eliminate the intermediate redraws allowing the user to resize a white screen, then on ButtonUp, redraw the screen properly. My problem is : I cannot trap WM_LBUTTONDOWN because the message when the Grip is grabbed is WM_NCLBUTTONDOWN. I have tried trapping WM_NCLBUTTONDOWN and it works fine if the scrollbars are activated and the resizing 'Corner' is there, but a plain-jane window grip 'apparently, has a differnt window handle and my message is skipped. I know there has to be a way to trap this, and set a flag, check the flag, clear the flag, and redraw at the proper time, but it alludes me. Any help is appreciated. Thanks Mike -----From: Mike Blaszczak At 16:00 12/7/96 GMT, Mike Dodd wrote: >Environment: VC++ 4.1b, NT 4.0 > >I have a project which draws numerous object on the screen using >Primatives. When the user sizes the window the objects are redrawn to >a relative size to the new window, larger or smaller. It is a nice >effect. Unfortunately, OnSize is called when I grab the grip and the >program attempts the long redraw at various stepping intervals. This >can take some time, so the net result is a jumpy, annoying, pause Alter the window class for your view and _don't_ specify CS_VREDRAW or CS_HREDRAW. .B ekiM http://www.nwlink.com/~mikeblas/ <-- trip report central! 95 Honda VFR-750F / 88 Yamaha FZ-700 (damaged) / 94 Mazda RX-7 Serial #00050! / AMA - HRC - VFROC / Wang Dang Wankel I am bored of this talk. It is time now for the dancing! These words are my own - I do not speak on behalf of Microsoft.
Roger Onslow/Newcastle/Computer Systems Australia/ Friday, December 13, 1996 -----From: John Lundy> In MFC, you can capture the messages WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE >in your CFrameWnd class (CMainFrame usually). These messages to not arrive >via the regular message map functionality so you will have to add add a >WndProc handler to catch them. Like this: [snip] Not necessary to write a WinProc etc. Just use OnMessage to handle it: eg. add ON_MESSAGE(WM_ENTERSIZEMOVE,OnEnterSizeMove) etc to your message map and write a handler for it. I think you'll find this much easier. Refer to the KB article reprinted below: Use ON_MESSAGE() Macro to Map Less-Common Messages PSS ID Number: Q99848 Article last modified on 01-19-1996 7.00 | 1.00 1.50 1.51 1.52 | 1.00 2.00 2.10 4.00 MS-DOS | WINDOWS | WINDOWS NT --------------------------------------------------------------------- The information in this article applies to: - The Microsoft Foundation Classes (MFC) included with: - Microsoft C/C++ version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52 - Microsoft Visual C++ 32-bit Edition, version 1.0, 2.0, 2.1, and 4.0 --------------------------------------------------------------------- SUMMARY ======= The Microsoft Foundation Class Library includes macros that an application can include in the message map of a CWnd or CWnd derived object.These macros, such as ON_WM_PAINT() and ON_WM_SIZE(), map common messages to default handler functions. The Microsoft Foundation Class Library provides macros for all standard window messages. To process user-defined message or less-common window messages (like WM_COMMNOTIFY), use the ON_MESSAGE() macro. The ON_MESSAGE macro must be used in a CWnd derived class. For example, it cannot be used in a CWinApp class or a CDocument class because neither of these classes is derived from CWnd. MORE INFORMATION ================ Here's an example of how an application could use ON_MESSAGE: // inside the class declaration afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam); ... #define WM_MYMESSAGE (WM_USER + 100) BEGIN_MESSAGE_MAP(CMyWnd, CMyParentWndClass) ON_MESSAGE(WM_MYMESSAGE, OnMyMessage) END_MESSAGE_MAP() LRESULT CMyWnd::OnMyMessage(WPARAM WParam, LPARAM LParam) { return (LRESULT)0; } The function specified by the second parameter of the ON_MESSAGE macro must be a function that takes two parameters, a WPARAM and an LPARAM, and returns a LRESULT. For more information about the ON_MESSAGE() macro, see Technical Note #6 in the MFC Tech Notes Help file distributed with Microsoft Visual C++ version 1.0 and in the MFC Technical Notes included in the Visual C++ Books Online. Or search the Visual C++ Books Online on the keyword "ON_MESSAGE." Additional reference words: kbinf 7.00 1.00 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00 KBCategory: kbprg KBSubcategory: MfcMisc ============================================================================= Copyright Microsoft Corporation 1996. Roger Onslow Software Development Manager Quisine Division - Computer Systems Australia mailto:Roger_Onslow@compsys.com.au visit us at http://www.compsys.com.au Quisine Insite - Designing for the Future
| Вернуться в корень Архива |