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 » Problem about CExtPPVW Collapse All
Subject Author Date
Jia Hong Li Apr 5, 2007 - 2:43 AM

Hi, tech.
How can I disable and hide some default buttons on control bar in the print preview mode when I use CExtPPVW?
Thanks...
ˆ_ˆ

Suhai Gyorgy Apr 5, 2007 - 3:33 AM

Hi!
If your class is of template CExtPPVW, then you can reach that toolbar with m_pWndPP->m_pPpvWndToolBar.
Best place to change the toolbar is if you override virtual void OnInitializePrintPreviewToolBar() method. In it, first call base class method, then you can customize toolbar. The default commands of the toolbar, if we look in ProfUIS resource file:

IDR_EXT_TOOLBAR_PPW TOOLBAR DISCARDABLE 16, 16
BEGIN
BUTTON ID_EXT_PPV_PREV
BUTTON ID_EXT_PPV_NEXT
BUTTON ID_EXT_PPV_PAGE_MODE_1
BUTTON ID_EXT_PPV_PAGE_MODE_2
BUTTON ID_EXT_PPV_PAGE_MODE_3
BUTTON ID_EXT_PPV_PAGE_MODE_4
BUTTON ID_EXT_PPV_PAGE_MODE_5
BUTTON ID_EXT_PPV_PAGE_MODE_6
BUTTON ID_EXT_PPV_PAGE_MODE_7
BUTTON ID_EXT_PPV_VIEW_MODE_FIT_WIDTH
BUTTON ID_EXT_PPV_VIEW_MODE_FIT_HEIGHT
BUTTON ID_EXT_PPV_VIEW_MODE_FIT_PAGES
BUTTON ID_EXT_PPV_VIEW_MODE_MAGNIFY
BUTTON ID_EXT_PPV_VIEW_ZOOMIN
BUTTON ID_EXT_PPV_VIEW_ZOOMOUT
BUTTON ID_EXT_PPV_SHOW_MARGINS
BUTTON ID_EXT_PPV_SETUP
BUTTON ID_EXT_PPV_PRINT
BUTTON ID_EXT_PPV_CLOSE
END

But checking code of default OnInitializePrintPreviewToolBar() method (in exprint.cpp, look for CExtPPVW_Printable::OnInitializePrintPreviewToolBar() ), you can read from code that there are other commands inserted after LoadToolBar.
So you should find out, which command you want to hide and actually you should remove them from toolbar. So if you want to remove let’s say ID_EXT_PPV_VIEW_MODE_FIT_WIDTH command, your code would be:

void CDemoGrid::OnInitializePrintPreviewToolBar()
{
	CExtPPVW < CExtGridWnd >::OnInitializePrintPreviewToolBar();
	m_pWndPP->m_pPpvWndToolBar->RemoveButton(m_pWndPP->m_pPpvWndToolBar->CommandToIndex(ID_EXT_PPV_VIEW_MODE_FIT_WIDTH));
}
To use ID_EXT_PPV_VIEW_MODE_FIT_WIDTH or other built-in command identifier of ProfUIS in your own code, you need to place this line in that file: #include <Resources/resource.h>

Disabling would be little harder, I think, I’d go for removing the unwanted commands.

Jia Hong Li Apr 5, 2007 - 4:40 AM

Thanks...It works...and another question: how to romove ZoomScrollBar that perform zoom-in and zoom-out if I do not want to change the Prof-UIS?
this part of code inside Prof-UIS(ExtPrint.cpp) is to create the default ZoomScrollBar:
if( m_pWndPP->m_bPpvUseZoomScrollBar )
    {
        VERIFY( m_pWndPP->m_pPpvWndToolBar->InitZoomScrollBar() );
        if( m_pWndPP->m_pPpvWndToolBar->m_wndZoomScrollBar.GetSafeHwnd() != NULL )
            m_pWndPP->m_nPpvMagnifyLevel = (UINT)m_pWndPP->m_pPpvWndToolBar->m_wndZoomScrollBar.GetScrollPos();
    }

Maybe it’s good way to reomve by marking this part but....any other way to do that?

Thanks a lot
(ˆ_ˆ)

Suhai Gyorgy Apr 5, 2007 - 4:48 AM

I didnt try it, but I guess it can be done like this:

void CDemoGrid::OnInitializePrintPreviewToolBar()
{
	m_pWndPP->m_bPpvUseZoomScrollBar = false;
	CExtPPVW < CExtGridWnd >::OnInitializePrintPreviewToolBar();
	m_pWndPP->m_pPpvWndToolBar->RemoveButton(m_pWndPP->m_pPpvWndToolBar->CommandToIndex(ID_EXT_PPV_VIEW_MODE_FIT_WIDTH));
}
Setting that boolean to false will skip the piece of code you mentioned.

Jia Hong Li Apr 5, 2007 - 8:04 PM

Thank you, Suhai.
It works
ˆ_ˆ