combooc.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 5k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #ifndef _COMBOBOX_OC_H_
  2. #define _COMBOBOX_OC_H_
  3. #include "unicpp/stdafx.h"
  4. #include <mshtmdid.h>
  5. #include <mshtml.h>
  6. #include <shdispid.h>
  7. #include "atldisp.h"
  8. #include "unicppsdspatch.h"
  9. #include "shcombox.h"
  10. #include "ids.h"
  11. #define FCIDM_VIEWADDRESS       (FCIDM_BROWSER_VIEW + 0x0005)
  12. #define DEFAULT_WINDOW_STYLE             (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | CBS_DROPDOWN | CBS_AUTOHSCROLL)
  13. #define SZ_REGVALUE_LAST_SELECTION       TEXT("Last Selection")
  14. // CProxy_ComboBoxExEvents
  15. template <class T>
  16. class CProxy_ComboBoxExEvents
  17.                     : public IConnectionPointImpl<T, &DIID_DComboBoxExEvents, CComDynamicUnkArray>
  18. {
  19. public:
  20. //methods:
  21. //DComboBoxExEvents : IDispatch
  22. public:
  23.     virtual void Fire_EnterPressed(void)
  24.     {
  25.         T* pT = (T*)this;
  26.         pT->Lock();
  27.         IUnknown** pp = m_vec.begin();
  28.         while (pp < m_vec.end())
  29.         {
  30.             if (*pp != NULL)
  31.             {
  32.                 DISPPARAMS disp = { NULL, NULL, 0, 0 };
  33.                 IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
  34.                 pDispatch->Invoke(DISPID_ENTERPRESSED, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  35.             }
  36.             pp++;
  37.         }
  38.         pT->Unlock();
  39.     }
  40. };
  41. class ATL_NO_VTABLE CComboBoxExOC
  42. {
  43. public:
  44.     CComboBoxExOC(LPCTSTR pszRegKey, int csidlDefaultPidl);
  45.     ~CComboBoxExOC();
  46.     virtual HRESULT TranslateAcceleratorInternal(MSG *pMsg, IOleClientSite * pocs);
  47.     virtual void Fire_EnterPressed(void) = 0;
  48. protected:
  49.     // Helper functions;
  50.     virtual HRESULT _PopulateTopItem(void);
  51.     virtual HRESULT _Populate(void) = 0;    // PURE virtual
  52.     virtual BOOL _IsSecure(void) = 0;    // PURE virtual
  53.     virtual HRESULT _AddDefaultItem(void) = 0;    // PURE virtual
  54.     virtual HRESULT _CustomizeName(UINT idResource, LPTSTR pszDisplayName, DWORD cchSize) = 0;    // PURE virtual
  55.     virtual HRESULT _GetSelectText(LPTSTR pszSelectText, DWORD cchSize, BOOL fDisplayName) = 0;    // PURE virtual
  56.     virtual HRESULT _IsDefaultSelection(LPCTSTR pszLastSelection) = 0;
  57.     virtual HRESULT _RestoreIfUserInputValue(LPCTSTR pszLastSelection) = 0;
  58.     virtual STDMETHODIMP get_Enabled(OUT VARIANT_BOOL * pfEnabled);
  59.     virtual STDMETHODIMP put_Enabled(IN VARIANT_BOOL fEnabled);
  60.     // Window Creation
  61.     HWND _CreateComboBoxEx(IOleClientSite * pClientSite, HWND hWnd, HWND hWndParent, RECT& rcPos, LPCTSTR pszWindowName, DWORD dwStyle, DWORD dwExStyle, UINT_PTR nID);
  62.     virtual HWND _Create(HWND hWndParent, RECT& rcPos, LPCTSTR pszWindowName, DWORD dwStyle, DWORD dwExStyle, UINT_PTR nID) = 0; // PURE Virtual
  63.     virtual DWORD _GetWindowStyles(void) { return DEFAULT_WINDOW_STYLE; };
  64.     virtual HRESULT _SetSelect(LPCTSTR pszDisplay, LPCTSTR pszReplace);
  65.     // Window Messages
  66.     LRESULT cb_ForwardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
  67.     LRESULT cb_OnDropDownMessage(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  68.     // ComboBox Util Functions
  69.     virtual HRESULT _AddFileType(LPCTSTR pszDisplayName, LPCTSTR pszExt, LPCITEMIDLIST pidlIcon, INT_PTR nPos, int iIndent);
  70.     HRESULT _AddResourceAndCsidlStr(UINT idString, int nCsidlItem, int nCsidlIcon, INT_PTR nPos, int iIndent);
  71.     HRESULT _AddResourceItem(int idString, DWORD dwData, int nCsidlIcon, INT_PTR nPos, int iIndent);
  72.     HRESULT _AddCsidlItem(int nCsidlItem, int nCsidlIcon, INT_PTR nPos, int iIndent);
  73.     HRESULT _AddCsidlItemStr(int nCsidlItem, int nCsidlIcon, INT_PTR nPos, int iIndent);
  74.     HRESULT _AddCsidlIcon(LPCTSTR pszDisplayName, LPVOID pvData, int nCsidlIcon, INT_PTR nPos, int iIndent);
  75.     HRESULT _AddPidl(LPITEMIDLIST pidl, LPITEMIDLIST pidlIcon, INT_PTR nPos, int iIndent);
  76.     HRESULT _AddToComboBox(LPCTSTR pszDisplayName, LPVOID pvData, LPCITEMIDLIST pidlIcon, INT_PTR nPos, int iIndent, INT_PTR *pnPosAdded);
  77.     HRESULT _AddToComboBoxKnownImage(LPCTSTR pszDisplayName, LPVOID pvData, int iImage, int iSelectedImage, INT_PTR nPos, int iIndent, INT_PTR *pnPosAdded);
  78.     // Util Functions
  79.     HRESULT _Load(IPropertyBag * pPropBag, IErrorLog * pErrorLog);
  80.     HRESULT _putString(LPCSTR pszString);
  81.     HRESULT _LoadAndConvertString(UINT idString, LPTSTR pszDisplayName, DWORD chSize);
  82.     // Private Member Variables
  83.     HWND                _hwndComboBox;
  84.     HWND                _hwndEdit;
  85.     LPCSTR              _pszInitialString;          // Initial String to display in Address Box.
  86.     LPCTSTR             _pszPersistString;          // Where in the registry to persist the state.
  87.     DWORD               _dwDropDownSize;            // Drop Down size.
  88.     BITBOOL             _fEnableEdit    : 1;        // Is Edit Allowed?
  89.     BITBOOL             _fInRecursion   : 1;
  90.     VARIANT_BOOL        _fEnabled;                  // Is the control enabled (not grayed out)?
  91.     LPCTSTR             _pszRegKey;                 // Persist data here.
  92.     int                 _csidlDefaultPidl;          // 
  93. };
  94. #endif // _COMBOBOX_OC_H_