Screen flashing using BeginPaint(), DrawText(), EndPaint() - why?

I made a grid using CStatics to display text data and it works great.  Now I'm trying to paint the text on the CDialog in it's OnPaint() member function.  I am getting screen flashing/flickering when I use this method during repetitive screen updating (like when you hold down pgdown to scroll through records).  Why?  Here's the method I'm trying

//  in OnPain

PAINTSTRUCT ps1
CDC *dc1

dc1 = BeginPaint(&ps1);

for (i=0;i<rowmax;i++
for (j=0;j<colmax;j++

dc1->DrawText(m_str1,16,&m_r1,0)

EndPaint(&ps1);


Also, how to you set the font for a DC?  I just can't figure out how to

Thank you.
0
anonymous (74732)
4/30/2004 9:56:03 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
609 Views

Similar Articles

[PageSpeed] 45

> Also, how to you set the font for a DC?  I just can't figure out how to.

This is how you get the font that the dc is using.

 // Get the font
 CFont *pFont, *pOldFont;
 pFont = GetFont();
 pOldFont = dc.SelectObject(pFont);


0
ks2057 (125)
4/30/2004 10:09:14 PM
Thank you KS

I found that I need bRedraw=FALSE for the flashing to go away

Invalidate(FALSE) or Invalidate(&m_rect,FALSE) fixed this for me.  :)
0
anonymous (74732)
5/1/2004 12:01:04 AM
You should not be painting onto a dialog in its OnPaint handler. 99.99999% of the time
when somebody tries this, it is because they have made a mistake. 

Put a static control on, subclass it, and paint on it. I have yet to run across a
situation in which painting directly on the dialog makes sense, except for a global change
in the background color of the dialog, usually handled in OnEraseBkgnd.
					joe

On Fri, 30 Apr 2004 14:56:03 -0700, "Yasoo" <anonymous@discussions.microsoft.com> wrote:

>I made a grid using CStatics to display text data and it works great.  Now I'm trying to paint the text on the CDialog in it's OnPaint() member function.  I am getting screen flashing/flickering when I use this method during repetitive screen updating (like when you hold down pgdown to scroll through records).  Why?  Here's the method I'm trying:
>
>//  in OnPaint
>
>PAINTSTRUCT ps1;
>CDC *dc1;
>
>dc1 = BeginPaint(&ps1); 
>
>for (i=0;i<rowmax;i++)
>for (j=0;j<colmax;j++)
>{
>dc1->DrawText(m_str1,16,&m_r1,0);
>}
>EndPaint(&ps1); 
>
>
>
>
>Also, how to you set the font for a DC?  I just can't figure out how to.
>
>Thank you.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15977)
5/2/2004 10:56:19 PM
Reply:

Similar Artilces:

Outlook Web Access
Hi Can anybody help me with some simple instructions on how to customise the login screen on Outlook Web Access...? I've found a number of "planetary" explanations, but if there are any simple ones out there..?, that would be great... Any help apprciated Colin (PS - I'm okay with Frontpage..) ...

Use of "--" in functions??
I'm new to compiling and using functions of anything other than a relatively simple basis. I've been reading a lot of questions and answers on this group and am amazed at some of the complex functions that can be built up. I am starting to understand most of them but keep seeing "--" used in functions - why is this used? Does it only apply to certain functions? I've tried typing the some of the functions posted without them because I thought they may just have been used to clarify the structure of the function but have noted that the end result is different with and w...

why does my screen keep freezing up on me
every so often my screen freezes,after about 20 or 30 seconds it comes back on, anyone know how to resolve this? Do you see anything on the status bar (bottom of Excel Window) like "Saving Files" Unfortunately Excel will not do this when you are away from your PC but waits for you to do something in Excel before checking to see if it is time to save -- in other words when you are busy. Tools, Autosave (bring up the item) --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: ...

Too many USER Objects being used
I have an application that loads in ActiveX "control panels"( about 25) in tabs, and within each ActiveX "control panel", and it has probably 25-50 ActiveX controls(components). This is, I believe, creating too many USER Objects, and depending on what is running on the system currently, makes it so the application cannot startup. It often fails on a call to GetControlUnknown() when trying to get handles to the ActiveX components in a particular ActiveX "control panel". Anyone have any ideas on how to bring down the number of user objects. I am unable to do any...

How to stop screen so i can read blue screen message
Hi, I have XP pro and it has started to keep on rebooting at start up with a flash of a blue screen message which I can't read as it is so fast. It boots up with the Windows logo screen and the blue lines showing it working for a few seconds but then it goes black and then the blue screen flashes and it then reboots to the same thing again. How can I read that blue screen and how can I see what it wrong and fix it. Thanks oz "rock" <1940@pobox.com> wrote in message news:#bLvKtrpKHA.5760@TK2MSFTNGP02.phx.gbl... > Hi, > > I have XP...

Bringing variables from Excel to be used in Microsoft Query
I just started using Microsoft Query and it looks like it does a good job. However, I want it to pass over a special number that represents the number of seconds after 1/1/1970. What I do is create the value using date functions to get the current date then subtract and multiply to get the value. Now I'm trying to figure out how to modifiy Microsoft Query to read that value that's in that cell. Anyone know how I can do that? ...

Screen Size
How do I get my webpage to automatically resize to fit everybodys screen? Thanks, Scott By using a percentage width in your body table rather then a fixed width. Something you can only do with a actual html editor/web design tool. Publisher has zero support for this. This is covered in the FAQ - http://www.publishermvps.com/Default.aspx?tabid=30 David Bartosik - [MSFT MVP] www.publishermvps.com www.davidbartosik.com "Scott" <scott.tuttle@delta.com> wrote in message news:0a8801c4d8ca$15508b50$a301280a@phx.gbl... > How do I get my webpage to automatically resize to ...

Compile error using CTypedPtrList
Hi, I am having problems at compile time using the following line: CTypedPtrList<CPtrList, CString*> m_ClientList ; When compiled I get the following errors: emailcfgdlg.h(114) : error C2143: syntax error : missing ';' before '<' emailcfgdlg.h(114) : error C2501: 'CTypedPtrList' : missing storage-class or type specifiers emailcfgdlg.h(114) : error C2059: syntax error : '<' emailcfgdlg.h(114) : error C2238: unexpected token(s) preceding ';' I am using the version 6 of the compiler with SP5. Now I think this is something to do with the c...

Using secured OMA
Hi, Please help me with my misunderstanding. When I try ro connect by t68i or z600 (WAP 2.0) to OMA directly with SSL required, using mydomain.com/oma, of course, I get 403 error. When I use https://mydomain.com/oma I get "Couldn't reach the indicated web server." altough it works fine with Pocket PC. What's wrong? What should I configure to establish secured connection from mobile phone? Best regards, Vit Knyshevich. "Vit Knyshevich" <abuse_vit_knysh@hotmail.com> wrote: >Please help me with my misunderstanding. When I try ro connect by t68i or >z60...

Splash Screen & Login Screen
Is there any way to modify the images on the Splash Screen, or the Login Screen to make it more branded to our company? Thanks! ...

Using resources, how to ?
Hi guys, I am using MS Visual Studio 2005 Express ( yes, the one that u can download for free from MS website ) and I have a "little-big" problem with my program. First of all let me say that I created a simple console program, with his main and few functions, and I wish that my ..exe file can drop another .exe when launched. The other exe is another compiled program, and I wish to handle it from my main program as resource. There are some topics about handling resources, but I cannot find anything of good; I know how to use LoadResource, FindResource, etc, but both fail since I am...

scatter plots using pivot table data
In older versions of Excel, you could directly create xy scatter plots using pivot table data. In Excel 2000, the chart wizard says you can't use an xy scatter plot with pivot table data. Why????? Is there any way around this limitation? Dan - Don't tell the pivot table you're making a regular chart. Select a cell away from the PT and start the chart wizard. Select the XY Scatter type you want in step 1. In step 2, use the Series tab to select the ranges for the names, X values, and Y values of each series in your chart. Make sure you don't select one of the PT but...

Using two pictures from clipart as my background
I can't seem to get more than one clipart as my background. When I try to add another one, it overrides the first one. I want two pictures, each on half the page, and faded. Thanks. On Jan 13, 7:31=A0pm, Michele <Mich...@discussions.microsoft.com> wrote: > I can't seem to get more than one clipart as my background. When I try to= add > another one, it overrides the first one. I want two pictures, each on hal= f > the page, and faded. Thanks. You can place multiple pictures on your slide (or slide master), but each slide can only contain one as it's ...

How to use interfaces
Hi ... How can you show in an UML diagram using visio that you have 1 class who uses the interface implementet by another ?? ex: C# public class MyClass : ImyInterface { //some code } //And then in another class you will do something like: private ImyInterface imi = new MyClass(); can you show this via UML shapes in Visio ?? thanks in advance ... -- ------------------------------- Med Venlig Hilsen Tonni Schm´┐Żcker Tonni@cool.dk ...

How can I find out which apps are using .NET and which not?
I appear to have three versions of .NET (2, 3, 3.5) with their associated special packs. How can I find out which apps are using .NET. (Please, no 'cut-one-out' method, I do not want to uninstall and see what has stopped working.) I am aware that the different .NETS are individually and separately usable by different apps - my questions is what app uses which? Thanks for any pointers occam wrote: > I appear to have three versions of .NET (2, 3, 3.5) with their > associated special packs. > > How can I find out which apps are using .NET. (Please, no 'c...

Excel 2002 Changes Screen Resolution
When Excel 2002 launches, it changes the screen resolution to 640x480. How do I get it to stop this? That's new one! Just to be sure that it is Excel, and not something that is loading with Excel, from Start->Run enter "Excel /s" (no quotes) and press Enter. This is "safe mode" where nothing extra runs. If it doesn't happen then you know it's an add-in or something auto-loading from ,say, XLSTART. -- Jim Rech Excel MVP "Sheila B" <anonymous@discussions.microsoft.com> wrote in message news:5c7401c42d7e$a9db5770$a001280a@phx.gbl... ...

Touch Screen Department & Categories
I have a need to setup Touch Screen in RMS. But I need to be able select a Department and then have an additional prompt of a catagory. Right now the way RMS works is you can only have RMS setup so you can see all Departments but then that gives you a long list of every item in that department. We want to break it down into further sub-groups. I know that RMS doesn't do this out of the box but if any one has any ideas on how to accomplish that woule be great. David We have an RR Touch module that will do this for you and more. Contact me if you wish to try this. Afshin Ali...

Reading xlsx using fso -logic..
I am reading an excel spreadsheet that has data starting from line 3 and store it in Access 2007 database. It has coulmn names but they are not relavant so I want to skip them and assign a different name. There are around 250 columns so I am just trying to read a few columns to test my code. I don't wan to use transferdb as there are format issues. Ex: Age has 6 mo. as well numeric data so 6mo coming out missing. My temp_str shows all junk character any idea? Private Sub readxl() Dim fso As New FileSystemObject Dim Tst As TextStream Dim strline As String Dim...

Just setup outlook using my Yahoo, my messages disappeared in yaho
I just set up my outlook with my yahoo account, i have done this before with msn and i was still able to access my hotmail account and receive emails at both, they synced up. Now i go to yahoo and all of my messages are gone, can i get them back? What do I do? "Brooke" <Brooke@discussions.microsoft.com> wrote in message news:52C631D4-A414-4F7D-B3E6-5FE1A668F52F@microsoft.com... >I just set up my outlook with my yahoo account, i have done this before >with > msn and i was still able to access my hotmail account and receive emails > at > both, they synced ...

Windows 7 upgrade Blue Screens my laptop. Maybe because of ATI?
Laptop's a Gateway NV52 with Vista Home Premium 64-bit. I'm upgrading to Windows 7 Home Premium 64-bit. I ran the Upgrade Advisor and it told me to uninstall ATI Catalyst Install Manager, which I did. I put in the upgrade disk, and after Phase 1 (3 total phases), it had to restart to begin Phase 2. After the Gateway logo screen, it blue screened on me. The error code was 0x7b. It didn't even do the whole mini dump thing it usually does when it blue screens. It never even makes it to the Welcome scene (where the green bar is loading on the black screen, not the Vista wel...

POS screen is invisible
Our POS froze the screen was restarted and for some reason the user name and password entry box was in the upper left hand corner of the screen and once logged in the POS screen is invisible. We can still scan in items but we can not see what we are doing. We are in the middle of a huge holiday with no POS screen to work from. Help. We have restarted the company 5 times and no change. We can access the Manager with no problem. James Harris Harris & Clark - thoughtful Grocery and Food School www.harrisclark.com This is a multi-part message in MIME format. ------=_NextPart_000_0022_0...

transfer exel report to a usb flash drive F
transfer exel doc.to new flash drive 2.0 *SAVE* to your hard drive, THEN, Use Windows explorer to *COPY* to the flash drive! *DON'T* save to the flash drive! -- HTH, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! --------------------------------------------------------------------------- "rexdaleyou" <rexdaleyou@discussions.microsoft.com> wrote in message news:E141BFCD-FA4C-4C6E-97DE-20300EDCAACF@microsoft.com... > transfer exel doc.to new flash drive 2.0 C...

How does E2K SP2 backup without using PAT files?
Hello I read an article about how E2K SP2 does not use PAT files to avoid the problems of missing or corrupted PAT files preventing hard recovery. However, the article did not explain what alternative mechanism is used in place of PAT files. Can anyone provide a detailed explanation for this? Thanks Aftab Khan ...

tab stops.. moving to the next control using code...
I have a number of controls on my form, set with tabindexs and tabstop set to true. My application runs on a touch screen, and I want the focus to move from one control to the other when the user pushed a button. Is there a way to move the focus to the next control based on its tabstop being the next highest ? thanks Am 13.05.2010 15:36, schrieb AussieRules: > I have a number of controls on my form, set with tabindexs and tabstop set > to true. > > My application runs on a touch screen, and I want the focus to move from one > control to the other when ...

Print Screen using dual screens?
I have recently set up to use dual screens.....this is great for productivity! If I now do a PrtScn, however, I get the screen shot of both monitors. Is there any clever way of achieving the screen shot only of one, or the other screen? Al Al wrote: > I have recently set up to use dual screens.....this is great for productivity! > > If I now do a PrtScn, however, I get the screen shot of both monitors. Is > there any clever way of achieving the screen shot only of one, or the other > screen? > > Al By design, as it has always been with ...