CMainFrame MDI ? Size and Title don't seem to work here

I am new to this doc/view architecture and have only really used dialogs with MFC. Also I have just swithed over to .NET.
I have an MDI app and I can't seem to get the OnSize funtion to work, nor can I update the windowText.

I would normally catch the message for the OnSize/WM_SIZE, then lets just say...use this to set the MainFrame window title.
I tried this: (what am I doing wrong?)

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
      CMDIFrameWnd::OnSize(nType, cx, cy);
      
      CString newTitle;
      newTitle.Format("( %d, %d )", cx, cy);
      SetWindowText(newTitle);
      
}

Just to clarify:
I want to get the onSize from the mainFrame, and set its title.(NOT THE CHILD WINDOWS)
LVL 1
chris rrrsoftware/pipelineAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mahesh1402Commented:
Check if you are calling DefWndProc rather than DefMDIChildProc in the child window's wndproc. You suppose to call DefMDIChildProc in the child window's wndproc.

MAHESH
0
chris rrrsoftware/pipelineAuthor Commented:
I actually don't have any Idea as to how to check that?

here is what I did and it worked:
///////////////////////////////////////////////////////////////////  PREVIOUSLY
.h
...public:
      afx_msg void OnSize(UINT nType, int cx, int cy);
      afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
----------------------------------------------------------------------------------
.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
      ON_WM_CREATE()
END_MESSAGE_MAP()

///////////////////////////////////////////////////////////////////  CHANGED TO
.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
      ON_WM_CREATE()
      ON_WM_SIZE() // added this ?
END_MESSAGE_MAP()

Can someone please explain this to me so I know it for the future... thanks
0
chris rrrsoftware/pipelineAuthor Commented:
Is there a function that will update all docking windows while I am moving. Like UpdateWindow() or something.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

mahesh1402Commented:
That means you have not added message ON_WM_SIZE for your handler function OnSize(). I suggest you to use ClassWizard to do this. Press Ctrl+W to invoke class wizard. Make sure you have selected appropriate class from list. In Message list box double click on WM_SIZE and click on Edit Code button to add code to handler function. Class wizard automatically adds ON_WM_SIZE() message entry in message map. So you need not to do this manually.

MAHESH
0
chris rrrsoftware/pipelineAuthor Commented:
Found RecalcLayout(t/f) thanks.
0
mahesh1402Commented:
>>Is there a function that will update all docking windows while I am moving. Like UpdateWindow() or something.

Have a look at function CDocument::UpdateAllViews().

MAHESH
0
chris rrrsoftware/pipelineAuthor Commented:
mahesh,
I am using .NET. I don't believe that it has Class Wizard. That is what is making this a little uncomfortable for me. I assumed that if I select the class and tell it to create a new messageFunction that it would set it up correctly. I guess not. I really like VC++ 6 (what I am used to) , but this .NET seems really nice to work in (as I get the hang of it). Are you taling about ChildWindows, or MainFrame? I need to update all my docking windows. I will look at UpdateAllViews, but it sounds like it is for the child window views.

what is happening if I only have the afx_msg and no WM_SIZE MessageMap? I still don't totally understand
0
mahesh1402Commented:
>>what is happening if I only have the afx_msg and no WM_SIZE MessageMap? I still don't totally understand

BEGIN_MESSAGE_MAP.... END_MESSAGE_MAP macros are to put messages you need to handle in your message map. Any message in this case WM_SIZE you need to handle you suppose to add message map entry in between this macros. Here you want to add handler for WM_SIZE so you suppose to add ON_WM_SIZE() in MFC. So that OnSize() member function is called by the framework to allow your application to handle a WM_SIZE Windows message.

Its just like similar to handling case WM_SIZE in your WindowProc of your window.

MAHESH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mahesh1402Commented:
if you dont hput ON_WM_SIZE() in your message map then your OnSize() will never get called as it will not understand on which event it suppose to call OnSize as OnSize is mapped to WM_SIZE.

MAHESH
0
mahesh1402Commented:
>>I am using .NET. I don't believe that it has Class Wizard. That is what is making this a little uncomfortable for me

Here its how to do in .NET :

In your project Select From menu View->Class View. Right Click on class name and select properties. In Right pane you will see Properties of class. Click on Messages button which is located at position 5th Button from left. Now you will see All messages. Click on list box in next to WM_SIZE where you will be able to select <Add>OnSize

Now it will let you add code for handle function OnSize.

MAHESH
0
chris rrrsoftware/pipelineAuthor Commented:
Hmmm,
Thats exactly what I did. Usually it seems to do it, I am using .NET for the first time and don't really know exactly how it does everything. Seems like it messed up then, it put the afx_msg code in, but not the ON_WM message Map. Thanks.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.