owner-draw problems with CListBox/OnEraseBkgnd/CDC:ExcludeClipRect

Hi, i've got a tricky problem with an owner-drawn ListBox object.  I'm 
trying to fix the update flicker so I got some sample code that creates a 
CDC wrapper around a hidden bitmap which i've used in DrawItem to hide the 
drawing process (this part works fine in isolation).

The problem is that i also had to override the OnEraseBkgnd method to stop 
the whole scroll area being erased and as a result I get nasty graphical 
'trails' of old data that hasn't been erased.

My (not very good) fix for this was to pad the ListBox so there are always 
enough blank entries to fill the scroll area and also snap the height of the 
client area to an exact multiple of the item height.  This fix works pretty 
well but it's not exactly what I had in mind (the scroll bars aren't 
accurate and there are empty but selectable entries at the end of short 
list - also if i resize the ListBox i need to re-pad the items).

I saw some other flicker-fix code (for resizing dialog windows) and this 
used the CDC:ExcludeClipRect function to stop certain bits of the window 
being erased so I thought it would be pretty neat if i could use 
ExcludeClipRect to force OnEraseBkgnd to only erase the parts of the ListBox 
scroll region where there are no items being displayed.

I'm currently trying to get this working in my ListBox class but it seems 
that when I call ExcludeClipRect in OnEraseBkgnd to exclude the areas where 
I know the list items are positioned the subsequent calls to DrawItem also 
use this modified clipping context and my ListBox items don't get drawn.

I've looked around to see if there is a way to 'back up' the clipping 
context/region (or whatever) so that i can modify the clip region in 
OnEraseBkgnd and then restore it at the end but i'm just going round in 
circles.

Can anyone help?

Regards,

Karl. 


0
me5306 (285)
1/18/2005 3:44:42 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1045 Views

Similar Articles

[PageSpeed] 22

me wrote:

>Hi, i've got a tricky problem with an owner-drawn ListBox object.  I'm 
>trying to fix the update flicker so I got some sample code that creates a 
>CDC wrapper around a hidden bitmap which i've used in DrawItem to hide the 
>drawing process (this part works fine in isolation).
>
>The problem is that i also had to override the OnEraseBkgnd method to stop 
>the whole scroll area being erased and as a result I get nasty graphical 
>'trails' of old data that hasn't been erased.
>
>My (not very good) fix for this was to pad the ListBox so there are always 
>enough blank entries to fill the scroll area and also snap the height of the 
>client area to an exact multiple of the item height.  This fix works pretty 
>well but it's not exactly what I had in mind (the scroll bars aren't 
>accurate and there are empty but selectable entries at the end of short 
>list - also if i resize the ListBox i need to re-pad the items).

Right, you definitely need to find another way.

>I saw some other flicker-fix code (for resizing dialog windows) and this 
>used the CDC:ExcludeClipRect function to stop certain bits of the window 
>being erased so I thought it would be pretty neat if i could use 
>ExcludeClipRect to force OnEraseBkgnd to only erase the parts of the ListBox 
>scroll region where there are no items being displayed.
>
>I'm currently trying to get this working in my ListBox class but it seems 
>that when I call ExcludeClipRect in OnEraseBkgnd to exclude the areas where 
>I know the list items are positioned the subsequent calls to DrawItem also 
>use this modified clipping context and my ListBox items don't get drawn.
>
>I've looked around to see if there is a way to 'back up' the clipping 
>context/region (or whatever) so that i can modify the clip region in 
>OnEraseBkgnd and then restore it at the end but i'm just going round in 
>circles.
>
>Can anyone help?

SaveDC/RestoreDC. You could also completely take over OnEraseBkgnd, which
would not be much (any?) harder.

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
1/18/2005 4:20:15 PM
You should not be having a flicker problem at all; how often are you updating it? But in
any case, you can handle it like this:

In OnEraseBkgnd, do the GetTopIndex. Then for i = top index; i < GetCount(); i++, compute
and sum up  the height of each element of the list, using GetItemHeight. If in the process
of computing the height, the height you get exceeds the window size, stop, you have
nothing to do. If you run out of entries before you run out of window, the balance of the
window from wherever you left off to the bottom of the window is what you need to erase.

				joe

On Tue, 18 Jan 2005 15:44:42 +0000 (UTC), "me" <me@here.com> wrote:

>Hi, i've got a tricky problem with an owner-drawn ListBox object.  I'm 
>trying to fix the update flicker so I got some sample code that creates a 
>CDC wrapper around a hidden bitmap which i've used in DrawItem to hide the 
>drawing process (this part works fine in isolation).
>
>The problem is that i also had to override the OnEraseBkgnd method to stop 
>the whole scroll area being erased and as a result I get nasty graphical 
>'trails' of old data that hasn't been erased.
>
>My (not very good) fix for this was to pad the ListBox so there are always 
>enough blank entries to fill the scroll area and also snap the height of the 
>client area to an exact multiple of the item height.  This fix works pretty 
>well but it's not exactly what I had in mind (the scroll bars aren't 
>accurate and there are empty but selectable entries at the end of short 
>list - also if i resize the ListBox i need to re-pad the items).
>
>I saw some other flicker-fix code (for resizing dialog windows) and this 
>used the CDC:ExcludeClipRect function to stop certain bits of the window 
>being erased so I thought it would be pretty neat if i could use 
>ExcludeClipRect to force OnEraseBkgnd to only erase the parts of the ListBox 
>scroll region where there are no items being displayed.
>
>I'm currently trying to get this working in my ListBox class but it seems 
>that when I call ExcludeClipRect in OnEraseBkgnd to exclude the areas where 
>I know the list items are positioned the subsequent calls to DrawItem also 
>use this modified clipping context and my ListBox items don't get drawn.
>
>I've looked around to see if there is a way to 'back up' the clipping 
>context/region (or whatever) so that i can modify the clip region in 
>OnEraseBkgnd and then restore it at the end but i'm just going round in 
>circles.
>
>Can anyone help?
>
>Regards,
>
>Karl. 
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
1/18/2005 6:06:33 PM
Reply:

Similar Artilces:

problems with Outlook client running on the Window2000
Hi guys, My Outlook client runs on Windows2000 SP4 and IE SP1 , office2003. now, there is a serious problem which the IE will appear the message "the page can not be displayed correctly", when i save the e-mail activity in the outlook client. does any one know how to fix it? Jerry ...

Version problem
I've seen that others have a problem opening Publisher files from different versions so it's a popular request, but I'm trying to open a file and I'm not sure what version it was made in (I think 95). I need it for Publisher 2000. Would someone be willing to convert it for me? Thanks, mm I'll convert it, be aware you may lose some formatting. gsauer at columbus dot rr dot com -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "matmorris" <matmorris@discussions.microsoft.com> wrote in message news:0...

Engineering Drawing
I would like to see a check box in the item Engineering Screen to indicate that the current Drawing Group and revision be attached to a PO line for the item during PO creation (and this attachment will NOT change if the current revision/drawings changes). An additional field in the PO line detail would show the attached drawing group, and allow for this to be changed for the item if required (such as an engineering purchase of a new rev, or a purchase of an old rev). The drawing group should be available in the Purchase Receipt detail, the Incoming Quality Module and other related s...

Registry problem
I recently had to reinstall xp and always change the registry so that the number lock is always on as below. I find now since the reinstall the registry won't keep the changes for HKEY_USERS, does anyone have a suggestion? thanks HKEY_USERS\.DEFAULT\Control Panel\Keyboard >InitialKeyboardIndicators = 0 > >HKEY_CURRENT_USER\Control Panel\Keyboard >InitialKeyboardIndicators = 0 Isn't there a setting in the Bios for that? If you enabled it stay on it will. "JT" <grouch_45@hotmail.com> wrote in message news:Swldn.9717$4N4.1...

Help:smart host problem
From: "Damon" <Damon@telus.net> Subject: Date: Friday, April 20, 2007 9:40 PM Hi, now I use SMTP.gmail.com as my smart host. My email is like usename@ mydomian.com. All the send-out email from my exchange server (mydomain.com) by smarthost-SMTP. Gmail.com is marked 'from damonXXXX@ GMAIL.com'! How to set it properly? Thank you.... "Damon" <Damon@telus.net> wrote: >Hi, now I use SMTP.gmail.com as my smart host. >My email is like usename@ mydomian.com. >All the send-out email from my exchange server (mydomain.com) by >smarthost-SMTP...

OWA Problem #13
We are using Windows Server 2003 and Exchange Server 2003. I have one user that can see/read emails when looking in Outlook but then when they use OWA they can't read some of them. There is nothing in common with the emails he can't read either. Some have attachments, some don't, some have subject lines, some don't, etc. He is using Office 2002 - could that be some type of problem? I am not sure why he is the only one that this is happening to. We went as far as downloading his email to a .pst and then deleting and recreating his account and bringing up the .pst...

Problems!!!! ThorConnWndClass
Hi. Every time I use Outlook, it hangs up when I am sending e-mail. This makes it so I cannot use explorer as well. When I restart the computer, I get the message that "ThorConnWndClass" is not responding. Does anyone know what is causing this problem? I am using the XP version. Thanks, Mike. Amazing, I started getting this EXACT same problem today. Have not figured it out yet either. System is sluggish, Outlook hangs a LOT. Constantly rebooting today. Defragged, scanned for viruses, ran the Office fix disk, rebuilt the PST file, deleted a bunch of old message. Am...

YouTube problems
Suddenly I can't get YouTube to work. I get a message from their page, "Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player. " Works with my other user account. Tried downloading "Flash Player." ?? -- Windows Vista Home Premium 64-BIT SP1 Intel Core 2 Duo CPU T5550 @ 1.83GHz 4.00 GB RAM 300 GB HDD We will need far more information that you have provided. What errors do you get when trying to install Flash? Have you turned on Java-script in your browser? Flash player (if you ...

No this is not the problem
I'm saying that the problem is not with the backup, the problem is with the logger (or anything else...) because every few seconds at least I receive a new log of 5MB, because I made a full online backup with the nt tool. Yes, the problem is with the database, that every time that i mount it , it dismount by itself, maybe the problem is with the size, but now i defragmented it and this no resolve the problem, best regards Yanki ysterenfeld@gmail.com wrote: > I'm saying that the problem is not with the backup, the problem is > with the logger (or anything else...) because ever...

problem using pst files with Exchange 2003 Standard
Hi, I am having problem using old Pst files when installing new Exchage 2003 Server. Every one in my organization worked in POP3 with pst files , (Outlook 2000/XP) without any difficults. Now, After I have installed Exchange 2003 Standard Edition, and I moved their old emails trough the pst files into the new Exchange Mailbox, I am having Problem reading those mails. I have moved them using the Outlook Drug and Drop feature or even Import/Export Sometimes. Now, those emails are there, but I just can`t use them. They are become unavailable (Gray Color). Please, help find a solution for th...

Windows AIK problem
My new anti-virus software, ESET NOD32, indicates I can create a bootable rescue disk, and in order to create that disk, I need to install Windows AIK. According to Microsoft's AIK installation instructions, one is supposed to download the AIK files as an image file, to be burned on to a CD. Then, one is supposed run the installation from that CD. After downloading the .iso AIK file to my desktop, when attempting to burn the file to a CD, I get an "error in copying" message, and the process will not continue. Clicking "retry" just results in the same erro...

eraser function in word drawing mode
How do I edit a picture in word (eg: to erase part of the picture)? Is there a eraser function? if so how do I use it?? Hi, Click on the picture and the Picture toolbar should appear. You can turn the toolbar on manually using View > Toolbars > Picture. On the bottom row of the toolbar you'll find selection tools. Use an appropriate selection tool to select an area then use Edit > Cut to remove the selected part. -Jim Quoting from "lawengin" <skho@iinet.net.au>, in article 659b9c2c-f361-4f64-be3c-1e1fb2be6ce3@e32g2000prn.googlegroups.com, on [DATE: > How...

562 problems
I came here looking for an answer for a simple problem. I have the new Outlook 2003 and it will receive email but it won't send. But, I see there are only people here looking for answers. Does anyone have answers? You're using the Web interface to access the newsgroups -- are you clicking the plus sign next to each question to expand the thread and see the replies? (Of course, if you're not, you probably won't see this reply either...) -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup ...

owner of databases
All, Currently, the database owner is set to the person (to the person’s login id - sql login or windows login) who creates the database. In almost all the cases, it is the DBA that creates the databases in our setup. So when “exec sp_help” is executed it lists all the databases on the server along with their owner. As a BEST PRACTICE, who should this owner be set to. The problem with leaving it on the individual users is that when the person quits and if his login is removed the owner shows up as NULL when sp_help is executed. Can it be set to “sa”? Thanks, rgn Ye...

Outlook mouse problems
Hello, folks. After Outlook 2002 has been open for a while (the length of time varies wildly), The tool bar buttons, menu bar, and right mouse buttons stop responding. Moving the mouse over them does nothing. Clicking does nothing. I can still delete a message with the delete key, and still open it from the preview pane by double clicking on the message header, but I cannot forward, reply, etc. (well, I suppose I could if there are shortcut keys for these actions). The only thing I can do is shut Outlook down and reopen it. Then the mouse response returns for a while, before eventually losing...

PropertyPage and control drawing problem...
Hi I have a Property Sheet where I have three property pages. On the third property page I have a CListCtrl and several dynamically created Combo Boxes on the top of it (on the top of list control). If the third page is activated and then I change the control to another program (alt + tab) and then back --> I can't see any of those controls in my property page. If I click list control, I can see the row I just clicked but not all. How and when I should draw those controls again TIA -HS ...

Print Problem
I have Office 2007 running on WXP, printing to an HP Deskjet 932C. I have a Word document that has a custom page size, 5.5w by 8.5 long. However, when I print in portrait it actually prints in landscape and visa versa. It prints fine on normal standard pages, but on the custom it flips portrait and landscape. What gives with this? Mike D. "Michael Dobony" <survey@stopassaultnow.net> wrote in message news:10uu7286ykb1a.kkbxqmx1tip3$.dlg@40tude.net... > I have Office 2007 running on WXP, printing to an HP Deskjet 932C. I have > a > Word document that h...

Problems Pasting Text in Publisher 2003
I have text formatted in Word, and when I paste it into a textbox in Publisher 2003, it looks like tiny, garbled text. None of the paste options bring in the format. The only option that even drops in legible text is "keep text only," which loses the bold, italics, etc. I have created in Word. Any thoughts? Create a text box, right-click the text box, click change text, click text file, browse to your Word document. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Pasting Quagmire" <Pasting Quagmire@disc...

USB CDC ACM driver for windows XP,vista,7
Hi I have one usb cdc acm supported wince device. i want to show this device as virtual com port in PC (Host) side. In PC side, should we write a usb cdc acm driver? or already windows current versions support usb cdc acm driver. does this usb cdc acm driver is enough to show virtual com port in PC? anyone have idea regarding this? thanks in advance. Regards, D. Hi Anybody having idea about usb cdc driver in PC side. Pls help me to start usb cdc driver. Thanks in advance. Regards - D. Hi, On 2010=E5=B9=B407=E6=9C=8804=E6=97=A5 17:00, dsrking wrote: >...

Money has encountered a problem and needs to close (when i launch it !)
Hello people from today when i launch my mony 2004 small business he say Money has encountered a problem and needs to close !! damn the first thing what i have think it a problem with the file (mny) but it seem not !! so i have delete the money and r�install it but its not work !! please help me !! thx a lot... Damn i see on a website this command to tape in the command (or run) regsvr32 msxml3.dll and it's work !! but every time when i launch my computer i need to tape these command regsvr32 msxml3.dll (for money) regsvr32 inetcomm.dll (and this for outllok) What the fuc... wro...

CAsyncSocket problems
Hey, Im currently developing a Server/Client program, I've developed client programs with MFC before, and some server-apps for linux, but never a server-app with MFC. Now I have 2 questions: the first question: which is better: using the CAsyncSocket class, which conveniently has OnReceive and OnAccept functions to respond to various events, or is it better to use treads and to post my own messages (or any other way of communication between the threads)? Second Question: Lazy as I am, I made a server app using the CAsyncSocket class, the problem is this, when I connect to this server th...

Changing Account owner also changes contact owner (and activity owner)
Hi, When I change the owner of an account, CRM also changes the owner of the contacts within that account and changes the owner of the activities that are connected to the contact. Is this behavior by default? (I can't Imagine). Sanne This is the default behavior. This is a nice feature when you lose an employee and need to reassign that employees accounts and all their sub-records to a replacement. Have you tried sharing the account record in question? What is your goal by reassigning the account but not the other related records? - Scott www.easiintl.com Sanne wrote: > Hi, >...

Problem with PO generation
We run HQ with 9 stores and a warehouse. All ordering and receiving is done through a central office location, where the office and a warehouse are located. That warehouse is "Store 10" as far as RMS is concerned. When we generate a PO based on stores' reorder information, we are not getting accurate information, and I'm wondering if it's a limitation of RMS or something I'M doing wrong, both are definite possibilities! We order from some suppliers that require a 2-3 month lead time, so the PO's sit in the system for a long time. We turn in a PO to that compa...

Problem cutting and pasting between Publisher Documents
Hi, I have a 13 page publisher document. Each page has three col's and three rows. Each of these pages have text boxes and photographs. For example on one page I have three stories and pics in three text boxes that fit into each of the colums. When I try to copy all the objects (the entire page) by selecting all, copy and then past to a new publisher document, only the two right side colums copy across and the font changes on the new page. Can anyone help me get this right as I cant find anything other than select all, copy and past in the help section. Thank you Give Paste Spec...

Bizarre problem with Outlook 2002 and .net passport
My Outlook 2002 has suddenly developed a very strange problem. When I create a new message to send and try to select a file as an attachment up pops a .net passport window asking for my details: this happens while the file viewing window is displayed. Really quite bizaree so help appreciated! ...