Link to home
Start Free TrialLog in
Avatar of scully12
scully12

asked on

Property Sheet with an image displayed on the left side.

I'm making an install wizard and want to put a bitmap on the left side of the property sheet. I'm using the wizard implementation of Property Sheet not the tabs. Using the code below I'm able to get the image displayed but it always shows up on the right side of the property sheet. I tried using MoveWindow to move it but it just crashes. Now, I found some code in another EE post (https://www.experts-exchange.com/questions/10072471/Eliminating-Flicker-in-a-Property-Sheet.html) that I believe is working to move the property sheet to the right. Now, how can I move my picture to the left? I'm doing it this way to avoid the flash that happens when I put the static image on each property page. Good examples please I'm kind of new to this.

BOOL CPropSheet::OnInitDialog()
{
     BOOL bResult = CPropertySheet::OnInitDialog();
     
     CRect rectWnd;
     GetWindowRect(rectWnd);
     SetWindowPos(NULL, 0, 0,
          rectWnd.Width() + 150,
          rectWnd.Height(),
          SWP_NOZORDER | SWP_NOACTIVATE);

     m_picture.CreateEx( WS_EX_CLIENTEDGE, _T("STATIC"), _T("#135"),
                    SS_BITMAP | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
                    rectWnd.Width(), 20, 80, 24, m_hWnd, 0, 0 );

     CenterWindow();

     return bResult;
}

I can upload the code that I have so far to a server if that would help somebody help me.
Avatar of KurtVon
KurtVon

Same idea as what you have here, but you need to move the property pages themselves, too.  Just add the function

void CMyProperyPage::MoveTabs()
{
    CRect rectWnd;

    CWnd* pTab = GetTabControl();
    pTab->GetWindowRect(rectWnd);
    pTab->MoveWindow(SHIFT_RIGHT, 0, rectWnd.Width(), rectWnd.Height(), FALSE);

    CWnd* pPage = GetActivePage();
    pPage->GetWindowRect(rectWnd);
    pPage->MoveWindow(SHIFT_RIGHT, 0, rectWnd.Width(), rectWnd.Height(), FALSE);
}

setting SHIFT_RIGHT to whatever you want to shift by.  Now, the MoveTabs needs to be called right after the SetWindowPos you already have in the InitDialog function above (don't forget to reposition your bitmap).

Also call this function whenever a new page is shown (WM_CHILDACTIVATE).  That should do it.

Avatar of scully12

ASKER

I think you just gave me what I already have. I used the OffsetButtons function from the other EE post like so:

BOOL CPropSheet::OffsetButtons( CPropertySheet* pSheet, CSize& sizOffset )
{
  CTabCtrl* pTabControl = pSheet->GetTabControl( );
 
  for( CWnd* pChild = pSheet->GetWindow( GW_CHILD ); pChild; pChild = pChild->GetNextWindow( GW_HWNDNEXT ))
  {
     if( pChild == pTabControl || pChild == this )
        continue;
     
     CRect rectWindow;
     pChild->GetWindowRect( &rectWindow );
     pSheet->ScreenToClient( &rectWindow );
     rectWindow.OffsetRect( sizOffset );
     pChild->MoveWindow( &rectWindow, TRUE );
  }
 
  return TRUE;
}

What I'm looking for now is how can I move the static picture box that I created on my property sheet to where the property sheet used to be?
ASKER CERTIFIED SOLUTION
Avatar of KurtVon
KurtVon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, it looks like you are correct. You gave me code I didn't even know I needed yet.

I swear I messed with those creation parameters earlier and it didn't do anything. I must have had something else messed up at the time. Thanks,

-scully12