Solved

Word-like background

Posted on 1997-05-14
4
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
ID: 1301551
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
ID: 1301552
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
ID: 1301553
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
ID: 1301554
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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