1 // **************************************************************************************
2 // File: LeashDebugWindow.cpp
3 // By: Arthur David Leather
5 // Copyright @1998 Massachusetts Institute of Technology - All rights reserved.
6 // Description: CPP file for LeashDebugWindow.h. Contains variables and functions
7 // for the Leash Debug Window
11 // MM/DD/YY Inits Description of Change
12 // 12/02/98 ADL Original
13 // **************************************************************************************
19 #include "LeashDebugWindow.h"
25 static char THIS_FILE[] = __FILE__;
28 /////////////////////////////////////////////////////////////////////////////
29 // CLeashDebugWindow dialog
32 CLeashDebugWindow::CLeashDebugWindow(CWnd* pParent /*=NULL*/)
33 : CDialog(CLeashDebugWindow::IDD, pParent)
35 //{{AFX_DATA_INIT(CLeashDebugWindow)
41 CLeashDebugWindow::CLeashDebugWindow(CFormView* pView)
46 void CLeashDebugWindow::DoDataExchange(CDataExchange* pDX)
48 CDialog::DoDataExchange(pDX);
49 //{{AFX_DATA_MAP(CLeashDebugWindow)
50 DDX_Control(pDX, IDC_DEBUG_LISTBOX, m_debugListBox);
51 DDX_Control(pDX, IDC_LOG_FILE_LOCATION_TEXT, m_debugFile);
56 BEGIN_MESSAGE_MAP(CLeashDebugWindow, CDialog)
57 //{{AFX_MSG_MAP(CLeashDebugWindow)
59 ON_BN_CLICKED(IDC_COPY_TO_CLIPBOARD, OnCopyToClipboard)
65 /////////////////////////////////////////////////////////////////////////////
66 // CLeashDebugWindow message handlers
69 BOOL CLeashDebugWindow::Create(const LPCSTR debugFilePath)
71 m_debugFilePath = debugFilePath;
72 return CDialog::Create(CLeashDebugWindow::IDD);
76 void CLeashDebugWindow::OnCancel()
82 pApp->WriteProfileInt("Settings", "DebugWindow", FALSE_FLAG);
83 m_pView->PostMessage(WM_GOODBYE, IDCANCEL); // modeless case
84 //// pset_krb_debug(OFF);
85 //// pset_krb_ap_req_debug(OFF);
89 CDialog::OnCancel(); // modal case
93 void CLeashDebugWindow::OnOK()
99 m_pView->PostMessage(WM_GOODBYE, IDOK);
103 CDialog::OnOK(); // modal case
107 BOOL CLeashDebugWindow::OnInitDialog()
109 CDialog::OnInitDialog();
112 //// pset_krb_debug(ON); //(int)m_debugListBox.GetSafeHwnd()
113 //// pset_krb_ap_req_debug(ON);
115 if (*m_debugFilePath != 0)
116 SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, m_debugFilePath);
118 SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, "Not Available");
120 if (!m_debugListBox.GetCount())
121 GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(FALSE);
123 m_CopyButton = FALSE;
125 return TRUE; // return TRUE unless you set the focus to a control
126 // EXCEPTION: OCX Property Pages should return FALSE
129 void CLeashDebugWindow::OnShowWindow(BOOL bShow, UINT nStatus)
131 CDialog::OnShowWindow(bShow, nStatus);
134 void CLeashDebugWindow::OnCopyToClipboard()
136 if (!OpenClipboard())
138 MessageBox("Unable to open Clipboard!", "Error", MB_OK);
144 int maxItems = m_debugListBox.GetCount();
145 const int MAX_MEM = maxItems * 90; // 90 chars per line seems safe like a safe bet
147 HGLOBAL hDebugText = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, MAX_MEM);
148 if (NULL != hDebugText)
151 LPSTR pDebugText = (LPSTR) GlobalLock(hDebugText);
154 MessageBox("Unable to write to Clipboard!", "Error", MB_OK);
160 for (int xItem = 0; xItem < maxItems; xItem++)
162 m_debugListBox.GetText(xItem, listboxItem);
163 strcat(pDebugText, listboxItem);
164 strcat(pDebugText, "\r\n");
167 GlobalUnlock(hDebugText);
170 if (NULL != hDebugText)
171 SetClipboardData(CF_TEXT, hDebugText);
174 MessageBox("Copy to Clipboard was Successful!\r\n Paste it in your favorite editor.",
178 BOOL CLeashDebugWindow::PreTranslateMessage(MSG* pMsg)
180 if (!m_CopyButton && m_debugListBox.GetCount())
183 GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(TRUE);
186 return CDialog::PreTranslateMessage(pMsg);