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 General Discussion » Print Setup dialog Collapse All
Subject Author Date
Anil Siddhpura Jan 1, 2009 - 6:16 AM

HI,


Is there any function to get "Print Setup" dialogbox? Or how to do "print setup" ??


 

Technical Support Jan 4, 2012 - 3:30 AM

First of all, you should understand the AfxHookWindowCreate() MFC API:
http://www.microsoft.com/msj/0699/c/c0699.aspx
It will allow you to use Prof-UIS for skinning externally created dialogs and windows. Even Visual Studio’s assertion dialog and .NET Windows Forms windows can be skinned. Here is the example of how we themed the standard Windows Shell’s Browse for Folder dialog:

#ifndef __AFXPRIV_H__
    #include <AfxPriv.h>
#endif

. . .

C_Hello_Win_Shell dlgHook;
    ::AfxHookWindowCreate( &dlgHook );
LPITEMIDLIST pItemList = SHBrowseForFolder( &bi );
    ::AfxUnhookWindowCreate();

And here is the C_Hello_Win_Shell class:
class C_Hello_Win_Shell : public CExtNCW < CExtResizableDialog >
{
public:
    CMy_CExtNCSB < CTreeCtrl > m_wndTree;
    C_Hello_Win_Shell()
        : m_wndTree( true )
    {
        SetAutoSubclassChildControls();
    }
protected:
    void _DoFixes()
    {
        HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD );
        for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
        {
            TCHAR sClassName[ _MAX_PATH + 1 ];
            ::memset( sClassName, 0, sizeof(sClassName) );
            ::GetClassName( hWnd, sClassName, _MAX_PATH );
            if( m_wndTree.GetSafeHwnd() == NULL )
            {
                if( _tcsnicmp( sClassName, _T("shBrowseForFolder"), _tcslen( _T("shBrowseForFolder") ) ) == 0 )
                {
                    HWND hWnd2 = ::GetWindow( hWnd, GW_CHILD );
                    for( ; hWnd2 != NULL; hWnd2 = ::GetWindow( hWnd2, GW_HWNDNEXT ) )
                    {
                        TCHAR sClassName[ _MAX_PATH + 1 ];
                        ::memset( sClassName, 0, sizeof(sClassName) );
                        ::GetClassName( hWnd2, sClassName, _MAX_PATH );
                        if( _tcsicmp( sClassName, _T("SysTreeView32") ) == 0 )
                        {
                            m_wndTree.SubclassWindow( hWnd2 );
                            m_wndTree.ModifyStyle( WS_BORDER, 0, SWP_FRAMECHANGED );
                            m_wndTree.ModifyStyleEx( WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME, 0, SWP_FRAMECHANGED );
                            break;
                        }
                    }
                    CWnd::FromHandle( hWnd ) -> ModifyStyle( WS_BORDER, WS_CLIPSIBLINGS|WS_CLIPCHILDREN, SWP_FRAMECHANGED );
                    CWnd::FromHandle( hWnd ) -> ModifyStyleEx( WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME, 0, SWP_FRAMECHANGED );
                    continue;
                }
            }
            if( _tcsicmp( sClassName, _T("scrollbar") ) == 0 )
                ::ShowWindow( hWnd, SW_HIDE );
        }
    }
    virtual void PreSubclassWindow()
    {
        __super::PreSubclassWindow();
        _DoFixes();
        ModifyStyle( 0, WS_CLIPSIBLINGS|WS_CLIPCHILDREN );
        PostMessage( (WM_USER+321) );
    }
    virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
    {
        if( message == (WM_USER+321) )
        {
            _DoFixes();
            return 0L;
        }
        LRESULT lr = __super::WindowProc( message, wParam, lParam );
        return lr;
    }
};

In the most case you need even more simple approach without creating a dialog class:
CExtNCW < CExtResizableDialog > dlgHook;
    dlgHook. SetAutoSubclassChildControls();
    ::AfxHookWindowCreate( &dlgHook );
. . .
// some HWND is created here
. . .
    ::AfxUnhookWindowCreate();

Please note, you should use the CExtNCW template class only with popup window types.

Bill Olson Dec 28, 2011 - 1:05 AM

I know this is a three year old thread, but I’m trying to get the print setup box to skin with Prof-UIS.  This is an MDI app.  I over rode the OnFilePrintSetup function and I copied and pasted the above code from Jan 9 into the function.  It still doesn’t skin.


Thanks,


Bill

Technical Support Jan 9, 2009 - 8:35 AM

This is not a problem. You should use the following code.

bool bPrintingAndPreviewingFeaturesAreAvailable = CExtPPVW_Printable::friendly_app_t::_IsPrinterAvailable();
            if( bPrintingAndPreviewingFeaturesAreAvailable )
                        CExtPPVW_Printable::friendly_app_t::_InvokeOnFilePrintSetup();



Anil Siddhpura Jan 9, 2009 - 2:55 AM

But my class is derived from CDialog class. So wat to do?

Technical Support Jan 2, 2009 - 3:16 PM

The CWinApp::OnFilePrintSetup() method is designed for handling the ID_FILE_PRINT_SETUP command. So, you should simply insert message map entry into the message map of the CWinApp-derived class in your project:

   ON_COMMAND( ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup )