Scope
LogView.cpp
1 #include "StdAfx.h"
2 #include "LogView.h"
3 
4 namespace scope {
5  namespace gui {
6 
7 BOOL CLogView::PreTranslateMessage(MSG* pMsg) {
8  pMsg;
9  return FALSE;
10 }
11 
12 int CLogView::OnCreate(LPCREATESTRUCT lpCreateStruct) {
13  CFont font;
14  CLogFont lf;
15  lf.lfWeight = FW_NORMAL;
16  lf.SetHeight(11);
17  SecureHelper::strcpy_x(lf.lfFaceName, LF_FACESIZE, L"Calibri");
18  font.CreateFontIndirect(&lf);
19  SetFont(font);
20  LimitText(128000);
21 
22  return DefWindowProc(); // Complete creation...
23 }
24 
25 LRESULT CLogView::OnChar(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled) {
26  // ignore without a beep
27  switch (wParam) {
28  case '\t': // tab
29  case '\r': //Carriage return
31  return 0;
32  }
33  return DefWindowProc(uMsg, wParam, lParam);
34 }
35 
36 BOOL CLogView::SaveFile(LPTSTR lpstrFilePath) {
37  _ASSERTE(lpstrFilePath != NULL);
38 
39  HANDLE hFile = ::CreateFile(lpstrFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
40  if(hFile == INVALID_HANDLE_VALUE)
41  return FALSE;
42 
43  EDITSTREAM es;
44  es.dwCookie = (DWORD)hFile;
45  es.dwError = 0;
46  es.pfnCallback = StreamWriteCallback;
47  StreamOut(SF_TEXT, es);
48 
49  ::CloseHandle(hFile);
50 
51  return !(BOOL)es.dwError;
52 }
53 
54 DWORD CALLBACK CLogView::StreamWriteCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG FAR *pcb) {
55  _ASSERTE(dwCookie != 0);
56  _ASSERTE(pcb != NULL);
57 
58  return !::WriteFile((HANDLE)dwCookie, pbBuff, cb, (LPDWORD)pcb, NULL);
59 }
60 
61 }}
void GetUserLoggings()
Gets the text in the logbook window and calls FlushLogbox.
Definition: ScopeLogger.cpp:42
scope::ScopeLogger scope_logger
our ScopeLogger here
Definition: LogView.h:19
This is the include file for standard system include files, or project specific include files that ar...
BOOL SaveFile(LPTSTR lpstrFilePath)
Saves the logwindow text into a file.
Definition: LogView.cpp:36
static DWORD CALLBACK StreamWriteCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG FAR *pcb)
Callback for actual writing to disk.
Definition: LogView.cpp:54