Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » AfxRepositionWindow question Collapse All
Subject Author Date
tera t Jun 18, 2008 - 7:27 PM

Hello.


Please teach how to use if you like.




In addition, will following how to use be permitted, too?


lpLayout->rect.top    = 0

lpLayout->rect.bottom = 100

lpLayout->rect.left   = 0

lpLayout->rect.right  = 1000


CRect rcOwnLayout1;

rcOwnLayout1.top    = 0

rcOwnLayout1.bottom = 100

rcOwnLayout1.left   = 0

rcOwnLayout1.right  = 500


::AfxRepositionWindow(

 lpLayout,

 m_pDialog1->m_hWnd,

 &rcOwnLayout1

);


CRect rcOwnLayout2;

rcOwnLayout2.top    = 0

rcOwnLayout2.bottom = 100

rcOwnLayout2.left   = 501

rcOwnLayout2.right  = 1000


::AfxRepositionWindow(

 lpLayout,

 m_pDialog2->m_hWnd,

 &rcOwnLayout2

);


best regards


 

Technical Support Jun 22, 2008 - 1:24 PM

The AfxRepositionWindow() function is an internal function in MFC. It does exactly the same as the DeferWindowPos() Win32 API does. The only difference is that the AfxRepositionWindow() function is using its own parameters based on a AFX_SIZEPARENTPARAMS data structure. Both APIs should be invoked between the BeginDeferWindowPos() and EndDeferWindowPos() Win32 APIs. If you forgot to invoke the n BeginDeferWindowPos() and EndDeferWindowPos() Win32 APIs, both AfxRepositionWindow() and DeferWindowPos() APIs will do nothing.

tera t Jun 22, 2008 - 6:51 PM

Thank you for an answer.

Does not AfxRepositionWindow have the function to occupy a domain of MainFrame?

Technical Support Jun 23, 2008 - 3:53 AM

The ::AfxRepositionWindow() API is used by child windows of the MFC frame window to take up some parts of frame side by side. The rest free space in the center is automatically used by a window with the dialog control identifier equal to AFX_IDW_PANE_FIRST. This is a view window in SDI frames and an MDI client area window (dark gray window, parent for MDI child frames) in MDI frames. The ::AfxRepositionWindow() API is typically used by MFC/Prof-UIS control bars to take up some parts of the frame window. But it’s possible to make any kind of window to occupy the required space inside the MFC frame window or even any other window.

Some more details. When the windows inside the frame window or other window should be repositioned, the CFrameWnd::RecalcLayout() method is invoked in the case of frame windows and the CWnd::RepositionBars() method is invoked in the case of any other windows. In fact, invocation of the CFrameWnd::RecalcLayout(); code is the same as invocation of the CWnd::RepositionBars( 0, 0xFFFF, AFX_IDW_PANE_FIRST ); code. So, the CWnd::RepositionBars() method walks through all the child windows which have dialog control identifiers in the specified range (0 ... 0xFFFF). The CWnd::RepositionBars() method can be used for repositioning child windows or only for computing the free central space. It sends the WM_SIZEPARENT message (internal message in MFC) to all the enumerated child windows and each child window handles it. You can see how this message is handled by Prof-UIS classes. For instance, the CExtTabWnd tab window handles this message in the CExtTabWnd::OnSizeParent() method and that is why MDI tabs are able to occupy the required space inside the MDI frame window. The CExtTabWnd control is able to take up the part of its parent window on left/right or at top/bottom. You can code your own window and it can be derived from any class. You window class should handle the WM_SIZEPARENT message in the same way as the CExtTabWnd::OnSizeParent() method does. Please note, the position of the window which handles the WM_SIZEPARENT message is also dependent on its Z-order.

Even some more examples. Several dialog classes in the <span class="newgreen">ProfUIS_Controls</a> sample application use the CWnd::RepositionBars() method in order to place child control bar windows near the dialog border. The CExtPropertyGridCtrl class works like an MFC frame window: the combo box bar, a toolbar and a help tip bar inside it are repositioned using the CWnd::RepositionBars() method. All CExtGridWnd-derived classes in Prof-UIS implementing grid controls also work like MFC frames and toolbar windows created as grid children will be repositioned for occupying required space near grid window borders. Even the CExtScrollBar windows created inside the CExtGridWnd window are moved to required scrollbar locations near grid borders using the WM_SIZEPARENT message and the CWnd::RepositionBars() method.