This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
frameDTCReader.cpp
executable file
·215 lines (166 loc) · 5.27 KB
/
frameDTCReader.cpp
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*/
frameDTCReader.cpp (2005.07.31)
/*/
#include <wfc.h>
#include "frameDTCReader.h"
#include "handlerError.h"
#include "definitionLocal.h"
#include "resource.h"
#include "definitionError.h"
#include "frameList.h"
extern void nuke();
extern void OutputString(CString sMessage,unsigned short usMessageType = 0);
IMPLEMENT_DYNCREATE(frameDTCReader, CFrameWnd)
BEGIN_MESSAGE_MAP(frameDTCReader, CFrameWnd)
//{{AFX_MSG_MAP(frameDTCReader
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_MESSAGE(MESSAGE_UPDATECURRENTDTC,OnUpdateCurrentDTC)
ON_MESSAGE(MESSAGE_UPDATEHISTORICDTC,OnUpdateHistoricDTC)
END_MESSAGE_MAP()
frameDTCReader::frameDTCReader()
{
lpFont = NULL;
lpSplitter = NULL;
lpParent = NULL;
}
frameDTCReader::~frameDTCReader()
{
if(lpSplitter != NULL)
delete lpSplitter;
if(lpFont != NULL)
delete lpFont;
}
BOOL frameDTCReader::OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext* pContext)
{
CString sError;
TRYTRY
EXCEPTION_BOOKMARK(__LINE__)
if(!CFrameWnd::OnCreateClient(lpcs,pContext))
return FALSE;
EXCEPTION_BOOKMARK(__LINE__)
RECT rect;
GetClientRect(&rect);
EXCEPTION_BOOKMARK(__LINE__)
if((lpSplitter = new CSplitterWnd) == NULL)
{
sError.Format("Memory Error - frameDTCReader::OnClientCreate() [lpSplitter] : %i [0x%X]",GetLastError(),GetLastError());
OutputString(sError,MESSAGETYPE_ERROR);
}
lpSplitter->CreateStatic(this,2,1);
lpSplitter->CreateView(0,0,RUNTIME_CLASS(frameList),CSize(100,100),pContext);
lpSplitter->CreateView(1,0,RUNTIME_CLASS(frameList),CSize(100,100),pContext);
EXCEPTION_BOOKMARK(__LINE__)
lpFont = new CFont;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 0xfffffff5;
lf.lfWeight = FW_REGULAR;
lf.lfOutPrecision = OUT_STROKE_PRECIS;
lf.lfClipPrecision = CLIP_STROKE_PRECIS;
lf.lfQuality = DRAFT_QUALITY;
lf.lfPitchAndFamily = 0x22;
lf.lfCharSet = 0;
strcpy(lf.lfFaceName,"Tahoma");
lpFont->CreateFontIndirect(&lf);
EXCEPTION_BOOKMARK(__LINE__)
frameList* lpFrameList = NULL;
lpFrameList = (frameList*)lpSplitter->GetPane(0,0);
lpFrameList->SetFont(lpFont);
lpFrameList->SetViewStyle(LVS_REPORT,LVS_EX_FULLROWSELECT);
lpFrameList->AddColumn("Current Trouble Code",150);
lpFrameList->AddColumn("Current Trouble Code Description",400);
EXCEPTION_BOOKMARK(__LINE__)
lpFrameList = (frameList*)lpSplitter->GetPane(1,0);
lpFrameList->SetFont(lpFont);
lpFrameList->SetViewStyle(LVS_REPORT,LVS_EX_FULLROWSELECT);
lpFrameList->AddColumn("Historic Trouble Code",150);
lpFrameList->AddColumn("Historic Trouble Code Description",400);
CATCHCATCH("frameDTCReader::OnCreateClient()");
if(bExceptionFlag == EXEPT_CONTINUE)
return FALSE;
if(bExceptionFlag == EXEPT_ABORT)
nuke();
return TRUE;
}
void frameDTCReader::ResizeSplitter()
{
CString sError;
TRYTRY
EXCEPTION_BOOKMARK(__LINE__)
RECT rect;
::GetClientRect(lpParent->lpMainFrame->splitterWndLeft.m_hWnd,&rect);
lpSplitter->SetRowInfo(0,(rect.bottom * lpParent->GetRegistryValue("Settings","splitterDTCReader",50)) / 100,40);
lpSplitter->RecalcLayout();
CATCHCATCH("frameDTCReader::ResizeSplitter()");
if(bExceptionFlag == EXEPT_CONTINUE)
{}
if(bExceptionFlag == EXEPT_ABORT)
nuke();
return;
}
void frameDTCReader::OnUpdateCurrentDTC(WPARAM wParam,LPARAM lParam)
{
CString sError;
LPSTRUCT_DTCITEM lpDTCItem = (LPSTRUCT_DTCITEM)lParam;
TRYTRY
EXCEPTION_BOOKMARK(__LINE__)
frameList* lpList_current = NULL;
lpList_current = (frameList*)lpSplitter->GetPane(0,0);
EXCEPTION_BOOKMARK(__LINE__)
LVFINDINFO findInfo;
findInfo.flags = LVFI_PARTIAL|LVFI_STRING;
findInfo.psz = lpDTCItem->szID;
if(lpList_current->lpList->FindItem(&findInfo) == -1)
{
lpList_current->lpList->InsertItem(lpList_current->lpList->GetItemCount(),lpDTCItem->szID);
lpList_current->lpList->SetItemText(lpList_current->lpList->GetItemCount()-1,1,lpDTCItem->szLabel);
}
CATCHCATCH("frameDTCReader::OnUpdateCurrentDTC()");
if(bExceptionFlag == EXEPT_CONTINUE)
{}
if(bExceptionFlag == EXEPT_ABORT)
nuke();
return;
}
void frameDTCReader::OnUpdateHistoricDTC(WPARAM wParam,LPARAM lParam)
{
CString sError;
LPSTRUCT_DTCITEM lpDTCItem = (LPSTRUCT_DTCITEM)lParam;
TRYTRY
EXCEPTION_BOOKMARK(__LINE__)
frameList* lpList_historic = NULL;
lpList_historic = (frameList*)lpSplitter->GetPane(1,0);
EXCEPTION_BOOKMARK(__LINE__)
LVFINDINFO findInfo;
findInfo.flags = LVFI_PARTIAL|LVFI_STRING;
findInfo.psz = lpDTCItem->szID;
if(lpList_historic->lpList->FindItem(&findInfo) == -1)
{
lpList_historic->lpList->InsertItem(lpList_historic->lpList->GetItemCount(),lpDTCItem->szID);
lpList_historic->lpList->SetItemText(lpList_historic->lpList->GetItemCount()-1,1,lpDTCItem->szLabel);
}
CATCHCATCH("frameDTCReader::OnUpdateHistoricDTC()");
if(bExceptionFlag == EXEPT_CONTINUE)
{}
if(bExceptionFlag == EXEPT_ABORT)
nuke();
return;
}
void frameDTCReader::OnPauseDTC()
{
CString sError;
TRYTRY
EXCEPTION_BOOKMARK(__LINE__)
if(lpParent->bThreadDTCQuery == TRUE)
lpParent->StopDTCQueryThread();
else
lpParent->StartDTCQueryThread();
CATCHCATCH("frameRealtime::OnPauseDataCapture()");
if(bExceptionFlag == EXEPT_CONTINUE)
{}
if(bExceptionFlag == EXEPT_ABORT)
nuke();
return;
}