OSDN Git Service

ObjectMap, ObjectVectorの値をByRef外しするようにした。他、ソースコード整形
[seraphyscrtools/SeraphyScriptTools.git] / Control.h
index 487a2bc..fbb6e65 100644 (file)
--- a/Control.h
+++ b/Control.h
@@ -1,17 +1,16 @@
 // Control.h : CControl \82Ì\90é\8c¾
 
-#ifndef __CONTROL_H_
-#define __CONTROL_H_
+#pragma once
 
 #include "resource.h"       // \83\81\83C\83\93 \83V\83\93\83{\83\8b
 #include "treeitem.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // CControl
-class ATL_NO_VTABLE CControl : 
+class ATL_NO_VTABLE CControl :
        public CComObjectRootEx<CComSingleThreadModel>,
-//     public CComCoClass<CControl, &CLSID_Control>,
-       public ISupportErrorInfo,
+       public CComCoClass<CControl, &CLSID_Control>,
+       public ISupportErrorInfoImpl<&IID_IControl>,
        public IConnectionPointContainerImpl<CControl>,
        public IDispatchImpl<IControl, &IID_IControl, &LIBID_SERAPHYSCRIPTTOOLSLib>
 {
@@ -22,58 +21,62 @@ public:
                m_y = 0;
                m_h = 0;
                m_w = 0;
-               m_bChecked  = false;
-               m_exstyle   = 0;
-               m_style     = 0;
-               m_nID       = 0;
-               m_hWnd      = NULL;
-               m_hParent   = NULL;
-               ZeroMemory(m_classname,MAX_PATH);
-               ZeroMemory(m_caption  ,MAX_PATH);
+               m_bChecked = false;
+               m_exstyle = 0;
+               m_style = 0;
+               m_nID = 0;
+               m_hWnd = NULL;
+               m_hParent = NULL;
+               ZeroMemory(m_classname, MAX_PATH);
+               ZeroMemory(m_captionMAX_PATH);
                // \83\8a\83X\83g\83R\83\93\83g\83\8d\81[\83\8b\97p
                m_nColumnCount = 0;
                m_dLastSortColumn = -1; //\8dÅ\8cã\82É\83\\81[\83g\82µ\82½\83J\83\89\83\80
        }
-       void SetParam(DWORD afterstyle,DWORD exstyle,LPCSTR classname,LPCSTR caption,DWORD style,int x,int y,int w,int h,int nID)
+
+       void SetParam(DWORD afterstyle, DWORD exstyle, LPCTSTR classname, LPCTSTR caption, DWORD style, int x, int y, int w, int h, int nID)
        {
-               CHAR tmp[64];
-               wsprintf(tmp,"OnCommand%d",nID);
+               TCHAR tmp[64];
+               wsprintf(tmp, _T("OnCommand%d"), nID);
                m_x = x;
                m_y = y;
                m_h = h;
                m_w = w;
-               m_exstyle   = exstyle;
-               m_style     = style;
-               lstrcpy(m_classname,classname);
-               lstrcpy(m_caption,caption);
-               m_nID       = nID;
+               m_exstyle = exstyle;
+               m_style = style;
+               StringCchCopy(m_classname, MAX_PATH, classname);
+               StringCchCopy(m_caption, MAX_PATH, caption);
+               m_nID = nID;
                m_bstrClassEvent = tmp;
                m_hWnd = NULL;
                m_hParent = NULL;
                m_afterstyle = afterstyle;
        }
+
        HWND GetHWnd()
        {
                return m_hWnd;
        }
+
        void Redraw()
        {
-               RedrawWindow(m_hWnd,NULL,NULL,RDW_ERASE|RDW_FRAME|RDW_INTERNALPAINT|RDW_INVALIDATE);
+               RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INTERNALPAINT | RDW_INVALIDATE);
        }
+
        void SetFont(HFONT hFont)
        {
-               if(m_hWnd){
-                       ::SendMessage(m_hWnd,WM_SETFONT,(WPARAM)hFont,true);
+               if (m_hWnd) {
+                       ::SendMessage(m_hWnd, WM_SETFONT, (WPARAM)hFont, true);
                }
        }
        void SetColor(DWORD color)
        {
-               if(m_hWnd){
-                       if(!lstrcmp(m_classname,WC_TREEVIEW)){
-                               TreeView_SetBkColor(m_hWnd,COLORREF(color));
+               if (m_hWnd) {
+                       if (!lstrcmp(m_classname, WC_TREEVIEW)) {
+                               TreeView_SetBkColor(m_hWnd, COLORREF(color));
                        }
-                       else if(!lstrcmp(m_classname,WC_LISTVIEW)){
-                               ListView_SetBkColor(m_hWnd,COLORREF(color));
+                       else if (!lstrcmp(m_classname, WC_LISTVIEW)) {
+                               ListView_SetBkColor(m_hWnd, COLORREF(color));
                        }
                }
        }
@@ -83,24 +86,21 @@ public:
                Destroy();
        }
 
-//DECLARE_REGISTRY_RESOURCEID(IDR_CONTROL)
-
-DECLARE_PROTECT_FINAL_CONSTRUCT()
+       //DECLARE_REGISTRY_RESOURCEID(IDR_CONTROL)
 
-BEGIN_COM_MAP(CControl)
-       COM_INTERFACE_ENTRY(IControl)
-       COM_INTERFACE_ENTRY(IDispatch)
-       COM_INTERFACE_ENTRY(ISupportErrorInfo)
-       COM_INTERFACE_ENTRY(IConnectionPointContainer)
-END_COM_MAP()
-BEGIN_CONNECTION_POINT_MAP(CControl)
-END_CONNECTION_POINT_MAP()
+       DECLARE_PROTECT_FINAL_CONSTRUCT()
 
+       BEGIN_COM_MAP(CControl)
+               COM_INTERFACE_ENTRY(IControl)
+               COM_INTERFACE_ENTRY(IDispatch)
+               COM_INTERFACE_ENTRY(ISupportErrorInfo)
+               COM_INTERFACE_ENTRY(IConnectionPointContainer)
+       END_COM_MAP()
+       BEGIN_CONNECTION_POINT_MAP(CControl)
+       END_CONNECTION_POINT_MAP()
 
-// ISupportsErrorInfo
-       STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
 
-// IControl
+       // IControl
 public:
        STDMETHOD(CreateChild)(/*[in]*/VARIANT text,/*[in]*/VARIANT varItem,/*[out,retval]*/VARIANT* pvarUnk);
        void GetClassEvent(BSTR* pEventName);
@@ -160,10 +160,10 @@ public:
        void Destroy();
 
 protected:
-//     LRESULT (CALLBACK *subclassproc)(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
-//     static LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
-static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); 
+       //      LRESULT (CALLBACK *subclassproc)(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
+       //      static LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
+       static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
+
 protected:
        int m_x;
        int m_y;
@@ -183,7 +183,5 @@ protected:
        VARTYPE m_typCompare;
        int m_dLastSortColumn;
        int m_nColumnCount;
-       LPSTR ConvertVariantToString(VARIANT text);
+       HRESULT ConvertVariantToString(VARIANT text, ATL::CString &retval);
 };
-
-#endif //__CONTROL_H_