-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDialogEx.cpp
More file actions
109 lines (92 loc) · 2.54 KB
/
Copy pathDialogEx.cpp
File metadata and controls
109 lines (92 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyleft 2004 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
/*
chris korda
revision history:
rev date comments
00 19apr04 initial version
01 05oct04 no more child dialogs; remove OnNcActivate
02 07oct04 override EnableToolTips to make it virtual
customized dialog base class
*/
// DialogEx.cpp : implementation file
//
#include "stdafx.h"
#include "Resource.h"
#include "DialogEx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogEx dialog
CDialogEx::CDialogEx(UINT nIDTemplate, UINT nIDAccel, CWnd* pParent /*=NULL*/)
: CDialog(nIDTemplate, pParent)
{
//{{AFX_DATA_INIT(CDialogEx)
//}}AFX_DATA_INIT
m_Parent = NULL;
m_Accel = LOADACCEL(nIDAccel);
}
CDialogEx::~CDialogEx()
{
DestroyWindow();
}
void CDialogEx::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogEx)
//}}AFX_DATA_MAP
}
void CDialogEx::SetParent(CWnd *Parent)
{
m_Parent = Parent;
CDialog::SetParent(Parent);
}
void CDialogEx::CenterWindowEx(const CPoint& Offset, bool Repaint)
{
if (m_Parent == NULL)
return;
// center dialog's top left corner within parent window
CRect vr, dr;
m_Parent->GetClientRect(vr);
GetWindowRect(dr);
MoveWindow(vr.Width() / 2 + Offset.x, vr.Height() / 2 + Offset.y,
dr.Width(), dr.Height(), Repaint);
}
BOOL CDialogEx::EnableToolTips(BOOL bEnable)
{
return(CDialog::EnableToolTips(bEnable));
}
BEGIN_MESSAGE_MAP(CDialogEx, CDialog)
//{{AFX_MSG_MAP(CDialogEx)
ON_WM_HSCROLL()
ON_WM_CLOSE()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTip)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogEx message handlers
BOOL CDialogEx::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
if (TranslateAccelerator(m_hWnd, m_Accel, pMsg))
return(TRUE);
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CDialogEx::OnToolTip(UINT id, NMHDR* pTTTStruct, LRESULT* pResult)
{
LPNMTTDISPINFO ttp = LPNMTTDISPINFO(pTTTStruct);
UINT nID = ttp->hdr.idFrom;
if (ttp->uFlags & TTF_IDISHWND) // idFrom can be HWND or ID
nID = ::GetDlgCtrlID((HWND)nID);
CString s;
s.LoadString(nID);
strcpy(ttp->szText, s);
return(TRUE);
}