#. ReBar 컨트롤에 집어 넣을 윈도우 구현

   - TB_BUTTONCOUNT, TB_GETITEMRECT 2개의 메세지 구현해주면 ReBar에 넣을수있다.

 

 


/////////////////////////////////////////////////////////////////////////////
class C_WTLWINVIEW_View : public CWindowImpl<C_WTLWINVIEW_View>
{
public:
 DECLARE_WND_CLASS(NULL)

 BOOL PreTranslateMessage(MSG* pMsg)
 {
  pMsg;
  return FALSE;
 }

 BEGIN_MSG_MAP(C_WTLWINVIEW_View)
  MESSAGE_HANDLER ( WM_PAINT            , OnPaint              )
  MESSAGE_HANDLER ( TB_BUTTONCOUNT      , OnTB_ButtonCount     )
  MESSAGE_HANDLER ( TB_GETITEMRECT      , OnTB_GetItemRect     )
  MESSAGE_HANDLER ( TB_GETEXTENDEDSTYLE , OnTB_GetExtendedStyle)
  MESSAGE_HANDLER ( TB_SETEXTENDEDSTYLE , OnTB_SetExtendedStyle)
 END_MSG_MAP()

 // Handler prototypes (uncomment arguments if needed):
 // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
 // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

 LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  CPaintDC dc(m_hWnd);

  //TODO: Add your drawing code here

  return 0;
 }
 LRESULT OnTB_ButtonCount(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return int item count
  // wParam int 0
  // lParam int 0
  return 1;
 }
 LRESULT OnTB_GetItemRect(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
 {
  // return BOOL  success
  // wParam int   button index
  // lParam RECT* button rect

  LPRECT lpRect = (LPRECT)lParam;

  lpRect->left  =0;
  lpRect->top   =0;
  lpRect->right =100;
  lpRect->bottom=20;

  return 1;
 }
 LRESULT OnTB_GetExtendedStyle(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return DWORD style
  // wParam int   0
  // lParam int   0
  return 0;
 }
 LRESULT OnTB_SetExtendedStyle(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
 {
  // return DWORD style
  // wParam int   0
  // lParam int   new style
  return 0;
 }
};

WTL::CFrameWindowImplBase::AddSimpleReBarBandCtrl()

 

/////////////////////////////////////////////////////////////////////////////

//

// Class: CMyToolWindow

//

/////////////////////////////////////////////////////////////////////////////

//===========================================================================

class CMyToolWindow : public CWindowImpl<CMyToolWindow>

{

public:

        //DECLARE_WND_CLASS(NULL)

        DECLARE_WND_CLASS_EX (NULL, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, (HBRUSH)(COLOR_APPWORKSPACE))

 

        BOOL PreTranslateMessage(MSG* pMsg)

        {

               pMsg;

               return FALSE;

        }

 

        BEGIN_MSG_MAP(CMyToolWindow)

               MESSAGE_HANDLER(TB_BUTTONCOUNT, OnToolBarButtonCount)

               MESSAGE_HANDLER(TB_GETITEMRECT, OnToolBarItemRect   )

               MESSAGE_HANDLER(WM_PAINT, OnPaint)

        END_MSG_MAP()

 

        LRESULT OnToolBarButtonCount(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

        {

               return 1;

        }

 

        LRESULT OnToolBarItemRect   (UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)

        {

               int    nButtonCount = (int)   wParam;

               LPRECT pRect        = (LPRECT)lParam;

 

               pRect->left   =0;

               pRect->top    =0;

 

               if (nButtonCount>0)

                       pRect->right  =100*nButtonCount;

               else

                       pRect->right  =100;

               pRect->bottom =25;

 

               return 1;

        }

 

        LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

        {

               CPaintDC dc(m_hWnd);

 

               //TODO: Add your drawing code here

               dc.TextOut (0,0,_T("xxx"));

               return 0;

        }

};

 

 

 

#. MainFrame 윈도우에서

 

CMyToolWindow m_MyToolWindow;

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        HWND hWndCmdBar;

        HWND hWndToolBar;

 

        hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);

        m_CmdBar.AttachMenu(GetMenu());

        m_CmdBar.LoadImages(IDR_MAINFRAME);

        SetMenu(NULL);

 

        hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);

 

        m_MyToolWindow.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_STATICEDGE);

 

        // Rebar

        CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);

        AddSimpleReBarBand(hWndCmdBar);

        AddSimpleReBarBand(hWndToolBar, NULL, TRUE);

        AddSimpleReBarBand(m_MyToolWindow, _T("MyToolWindow"), TRUE, 100, TRUE);

 

        // StatusBar

        CreateSimpleStatusBar();

 

        // View

        m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

 

        UIAddToolBar(hWndToolBar);

        UISetCheck(ID_VIEW_TOOLBAR, 1);

        UISetCheck(ID_VIEW_STATUS_BAR, 1);

 

        // register object for message filtering and idle updates

        CMessageLoop* pLoop = _Module.GetMessageLoop();

        ATLASSERT(pLoop != NULL);

        pLoop->AddMessageFilter(this);

        pLoop->AddIdleHandler(this);

 

        return 0;

}

 

Posted by 셈말짓기 :

TCHAR      text[128];

SYSTEMTIME st;

int        result = 0;

 

GetLocalTime (&st);

 

result = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, text, 128);

if (result)

{

        // printf (text);

}

 

result = GetTimeFormat(LOCALE_USER_DEFAULT, /*LOCALE_NOUSEROVERRIDE*/0, &st, _T("HH:mm:ss"), text, 128);

if (result)

{

        // printf (text);

}

 

Posted by 셈말짓기 :

class object
{
private:
 typedef unsigned int uint_t;
 typedef void (object::*object_proc)(uint_t param);

 std::map<uint_t, object::object_proc> _lookup_of_object_proc;

public:
 uint_t _value;

public:
 void initialize (void)
 {
  _lookup_of_object_proc[0] = &object::test_1;
  _lookup_of_object_proc[1] = &object::test_2;
 }

 void test_1 (uint_t param)
 {
  printf ("test_1 = %d %d \r\n",_value, param);
 }

 void test_2 (uint_t param)
 {
  printf ("test_2 = %d %d \r\n", _value, param);
 }

 void run (uint_t id, uint_t value)
 {
  object_proc proc = _lookup_of_object_proc[id];

  if (proc)
  {
   (this->*proc) (value);
  }
 }
};

int _tmain(int argc, _TCHAR* argv[])
{
 HRESULT hRes = ::CoInitialize(NULL);

 assert(SUCCEEDED(hRes));


 object a,b;

 a.initialize();
 b.initialize();

 a._value = 10;
 b._value = 20;

 a.run (0, 1);
 a.run (1, 2);

 b.run (0, 1);
 b.run (1, 2);

 ::CoUninitialize();

 return 0;
}



---------------------------------------------------------
test_1 = 10 1
test_2 = 10 2
test_1 = 20 1
test_2 = 20 2
계속하려면 아무 키나 누르십시오 . . .

Posted by 셈말짓기 :


std::for_each(m_Module.begin(), m_Module.end(), DeleteWindowObject<CVMEModuleWidget*>); 

template <typename TYPE>
static void DeleteWindowObject (TYPE p)
{
 p->DestroyWindow();
 delete p;
}

template <typename TYPE>
static void DeletePointer (TYPE p)
{
 delete p;
}

template <typename TYPE>
static void DeleteArrayPointer (TYPE p)
{
 delete []p;

 template <typename TYPE>
 static void delete_pointer_of_std_pair_second (TYPE p)
 {
  delete p.second;
 }

Posted by 셈말짓기 :

# 일반 Class 형
class Data_Class
{
public:
 int value1;
 int value2;
 int value3;

public:
 Data_Class ();
 Data_Class (const Data_Class& o);
 Data_Class& operator=(const Data_Class& rhs);
};

Data_Class::Data_Class ()
{
 value1=0;
 value2=0;
 value3=0;
}

Data_Class::Data_Class (const Data_Class& o)
{
 value1=o.value1;
 value2=o.value2;
 value3=o.value3;
}

Data_Class& Data_Class::operator=(const Data_Class& rhs)
{
 value1=rhs.value1;
 value2=rhs.value2;
 value3=rhs.value3;

 return *this;
}

# Inline Class 형
class Data_Inline_Class
{
public:
 int value1;
 int value2;
 int value3;

public:
 Data_Inline_Class ()
 {
  value1=0;
  value2=0;
  value3=0;
 }


 Data_Inline_Class (const Data_Inline_Class& o)
 {
  value1=o.value1;
  value2=o.value2;
  value3=o.value3;
 }

 Data_Inline_Class& operator=(const Data_Inline_Class& rhs)
 {
  value1=rhs.value1;
  value2=rhs.value2;
  value3=rhs.value3;

  return *this;
 }
};

Posted by 셈말짓기 :

USE [zm]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/** zm_marine_farm
 **/
CREATE PROCEDURE [dbo].[zm_add_gathering_data] (
 @param1 NVARCHAR(32),
 @param2 NVARCHAR(32),
 @param3 FLOAT,
 @param4 FLOAT,
 @param5 FLOAT
) AS
BEGIN
 IF  (SELECT COUNT(TABLE_NAME)  
       FROM INFORMATION_SCHEMA.TABLES  
       WHERE
INFORMATION_SCHEMA.TABLES.TABLE_NAME=@param1) = 0
 BEGIN
  EXEC('CREATE TABLE [dbo].[' + @param1 + '] (
    [gather_time]       [datetime]     NOT NULL,
    [device_node_id]    [nvarchar](16) NOT NULL,
    [water_temperature] [float]        NULL,
    [demand_oxygens]    [float]        NULL,
    [salinity]          [float]        NULL)')
 END

 EXEC('INSERT INTO [dbo].[' + @param1 + '] (
                      [gather_time]      ,
                      [device_node_id]   ,
                      [water_temperature],
                      [demand_oxygens]   ,
                      [salinity]         )
              VALUES (GETDATE(), '''
                      + @param2 + ''','
                      + @param3 + ','
                      + @param4 + ','
                      + @param5 + ')' )
END

Posted by 셈말짓기 :

class CMainFrame :

        public CFrameWindowImpl<CMainFrame>,

        public CUpdateUI<CMainFrame>,

        public CMessageFilter, public CIdleHandler

{

public:

 

DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

 

BEGIN_MSG_MAP(CMainFrame)

 

        MESSAGE_HANDLER    ( WM_CREATE        , OnCreate       )

        MESSAGE_HANDLER    ( WM_DESTROY       , OnDestroy      )

        MESSAGE_HANDLER    ( WM_DROPFILES     , OnDropFile     )

        COMMAND_ID_HANDLER ( ID_SELECTFOLDER  , OnSelectFolder )

        COMMAND_ID_HANDLER ( ID_FILE_OPEN     , OnFileOpen     )

        COMMAND_ID_HANDLER ( ID_FILE_SAVE     , OnFileSave     )

        ...

END_MSG_MAP()

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        ...

        DragAcceptFiles (TRUE);

 

        return 0;

}

 

LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)

{

        DragAcceptFiles (FALSE);

        ...

}

 

LRESULT OnDropFile (UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        HDROP  hDrop = (HDROP) wParam;    

 

        TCHAR filePath [MAX_PATH];

        int   fileCount;

        int   index;

 

        fileCount = DragQueryFile (hDrop, -1, NULL, NULL);

        if (fileCount > 0)

        {

               for (index=0; index<fileCount; index++)

               {

                       if (DragQueryFile (hDrop, index, filePath, sizeof(filePath)))

                       {

                              ATLTRACE (_T("OnDropFile(): %s \r\n"), filePath);

                       }

               }

        }

 

        DragFinish(hDrop);

 

        return 0;

}

 

LRESULT OnSelectFolder (WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        BROWSEINFO   bi = { 0 };

        LPITEMIDLIST pidl;

        TCHAR        path[MAX_PATH] = { 0 };

 

        ZeroMemory (&bi,sizeof(BROWSEINFO));

 

        bi.ulFlags        = 0;

        bi.lpszTitle      = NULL;

        bi.pszDisplayName = path;

        pidl              = SHBrowseForFolder ( &bi );

 

        if ( pidl != 0 )

        {

               if (SHGetPathFromIDList (pidl, path))

               {

                       ATLTRACE (_T("OnSelectFolder(): %s \r\n"), path);

               }

 

               // free memory used

               IMalloc * imalloc = 0;

               if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )

               {

                       imalloc->Free ( pidl );

                       imalloc->Release ( );

               }

        }

 

        return 0;

}

 

LRESULT OnFileSave(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        CFileDialog FileOpenDilaog

        (

               FALSE,

               _T("bin"),

               _T("default.bin"),         

               OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

               _T("Binary Files (*.bin)\0*.bin\0All Files (*.*)\0*.*\0"),

               m_hWnd

        );

 

 

        if (FileOpenDilaog.DoModal() == IDOK)

        {

               ATLTRACE (_T("OnFileSave(): %s \r\n"), FileOpenDilaog.m_szFileName);

        }

 

        return 0;

}

 

LRESULT OnFileOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        CFileDialog FileOpenDilaog

        (

                TRUE,

               _T("bin"),

               NULL,

               OFN_HIDEREADONLY,

               _T("Binary Files (*.bin)\0*.bin\0All Files (*.*)\0*.*\0"),

               m_hWnd

        );

 

        if (FileOpenDilaog.DoModal() == IDOK)

        {

               ATLTRACE (_T("OnFileOpen(): %s \r\n"), FileOpenDilaog.m_szFileName);

        }

 

        return 0;

}

 

};

 

Posted by 셈말짓기 :

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        // . . .

 

        // delete memuitems

        CMenuHandle menu     = m_CmdBar.GetMenu();

        CMenuHandle menuFile = menu.GetSubMenu (0);

       

        menuFile.RemoveMenu (ID_FILE_NEW,           MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_OPEN,          MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_SAVE,          MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_SAVE_AS,       MF_BYCOMMAND);

        menuFile.RemoveMenu (0,                     MF_SEPARATOR);

        menuFile.RemoveMenu (ID_FILE_PRINT,         MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_PRINT_PREVIEW, MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_PRINT_SETUP,   MF_BYCOMMAND);

        menuFile.RemoveMenu (0,                     MF_SEPARATOR);

 

        CMenuHandle menuWindow = menu.GetSubMenu (3);

        menuWindow.RemoveMenu (ID_WINDOW_CLOSE,      MF_BYCOMMAND);

        menuWindow.RemoveMenu (ID_WINDOW_CLOSE_ALL,  MF_BYCOMMAND);

        menuWindow.RemoveMenu (0,                    MF_SEPARATOR);

       

        menu.DeleteMenu (1,MF_BYPOSITION); // EDIT menu

        m_CmdBar.AttachMenu (menu);

       

        // delete buttons of toolbar

        CToolBarCtrl toolbar;

       

        toolbar.Attach (hWndToolBar);

 

        toolbar.DeleteButton (0); // NEW

        toolbar.DeleteButton (0); // OPEN

        toolbar.DeleteButton (0); // SAVE

        toolbar.DeleteButton (0); // -

        toolbar.DeleteButton (0); // CUT

        toolbar.DeleteButton (0); // COPY

        toolbar.DeleteButton (0); // PASTE

        toolbar.DeleteButton (0); // -

        toolbar.DeleteButton (0); // PRINT

       

        toolbar.Detach ();

       

        return 0;

}

 

Posted by 셈말짓기 :