?
Solved

Word-like background

Posted on 1997-05-14
4
Medium Priority
?
208 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 400 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 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