1 // xkeymacs.cpp : Defines the class behaviors for the application.
\r
5 #include "xkeymacs.h"
\r
10 #define new DEBUG_NEW
\r
12 static char THIS_FILE[] = __FILE__;
\r
15 /////////////////////////////////////////////////////////////////////////////
\r
18 BEGIN_MESSAGE_MAP(CXkeymacsApp, CWinApp)
\r
19 //{{AFX_MSG_MAP(CXkeymacsApp)
\r
20 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
\r
21 // NOTE - the ClassWizard will add and remove mapping macros here.
\r
22 // DO NOT EDIT what you see in these blocks of generated code!
\r
24 // Standard file based document commands
\r
25 ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
\r
26 ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
30 // CXkeymacsApp construction
\r
32 CXkeymacsApp::CXkeymacsApp()
\r
34 // TODO: add construction code here,
\r
35 // Place all significant initialization in InitInstance
\r
37 m_Instance = FirstInstance;
\r
40 /////////////////////////////////////////////////////////////////////////////
\r
41 // The one and only CXkeymacsApp object
\r
43 CXkeymacsApp theApp;
\r
45 /////////////////////////////////////////////////////////////////////////////
\r
46 // CXkeymacsApp initialization
\r
48 BOOL CXkeymacsApp::InitInstance()
\r
50 // AfxEnableControlContainer();
\r
52 // Standard initialization
\r
53 // If you are not using these features and wish to reduce the size
\r
54 // of your final executable, you should remove from the following
\r
55 // the specific initialization routines you do not need.
\r
57 m_hMutex = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)));
\r
59 if (::GetLastError() == ERROR_ALREADY_EXISTS) {
\r
60 m_Instance = SecondInstance;
\r
61 CloseHandle( m_hMutex );
\r
66 Enable3dControls(); // Call this when using MFC in a shared DLL
\r
68 Enable3dControlsStatic(); // Call this when linking to MFC statically
\r
71 // Change the registry key under which our settings are stored.
\r
72 // TODO: You should modify this string to be something appropriate
\r
73 // such as the name of your company or organization.
\r
74 // SetRegistryKey(_T("Local AppWizard-Generated Applications"));
\r
75 SetRegistryKey(IDS_REGISTRY_KEY);
\r
77 // LoadStdProfileSettings(); // Load standard INI file options (including MRU)
\r
79 // Parse command line for standard shell commands, DDE, file open
\r
80 // CCommandLineInfo cmdInfo;
\r
81 // ParseCommandLine(cmdInfo);
\r
83 // Dispatch commands specified on the command line
\r
84 // if (!ProcessShellCommand(cmdInfo))
\r
87 // The one and only window has been initialized, so show and update it.
\r
88 m_pMainWnd = new CMainFrame;
\r
89 m_pMainWnd->ShowWindow(SW_HIDE);
\r
90 m_pMainWnd->UpdateWindow();
\r
91 SetClassLong(m_pMainWnd->m_hWnd, GCL_HICON, (LONG)LoadIcon(IDR_MAINFRAME));
\r
94 // CMainFrame *pMainWnd = (CMainFrame*)m_pMainWnd;
\r
95 CProfile::InitDllData();
\r
101 /////////////////////////////////////////////////////////////////////////////
\r
102 // CAboutDlg dialog used for App About
\r
104 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
\r
106 //{{AFX_DATA_INIT(CAboutDlg)
\r
107 m_szVersionInformation = _T("");
\r
108 m_szLegalCopyright = _T("");
\r
111 m_szLegalCopyright.Format(_T("Copyright (C) 2001-2006")); // rough
\r
113 WORD wMajorVersion = 0;
\r
114 WORD wMinorVersion = 0;
\r
115 WORD wBuildVersion = 0;
\r
116 WORD wRevisionVersion = 0;
\r
118 TCHAR szFileName[MAX_PATH] = {'\0'};
\r
119 GetModuleFileName(NULL, szFileName, sizeof(szFileName));
\r
120 DWORD dwHandle = 0;
\r
122 DWORD dwLen = GetFileVersionInfoSize(szFileName, &dwHandle);
\r
124 LPVOID lpData = new BYTE[dwLen];
\r
125 if (GetFileVersionInfo(szFileName, dwHandle, dwLen, lpData)) {
\r
126 VS_FIXEDFILEINFO *pInfo;
\r
128 if (VerQueryValue(lpData, _T("\\"), (LPVOID *)&pInfo, &uLen)) {
\r
129 wMajorVersion = (WORD)((pInfo->dwProductVersionMS >> 16) & 0xffff);
\r
130 wMinorVersion = (WORD)((pInfo->dwProductVersionMS ) & 0xffff);
\r
131 wBuildVersion = (WORD)((pInfo->dwProductVersionLS >> 16) & 0xffff);
\r
132 wRevisionVersion = (WORD)((pInfo->dwProductVersionLS ) & 0xffff);
\r
135 Translate_t *lpTranslate = NULL;
\r
136 UINT cbTranslate = 0;
\r
137 if (VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &cbTranslate) && sizeof(Translate_t) <= cbTranslate) {
\r
138 LPVOID lpLegalCopyright = NULL;
\r
142 SubBlock.Format(_T("\\StringFileInfo\\%04x%04x\\LegalCopyright"), lpTranslate->wLanguage, lpTranslate->wCodePage);
\r
143 if (VerQueryValue(lpData, SubBlock.GetBuffer(SubBlock.GetLength()), (LPVOID *)&lpLegalCopyright, &uLen) && uLen) {
\r
144 m_szLegalCopyright.Format(_T("%s"), lpLegalCopyright);
\r
152 m_szVersionInformation.Format(_T("%s Version %d.%d"), CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)), wMajorVersion, wMinorVersion);
\r
154 if (wBuildVersion) {
\r
156 sz.Format(_T(".%d"), wBuildVersion);
\r
157 m_szVersionInformation += sz;
\r
159 if (wRevisionVersion) {
\r
161 sz.Format(_T(".%d"), wRevisionVersion);
\r
162 m_szVersionInformation += sz;
\r
167 void CAboutDlg::DoDataExchange(CDataExchange *pDX)
\r
169 CDialog::DoDataExchange(pDX);
\r
170 //{{AFX_DATA_MAP(CAboutDlg)
\r
171 DDX_Control(pDX, IDC_URL, m_cURL);
\r
172 DDX_Text(pDX, IDC_VERSION_INFORMATION, m_szVersionInformation);
\r
173 DDX_Text(pDX, IDC_LEGAL_COPYRIGHT, m_szLegalCopyright);
\r
177 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
\r
178 //{{AFX_MSG_MAP(CAboutDlg)
\r
180 ON_BN_CLICKED(IDC_URL, OnUrl)
\r
186 // App command to run the dialog
\r
187 void CXkeymacsApp::OnAppAbout()
\r
189 CAboutDlg aboutDlg;
\r
190 aboutDlg.DoModal();
\r
193 /////////////////////////////////////////////////////////////////////////////
\r
194 // CXkeymacsApp message handlers
\r
197 int CXkeymacsApp::ExitInstance()
\r
199 // TODO: Add your specialized code here and/or call the base class
\r
201 if (m_Instance == FirstInstance) {
\r
202 ReleaseMutex( m_hMutex );
\r
203 CloseHandle( m_hMutex );
\r
205 m_pMainWnd->DestroyWindow();
\r
210 return CWinApp::ExitInstance();
\r
213 void CAboutDlg::OnOK()
\r
215 // TODO: Add extra validation here
\r
220 void CAboutDlg::OnClose()
\r
222 // TODO: Add your message handler code here and/or call default
\r
223 CDialog::OnClose();
\r
226 void CAboutDlg::OnUrl()
\r
228 // TODO: Add your message handler code here and/or call default
\r
230 m_cURL.GetWindowText(szURL);
\r
232 ShellExecute(m_hWnd, NULL, szURL, NULL, NULL, SW_SHOWNORMAL);
\r
235 HBRUSH CAboutDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
\r
237 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
\r
239 // TODO: Change any attributes of the DC here
\r
240 COLORREF crBlue = RGB(0, 0, 0xff);
\r
242 if (pWnd == &m_cURL) {
\r
243 pDC->SetTextColor(crBlue);
\r
246 // TODO: Return a different brush if the default is not desired
\r
250 BOOL CAboutDlg::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message)
\r
252 // TODO: Add your message handler code here and/or call default
\r
254 m_cURL.GetWindowRect(rect);
\r
257 ::GetCursorPos(&p);
\r
259 if (rect.PtInRect(p)) {
\r
260 HCURSOR hCursor = (HCURSOR)LoadImage(theApp.m_hInstance, MAKEINTRESOURCE(IDC_HAND_CURSOR),
\r
261 IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
\r
262 SetCursor(hCursor);
\r
266 return CDialog::OnSetCursor(pWnd, nHitTest, message);
\r