-
January 7th, 2013, 04:47 PM
#1
How to create MDI child with borders
How can I create MS Word 'print layout' like interface. The attached picture says it all. Basically I want a shaded area around my document just like word so it gives a feel of the 'page'.
I was hoping I can override some function somewhere and along that lines tried playing around with below but that didn't help.
Code:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWndEx::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = 250; // just playing around with size
cs.cy = 250;
return TRUE;
}
Any ideas how can I do that?
-
January 8th, 2013, 06:47 AM
#2
Re: How to create MDI child with borders
Use Spy++ to obtain this window class (which is _WwG in the case of Word 2003) and its properties.
Victor Nijegorodov
-
January 8th, 2013, 07:44 AM
#3
Re: How to create MDI child with borders
There isn't a windows style for this. What you are seeing is all done by custom Paint code.
-
January 8th, 2013, 10:20 AM
#4
Re: How to create MDI child with borders
It would seem that it is just a matter of creating smaller view inside the frame and than maybe I can handle no client area messages to further customize but apparently the view automatically occupies all the client area. I was hoping the following override will do the trick
Code:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
lpcs->cx = 500; // again playing with numbers
lpcs->cy = 400;
lpcs->x = 50;
lpcs->y = 50;
return CFrameWndEx::OnCreateClient(lpcs, pContext);
}
Again no use.
I also tried to override Create()
Code:
BOOL CToolsView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CRichEditView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
and here rect is passed which is all 0,0,0,0 and I tried to change but it has no effect.
-
January 8th, 2013, 10:40 AM
#5
Re: How to create MDI child with borders
Originally Posted by VictorN
Use Spy++ to obtain this window class (which is _WwG in the case of Word 2003) and its properties.
I did that but the properties doesn't tell me much. It's style is WS_CHILDWINDOW, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, I am more after how to create this.
-
January 8th, 2013, 10:55 AM
#6
Re: How to create MDI child with borders
Originally Posted by zspirit
I did that but the properties doesn't tell me much. It's style is WS_CHILDWINDOW, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, I am more after how to create this.
Well, every window is created using one of the APIs like ::CreateWindow, ::CreateWindowEx, ...
Note however, that this _WwG window is NOT a View (not derived from MFC CView class), And as OReubens already wrote you:
Originally Posted by OReubens
There isn't a windows style for this. What you are seeing is all done by custom Paint code.
Victor Nijegorodov
-
January 8th, 2013, 11:55 AM
#7
Re: How to create MDI child with borders
or to put it in other terms with MFC.
This is a regular CView or CScrollView where YOU provide the entire client area painting.
For getting something similar to what you are seeing in word, this would amount to something along the lines of:
Code:
CMyView::OnDraw(CDC* pDC)
{
PaintEntireViewInGray(pDC);
PaintTheWhitePaper(pDC);
PaintTheShadowAroundTheWhitePaper(pDC);
PaintTextInsideWhitePaper(pDC, "As you can see the document is enclosed in a shaded border area. How can I do this?", "Calibri", 14);
}
Now all you have to do is fill in the details of those 4 functions. (And yes, this'll take time to develop).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|