Link to home
Start Free TrialLog in
Avatar of Lewis
Lewis

asked on

Word-like background

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?
ASKER CERTIFIED SOLUTION
Avatar of RONSLOW
RONSLOW

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lewis
Lewis

ASKER

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?
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).

Avatar of Lewis

ASKER

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