OSDN Git Service

・ MBCS->Unicode対応
[seraphyscrtools/SeraphyScriptTools.git] / Control.h
index f23c635..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 ISupportErrorInfoImpl<&IID_IControl>,
        public IConnectionPointContainerImpl<CControl>,
        public IDispatchImpl<IControl, &IID_IControl, &LIBID_SERAPHYSCRIPTTOOLSLib>
 {
@@ -22,14 +21,14 @@ 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
@@ -44,10 +43,10 @@ public:
                m_h = h;
                m_w = w;
                m_exstyle = exstyle;
-               m_style   = style;
-               lstrcpy(m_classname, classname);
-               lstrcpy(m_caption, caption);
-               m_nID  = nID;
+               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;
@@ -66,18 +65,18 @@ public:
 
        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));
                        }
                }
        }
@@ -87,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);
@@ -164,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;
@@ -189,5 +185,3 @@ protected:
        int m_nColumnCount;
        HRESULT ConvertVariantToString(VARIANT text, ATL::CString &retval);
 };
-
-#endif //__CONTROL_H_