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
|
// MsDevCallerListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include <atlbase.h>
#include "MsDevCallerListCtrl.h"
#include <msvc6/testrunner/TestRunner.h>
#include <msvc6/DSPlugin/TestRunnerDSPluginVC6.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MsDevCallerListCtrl
MsDevCallerListCtrl::MsDevCallerListCtrl()
: m_lineNumberSubItem( 3 )
, m_fileNameSubItem( 4 )
{
m_comInitialized = SUCCEEDED( CoInitialize(NULL) );
}
MsDevCallerListCtrl::~MsDevCallerListCtrl()
{
if ( m_comInitialized )
CoUninitialize();
}
void
MsDevCallerListCtrl::setLineNumberSubItem( int subItemIndex )
{
m_lineNumberSubItem = subItemIndex;
}
void
MsDevCallerListCtrl::setFileNameSubItem( int fileNameItemIndex )
{
m_fileNameSubItem = fileNameItemIndex;
}
BEGIN_MESSAGE_MAP(MsDevCallerListCtrl, CListCtrl)
//{{AFX_MSG_MAP(MsDevCallerListCtrl)
ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MsDevCallerListCtrl message handlers
void MsDevCallerListCtrl::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
HRESULT hr = S_OK;
int hotItem = 0;
CComPtr< ITestRunnerDSPlugin> pIDSPlugin;
hr = CoCreateInstance( CLSID_DSAddIn, NULL, CLSCTX_LOCAL_SERVER, IID_ITestRunnerDSPlugin,
reinterpret_cast< void**>(&pIDSPlugin));
if ( SUCCEEDED( hr))
{
CPoint pt;
UINT flags = 0;
CString lineNumber, fileName;
GetCursorPos( &pt);
ScreenToClient( &pt);
// some dirty hack to get some selection
// should get the border-width + 1, but WINDOWINFO
// is not supported in Win95
pt.x = 5;
hotItem = HitTest( pt, &flags);
lineNumber = GetItemText( hotItem, m_lineNumberSubItem);
fileName = GetItemText( hotItem, m_fileNameSubItem);
pIDSPlugin->goToLineInSourceCode( CComBSTR( fileName), _ttoi( lineNumber));
}
*pResult = 0;
}
|