Solved

Word-like background

Posted on 1997-05-14
4
199 Views
Last Modified: 2013-11-20
How do I get a view that looks like that provided by
Microsoft Word.
There you write on a nice white sheet of paper in front
of a gray background.
The Visual C++ document-/view architecture offers a view
with its origin in the upper left corner of the parent
window. What is the best (preferred) way to move the
point (0,0) a bit down and to the left, and how do I get
the gray background.
I tried to change the x and y elements of CREATESTRUCT
within the PreCreateWindow of my ScrollView, but it
somehow didn't work!?
Another way might be painting the whole thing
(OnEraseBkgnd with a white Rectangle over it, shifting
the ViewportOrg), but this seems to be a bit primitive!
So, how do they do it at Microsoft?
0
Comment
Question by:Lewis
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
Comment Utility
There is no built-in support in Windows for a white drawing page with grey surrounds - it's up to you to paint it that way.

You fill the area around your "page" with the grey background color (use ::GetSysColor(COLOR_APPWORKSPACE) to find out the color).  You fill the "page: itself with the white color (use ::GetSysColor(COLOR_WINDOW) for this). The draw your text/graphics over this.

CScrollView has a routine (FillOutsideRect()) for filling outside the page you define - you can use this in your OnEraseBkgnd to do the grey background - but you still need to paint the inside of the page white (as above).

Of course, for smooth appearance, you would use an off-screen bitmap (ie. create a dc for the bitmap, draw inot it, then BitBlt it onto the view). You would also only redraw the rectangle which needs it (use GetClipBox()).

Let me know if you require any further details on this.

0
 

Author Comment

by:Lewis
Comment Utility
Could you provide the exact code necassary?
What functions are affected (OnEraseBkgnd, OnDraw,...)?
How to move (0,0) so that future drawing commands will
not have to worry about any offsets?

Apart from that, could you explain the last paragraph
(off-screen bitmap) more closely?
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
I'll check for sample code for you - it'd be tricky sending you my own code becuase of all the other things that happen would confuse the issue - but I'm sure I can find a smaple that shows you how to use FillOutsideRect within OnEraseBkgrnd (check the on-line help for FillOutsideRect for a starting point).

OnDraw should fill the area in which your page is defined ([0,0]..[maxx,maxy]) with the current window colour then draw your other stuff on top.  OnEraseBkgrnd should fill outside the rect with the appworkspace color.  You can use SetWindowExt,SetViewportExt etc function with MM_ANISOTROPIC to define how your logical page space maps onto the client area (pixels) of the window.

I will try to send you some code on off-screen bitmaps.  The idea is that in your OnDraw you create a compatible bitmap (using the size of the GetClipBox to limit it if you want).  You create a DC and select the bitmap into it, the do your drawing into THAT dc instead of the one passed into OnDraw.  When finished, flush the GDI and use BitBlt to copy from the bitmap dc onto the view dc in one hit, avoiding any flicker.

Anyway, I'll see what I can dig out for you - okease give me your eMail address as it is very tricky posting long code smaples here (I can eMail you a ZIP instead).

0
 

Author Comment

by:Lewis
Comment Utility
Hi,
did you dig out anything for me? Sorry for asking again,
but I have a deadline to meet in three weeks.
Lewis
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now