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 » PageContainer Example (dynamically stretch in length) Collapse All
Subject Author Date
Dominik Braendlin May 16, 2008 - 1:05 AM


Hi


I have adapted the PageContainer example to work within my project.


If I change the size of the PageContainer window the pages will stretch in width. Is there an easy way to also have them stretch in height? I would like to avoid the scrollbar within a pageitem.




Imagine you display a picture on one of the pageitems e.g. in a dialog. I would like to stretch this on in width and height. Not only in width.


Best regards


Dominik Braendlin May 26, 2008 - 1:22 AM

Thanks for your help. It works.

Dominik Braendlin May 26, 2008 - 1:21 AM

Thanks for your help. It works.

Dominik Braendlin May 20, 2008 - 12:34 AM

Concerning my request about the PageContainer. Please have a look at the PageContainer example especially at the “Custom-drawn page container” which is the free floating window within this demo. Focus on the first part called Dialog including the Label, Check1, Check2 and Check3 items. If you stretch the window horizontally these items are stretched accordingly. If you stretch the window vertically the items are not stretched at all. Imagine instead of the Label, Check1, Check2 and Check3 items you have a picture in the Dialog item. If you stretch the window horizontally the picture could always have the same width as the window.

That is where my problem starts to arise. If the picture gets stretched in width it should also be stretched in height. Since the height of the dialog keeps the initial height the picture has no room to gain in height. As I stretch the window horizontally I would need the Dialog item to be stretched in height as well as in width. Therefore the other items such as “Custom-drawn Shortcut List Window”, “Listview Control” and “Web Browser Control” should dynamically move up or down, depending on the space I need for my Dialog item.


Please let me know if there is a way to solve my picture issue.

Best regards

Technical Support May 16, 2008 - 1:47 PM

The CExtPageContainerWnd class supports two types of the layout behavior:

1) Like in Outlook 98/2000/XP. Only one page is expanded and it’s stretched to the entire available height. Other pages are collapsed. The scrollbar like area is never used.

2) Like in 3D Studio MAX. Many pages can be expanded and/or collapsed at the same time. Scrollbar like area is available.

The PageContainer sample provides both options (available from the menu). Please let us know whether you need the Outlook mode or you are looking for some other layout which has not been implemented yet?

Dominik Braendlin May 20, 2008 - 12:35 AM

Concerning my request about the PageContainer. Please have a look at the PageContainer example especially at the “Custom-drawn page container” which is the free floating window within this demo. Focus on the first part called Dialog including the Label, Check1, Check2 and Check3 items. If you stretch the window horizontally these items are stretched accordingly. If you stretch the window vertically the items are not stretched at all. Imagine instead of the Label, Check1, Check2 and Check3 items you have a picture in the Dialog item. If you stretch the window horizontally the picture could always have the same width as the window.



That is where my problem starts to arise. If the picture gets stretched in width it should also be stretched in height. Since the height of the dialog keeps the initial height the picture has no room to gain in height. As I stretch the window horizontally I would need the Dialog item to be stretched in height as well as in width. Therefore the other items such as “Custom-drawn Shortcut List Window”, “Listview Control” and “Web Browser Control” should dynamically move up or down, depending on the space I need for my Dialog item.


 


Please let me know if there is a way to solve my picture issue.



Best regards

Technical Support May 20, 2008 - 12:14 PM

The custom drawn page container uses a 3D Studio Max layout and behavior. The mutual layout of page windows is computed according to the real height of each window. The page container control can change the width of all pages but can never change their height. So, if you need some page window with an automatically adjustable height, you should handle the WM_SIZE message in this page window, compute the required height according to the changed width and let the window resize itself vertically using the SetWindowPos() or MoveWindow() APIs if needed. If the page window resizes itself vertically and its window has the WS_VISIBLE style (i.e. the page is not contracted), the page container’s CExtPageContainerWnd::UpdatePageContainerWnd() method should be invoked to re-compute the mutual layout of all page windows. You can simply invoke

( STATIC_DOWNCAST( CExtPageContainerWnd, GetParent() ) ) -> UpdatePageContainerWnd();
from the WM_SIZE message handler of your page window after it has adjusted its height using the SetWindowPos() API.

Dominik Braendlin May 22, 2008 - 3:22 AM

I‘ve been trying to use your latest suggestions, but I was not successful. Should I call UpdatePageContainerWnd with false or true? If I call the SetWindowPos within WM_SIZE of the panel it triggers a new WM_SIZE.

In order to save time, I would like to ask you, if you could extend the PageContainer example program with the behavior I am looking for. In my case the height of the panel under Dialog with the Label, Check1, Check2 and Check3 should always have the same length as the width (width == height). As you drag the “Custom-draw page container” the Dialog panel should grow or shrink in height accordingly.

Technical Support May 23, 2008 - 6:33 AM

A sample test project is not a problem. Please find then following line in the MainFrm.h file in the PageContainer sample (it’s a property of the CCustomDrawnPageContainer class):

    CListCtrl m_wndPage2;
Then please replace the line of code above with the following code:
      class CMyListCtrl : public CListCtrl
      {
      public:
            INT CalculateDesiredHeight()
            {
                  ASSERT_VALID( this );
                  ASSERT( GetSafeHwnd() != NULL );
                  CRect rcClient;
                  GetWindowRect( &rcClient );
                  // for testing, we will make height of this list view common
                  // control equal to its width, i.e. it will have square shape
                  INT nDesiredHeight = rcClient.Width();
                  // ... or you can uncomment next line to make height equal 2/3 of width
                  // nDesiredHeight = ::MulDiv( nDesiredHeight, 2, 3 );
                  return nDesiredHeight;
            }
      protected:
            void CheckHeight( bool bUpdateNow )
            {
                  ASSERT_VALID( this );
                  ASSERT( GetSafeHwnd() != NULL );
                  CRect rc;
                  GetWindowRect( &rc );
                  INT nCurrentHeight = rc.Height();
                  INT nDesiredHeight = CalculateDesiredHeight();
                  if( nCurrentHeight != nDesiredHeight )
                  {
                        if( bUpdateNow )
                        {
                              // we assume this CMyListCtrl window is always created as
                              // child of the CExtPageContainerWnd window in scope of this project
                              CExtPageContainerWnd * pWndParent =
                                    STATIC_DOWNCAST( CExtPageContainerWnd, GetParent() );
                              rc.bottom = rc.top + nDesiredHeight;
                              pWndParent->ScreenToClient( &rc );
                              //MoveWindow( &rc ); // even this is not needed
                              LONG nPageIndex = pWndParent->PageFind( m_hWnd );
                              ASSERT( nPageIndex >= 0 );
                              CExtPageContainerWnd::PAGE_ITEM_INFO * pPII = pWndParent->PageGetInfo( nPageIndex );
                              ASSERT( pPII != NULL );
                              pPII->SetRectInitial( rc ); // sorry, we forgot about this one thing
                              pWndParent->UpdatePageContainerWnd( true );
                        }
                        else
                              PostMessage( WM_USER+321 );
                  }
            }
            virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
            {
                  LRESULT lResult = CListCtrl::WindowProc( message, wParam, lParam );
                  switch( message )
                  {
                  case WM_SIZE:
                        CheckHeight( false );
                  break;
                  case (WM_USER+321):
                        CheckHeight( true );
                  break;
                  }
                  return lResult;
            }
      };
      
      CMyListCtrl m_wndPage2;
As a result, the list control that uses the 32x32 icon mode in the custom drawn page container window will behave like you need. The CMyListCtrl class is close to the approach we suggested you in our previous answer. We just forgot about the SetRectInitial() API invocation and protecting the message loop overflow with delayed layout updating.

You can also download a modified version of the PageContainer sample with the improvements described above.