• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

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 (http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_10072471.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.
0
scully12
Asked:
scully12
  • 2
  • 2
1 Solution
 
KurtVonCommented:
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.

0
 
scully12Author Commented:
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?
0
 
KurtVonCommented:
It looks like that code offsets the buttons, not the property pages.

Either way, to move your image, just change the creation parameters.  Currently you specify the left to be rectWnd.Width().  Just use RectWnd.left.

Actually, you probably want to get the left edge of the tab control and put the left edge of the tab window there:

GetTabControl()->GetWindowRect(rectWnd);
ScreenToClient(rectWnd);
m_picture.CreateEx( WS_EX_CLIENTEDGE, _T("STATIC"), _T("#135"),
                   SS_BITMAP | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
                   rectWnd.left, rectWnd.top, BITMAP_WIDTH, min(rectWnd.Height(), BITMAP_HEIGHT), m_hWnd, 0, 0);
0
 
scully12Author Commented:
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now