krb5 commit: Prep for KfW conversion to ribbon toolbar

Benjamin Kaduk kaduk at MIT.EDU
Fri Aug 24 12:24:03 EDT 2012


https://github.com/krb5/krb5/commit/7a53399722e129ed9c00f0c37d0c20c0387c829d
commit 7a53399722e129ed9c00f0c37d0c20c0387c829d
Author: Kevin Wasserman <kevin.wasserman at painless-security.com>
Date:   Tue Apr 3 07:02:43 2012 -0400

    Prep for KfW conversion to ribbon toolbar
    
    Upgrade classes: CWinApp->CWinAppEx, CFrameWnd->CFrameWndEx,
    CStatusBar->CMFCStatusBar, CToolBar->CMFCToolBar.
    Call AfxOleInit() from CLeashApp::InitInstance()
    Do not call LoadBarState() (crashes)
    or GetToolBarCtrl() (no longer exists)
    
    Signed-off-by: Kevin Wasserman <kevin.wasserman at painless-security.com>
    
    ticket: 7244 (new)
    queue: kfw
    target_version: 1.10.4
    tags: pullup

 src/windows/leash/Leash.cpp      |    1 +
 src/windows/leash/Leash.h        |    2 +-
 src/windows/leash/LeashFrame.cpp |    9 ++---
 src/windows/leash/LeashFrame.h   |    2 +-
 src/windows/leash/LeashView.cpp  |    6 ++-
 src/windows/leash/MainFrm.cpp    |   71 +++-----------------------------------
 src/windows/leash/MainFrm.h      |    4 +-
 src/windows/leash/StdAfx.h       |    1 +
 8 files changed, 19 insertions(+), 77 deletions(-)

diff --git a/src/windows/leash/Leash.cpp b/src/windows/leash/Leash.cpp
index 0ee617a..9c187c1 100644
--- a/src/windows/leash/Leash.cpp
+++ b/src/windows/leash/Leash.cpp
@@ -166,6 +166,7 @@ extern "C" {
 
 BOOL CLeashApp::InitInstance()
 {
+    AfxOleInit();
     // NOTE: Not used at this time
     /// Set LEASH_DLL to the path where the Leash.exe is
     char modulePath[MAX_PATH];
diff --git a/src/windows/leash/Leash.h b/src/windows/leash/Leash.h
index 13b1438..377f0fc 100644
--- a/src/windows/leash/Leash.h
+++ b/src/windows/leash/Leash.h
@@ -92,7 +92,7 @@
 // See Leash.cpp for the implementation of this class
 //
 
-class CLeashApp : public CWinApp
+class CLeashApp : public CWinAppEx
 {
 private:
 	CString		m_leashDLL;
diff --git a/src/windows/leash/LeashFrame.cpp b/src/windows/leash/LeashFrame.cpp
index f7e4b56..2247833 100644
--- a/src/windows/leash/LeashFrame.cpp
+++ b/src/windows/leash/LeashFrame.cpp
@@ -31,9 +31,9 @@ const char CLeashFrame::s_profileMax[] = "max";
 const char CLeashFrame::s_profileTool[] = "tool";
 const char CLeashFrame::s_profileStatus[] = "status";
 
-IMPLEMENT_DYNAMIC(CLeashFrame, CFrameWnd)
+IMPLEMENT_DYNAMIC(CLeashFrame, CFrameWndEx)
 
-BEGIN_MESSAGE_MAP(CLeashFrame, CFrameWnd)
+BEGIN_MESSAGE_MAP(CLeashFrame, CFrameWndEx)
 	//{{AFX_MSG_MAP(CLeashFrame)
 	ON_WM_DESTROY()
 	//}}AFX_MSG_MAP
@@ -101,7 +101,7 @@ void CLeashFrame::OnDestroy()
 
 	SaveBarState(AfxGetApp()->m_pszProfileName);
 
-	CFrameWnd::OnDestroy();
+	CFrameWndEx::OnDestroy();
 }
 
 ///////////////////////////////////////////////////////////////
@@ -112,8 +112,7 @@ void CLeashFrame::ActivateFrame(int nCmdShow)
 	{
 		m_bFirstTime = FALSE;
 
-        LoadBarState(AfxGetApp()->m_pszProfileName);
     }
 
-	CFrameWnd::ActivateFrame(nCmdShow);
+	CFrameWndEx::ActivateFrame(nCmdShow);
 }
diff --git a/src/windows/leash/LeashFrame.h b/src/windows/leash/LeashFrame.h
index 6d45e78..9e17587 100644
--- a/src/windows/leash/LeashFrame.h
+++ b/src/windows/leash/LeashFrame.h
@@ -16,7 +16,7 @@
 #ifndef _LEASH_PERSISTENT_FRAME
 #define _LEASH_PERSISTENT_FRAME
 
-class CLeashFrame : public CFrameWnd
+class CLeashFrame : public CFrameWndEx
 { // remembers where it was on the desktop
 	DECLARE_DYNAMIC(CLeashFrame)
     static const CRect s_rectDefault;
diff --git a/src/windows/leash/LeashView.cpp b/src/windows/leash/LeashView.cpp
index 163f463..bc5d48e 100644
--- a/src/windows/leash/LeashView.cpp
+++ b/src/windows/leash/LeashView.cpp
@@ -1269,7 +1269,7 @@ VOID CLeashView::OnUpdateDisplay()
         m_tvinsert.item.iSelectedImage = NONE_PARENT_NODE;
         m_hPrincipal = m_pTree->InsertItem(&m_tvinsert);
 
-        if (CMainFrame::m_wndToolBar)
+/*        if (CMainFrame::m_wndToolBar)
         {
             CToolBarCtrl *_toolBar = NULL;
             CToolBarCtrl& toolBar = CMainFrame::m_wndToolBar.GetToolBarCtrl();
@@ -1284,12 +1284,13 @@ VOID CLeashView::OnUpdateDisplay()
                            MB_OK|MB_ICONSTOP);
             }
         }
+*/
     }
     else
     {
         // We have some tickets
         m_pTree->SetItemText(m_hPrincipal, sPrincipal);
-
+/*
         if (CMainFrame::m_wndToolBar)
         {
             CToolBarCtrl *_toolBar = NULL;
@@ -1304,6 +1305,7 @@ VOID CLeashView::OnUpdateDisplay()
                 AfxMessageBox("There is a problem with the Leash Toolbar!", MB_OK|MB_ICONSTOP);
             }
         }
+*/
     }
     ReleaseMutex(ticketinfo.lockObj);
 }
diff --git a/src/windows/leash/MainFrm.cpp b/src/windows/leash/MainFrm.cpp
index fe1472c..2332a1b 100644
--- a/src/windows/leash/MainFrm.cpp
+++ b/src/windows/leash/MainFrm.cpp
@@ -33,8 +33,8 @@ static char THIS_FILE[] = __FILE__;
 #define MIN_RIGHT	  530
 #define MIN_BOTTOM	  280
 
-CStatusBar CMainFrame::m_wndStatusBar;
-CToolBar   CMainFrame::m_wndToolBar;
+CMFCStatusBar CMainFrame::m_wndStatusBar;
+CMFCToolBar   CMainFrame::m_wndToolBar;
 CImageList CMainFrame::m_imageList;
 CImageList CMainFrame::m_disabledImageList;
 BOOL	   CMainFrame::m_isMinimum;
@@ -124,67 +124,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 		return -1;      // fail to create
 	}
 
-    // Create an image list of Icons so that we can use the best color
-    // depth available on the system and then assign this new list to
-    // be used instead of the single bitmap file assigned to the toolbar
-    // in the resource file
-    CToolBarCtrl *_toolBar = NULL;
-    CToolBarCtrl& toolBar = CMainFrame::m_wndToolBar.GetToolBarCtrl();
-    HICON      hIcon[7];
-    int n;
-
-    for (n = 0; n < 7; n++)
-    {
-        hIcon[n] = NULL;
-    }
-
-    UINT bitsPerPixel = GetDeviceCaps( ::GetDC(::GetDesktopWindow()), BITSPIXEL);
-    UINT ilcColor;
-    if ( bitsPerPixel >= 32 )
-        ilcColor = ILC_COLOR32;
-    else if ( bitsPerPixel >= 24 )
-        ilcColor = ILC_COLOR24;
-    else if ( bitsPerPixel >= 16 )
-        ilcColor = ILC_COLOR16;
-    else if ( bitsPerPixel >= 8 )
-        ilcColor = ILC_COLOR8;
-    else
-        ilcColor = ILC_COLOR;
-
-    m_imageList.Create(18, 18, ilcColor | ILC_MASK, 8, 4);
-    m_imageList.SetBkColor(GetSysColor(COLOR_BTNFACE));
-
-    hIcon[0] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_INIT);
-    hIcon[1] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_RENEW);
-    hIcon[2] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_IMPORT);
-    hIcon[3] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_DESTROY);
-    hIcon[4] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_PASSWORD);
-    hIcon[5] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_REFRESH);
-    hIcon[6] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_SYNC);
-
-    for (n = 0; n < 7; n++)
-    {
-        m_imageList.Add(hIcon[n]);
-    }
-    toolBar.SetImageList(&m_imageList);
-
-    m_disabledImageList.Create(18, 18, ilcColor | ILC_MASK, 8, 4);
-    m_disabledImageList.SetBkColor(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
-
-    hIcon[0] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_INIT_DISABLED);
-    hIcon[1] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_RENEW_DISABLED);
-    hIcon[2] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_IMPORT_DISABLED);
-    hIcon[3] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_DESTROY_DISABLED);
-    hIcon[4] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_PASSWORD_DISABLED);
-    hIcon[5] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_REFRESH_DISABLED);
-    hIcon[6] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_SYNC_DISABLED);
-
-    for (n = 0; n < 7; n++)
-    {
-        m_disabledImageList.Add(hIcon[n]);
-    }
-    toolBar.SetDisabledImageList(&m_disabledImageList);
-
 	if (!m_wndStatusBar.Create(this) ||
 		!m_wndStatusBar.SetIndicators(indicators,
 		  (CLeashApp::m_hAfsDLL ? 4 : 3)))
@@ -196,13 +135,13 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	}
 
 	// TODO: Remove this if you don't want tool tips or a resizeable toolbar
-	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
+	m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() |
 		                     CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
 
 	// TODO: Delete these three lines if you don't want the toolbar to
 	//  be dockable
-	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
-	EnableDocking(CBRS_ALIGN_ANY);
+//	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
+//	EnableDocking(CBRS_ALIGN_ANY);
 	//DockControlBar(&m_wndToolBar);
 
 	return 0;
diff --git a/src/windows/leash/MainFrm.h b/src/windows/leash/MainFrm.h
index 1ccfcfd..2d35bfd 100644
--- a/src/windows/leash/MainFrm.h
+++ b/src/windows/leash/MainFrm.h
@@ -39,8 +39,8 @@ protected: // create from serialization only
 // Attributes
 public:
 	static int         m_whatSide;
-    static CStatusBar  m_wndStatusBar;
-	static CToolBar    m_wndToolBar;
+    static CMFCStatusBar  m_wndStatusBar;
+	static CMFCToolBar    m_wndToolBar;
 	static BOOL		   m_isMinimum;
     static BOOL        m_isBeingResized;
     static CImageList  m_imageList;
diff --git a/src/windows/leash/StdAfx.h b/src/windows/leash/StdAfx.h
index 8717508..aa3b90e 100644
--- a/src/windows/leash/StdAfx.h
+++ b/src/windows/leash/StdAfx.h
@@ -21,6 +21,7 @@
 #include "htmlhelp.h"
 
 #endif // _AFX_NO_AFXCMN_SUPPORT
+#include <afxcontrolbars.h>
 
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.


More information about the cvs-krb5 mailing list