|
-
April 8th, 2012, 01:14 PM
#1
SetWindowPos v CREATESTRUCT
Ladies and gentleman
This is really just for education on the nuances of MFC.
I was playing around with creating windows of different sizes and positions. Although I can achieve this with SetWindowPos, I have tried a number of times with CREATESTRUCT but it has only worked once for me.
The following work in only one of my projects:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE;
cs.style=WS_OVERLAPPED | WS_SYSMENU | WS_BORDER; // no min/max
cs.x=10;
cs.y=10;
cs.cx=100;
cs.cy=100;
cs.hMenu=NULL;
return TRUE;
}
In all other projects, I can change the style but not the position and size. The only thing I can imagine is that ia dependent on the initial MFC project set-up and what underlying Application is picked. I have experiment but still can't find one that allows the above code to work again. Am I missing something really obvious.
As I said I can affect the changes through SetWindowPos but I would like to understand why CREATESTRUCT doesn't always work. I would also be gratefully if someone could explain when you would consider changing the code in:
BOOL CGridClickView::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
Ben
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
|