Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Multidevice ASIO output plugin for WinAMP

, 13 Feb 2009 CDDL
A tiny WinAMP output DLL that uses a C++ replacement of the official ASIO SDK that supports multiple ASIO devices.
#pragma once

#include "WTL.h"

#include <algorithm>
#include <cassert>


////////////////////////////////////////////////////////////////////////////////
//
//  InDialogPropertySheet
//  ---------------------
//
//  Extends/fixes WTL::CPropertySheetImpl<> to work properly as a dialog box
// child.
//
// (todo) make it more configurable.
//
////////////////////////////////////////////////////////////////////////////////

class InDialogPropertySheet : public WTL::CPropertySheetImpl<InDialogPropertySheet>
{
public:
    InDialogPropertySheet( ATL::_U_STRINGorID title = LPCTSTR( NULL ), UINT uStartPage = 0, HWND hWndParent = NULL )
        : CPropertySheetImpl<InDialogPropertySheet>( title, uStartPage, hWndParent )
    {
        m_psh.dwFlags |= PSH_MODELESS | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
    }

public:  // "private" CPropertySheetImpl interface.
    void OnSheetInitialized();
    static int CALLBACK PropSheetCallback( HWND, UINT uMsg, LPARAM );
};


////////////////////////////////////////////////////////////////////////////////
//
//  ReadOnlyPropertyPage
//  --------------------
//
//  A helper class intended for property sheet pages that only display (static)
// information and thus do not require the whole functionality of
// WTL::CPropertyPageImpl<> but a single call to an initialization function on
// WM_INITDIALOG.
//
////////////////////////////////////////////////////////////////////////////////

template <class Parameter, void (*InitializePage)( WTL::CPropertyPageWindow, HWND initialFocusControlHandle, Parameter parameter )>
class ReadOnlyPropertyPage
{
public:
    ReadOnlyPropertyPage( Parameter parameter, ATL::_U_STRINGorID const dialogTemplate, ATL::_U_STRINGorID const title = (LPCTSTR)NULL, bool const preCreate = false )
    {
        assert( sizeof( parameter ) <= sizeof( LPARAM ) );
        // Initialize the PROPSHEETPAGE struct.
        ::ZeroMemory( &psp_, sizeof( PROPSHEETPAGE ) );
        psp_.dwSize      = sizeof( PROPSHEETPAGE );
        psp_.dwFlags     = ( title.m_lpstr ? PSP_USETITLE : PSP_DEFAULT ) | ( preCreate ? PSP_PREMATURE : 0 );
        psp_.hInstance   = WTL::ModuleHelper::GetResourceInstance();
        psp_.pszTemplate = dialogTemplate.m_lpstr;
        psp_.pfnDlgProc  = &DialogProcedure;
        psp_.lParam      = reinterpret_cast<LPARAM>( const_cast<void *>( static_cast<void const *>( parameter ) ) );
        psp_.pszTitle    = title.m_lpstr;
    }

        operator LPCPROPSHEETPAGE() const { return &psp_; }

private:
    static INT_PTR CALLBACK DialogProcedure( HWND const hWnd, UINT const uMsg, WPARAM const wParam, LPARAM const lParam )
    {
        if ( uMsg == WM_INITDIALOG )
        {
            // Initialize the page.
            InitializePage( hWnd, reinterpret_cast<HWND>( wParam ), reinterpret_cast<Parameter>( reinterpret_cast<PROPSHEETPAGE *>( lParam )->lParam ) );
            // Disable any further DLGPROC calls.
            //  ...this breaks XP-style (white) property page backgrounds
            //::SetWindowLongPtr( hWnd, DWLP_DLGPROC, static_cast<LONG_PTR>( 0 ) );
        }
        return false;
    }

private:
    PROPSHEETPAGE psp_;
};


////////////////////////////////////////////////////////////////////////////////
//
//  Various GUI/WTL helpers
//  -----------------------
//
//  (todo) clean up and document better.
//
////////////////////////////////////////////////////////////////////////////////


unsigned int AddToolBarButtons
(
    WTL::CToolBarCtrl       & toolBar              ,
    WORD              const * items                ,
    WORD                      numberOfItems        ,
    BYTE                      buttonWrapState      ,
    size_t                    separatorWidth       ,
    size_t                    initialSeparatorWidth
);


WTL::CBitmap CreateBitmapFromIcon
(
    unsigned int  iconResourceID,
    TCHAR const * moduleName = _T( "shell32.dll" ),
    bool          assumeModuleIsLoaded = true
);


WTL::CToolBarCtrl CreateEmptyToolbar
(
    HWND hWndParent,
    DWORD dwStyle = ATL_SIMPLE_TOOLBAR_STYLE,
    DWORD dwStyleEx = 0,
    int x = 0,
    int y = 0,
    int width  = 0,
    int height = 0,
    UINT nID = ATL_IDW_TOOLBAR
);


WTL::CToolBarCtrl CreateSimpleToolBar
(
    HWND  hWndParent                                  ,
    UINT  nResourceID                                 ,
    bool  bInitialSeparator = false                   ,
    WORD  buttonMargin      = 7                       ,
    DWORD dwStyle           = ATL_SIMPLE_TOOLBAR_STYLE,
    UINT  nID               = ATL_IDW_TOOLBAR
);

WORD fontHeight( ATL::CWindow const & );


WTL::CRect GetDlgItemRect( ATL::CWindow const &, int itemID );


typedef WTL::CFrameWindowImplBase<>::_AtlToolBarData ToolBarData;

ToolBarData & GetToolBarData( UINT nResourceID );

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Domagoj Šarić
Software Developer Little Endian Ltd.
Croatia Croatia
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 13 Feb 2009
Article Copyright 2009 by Domagoj Šarić
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid