home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- //
- // mainfrm.cpp : Implementation of the CMainFrame class
- //
- /////////////////////////////////////////////////////////////////////////////
- //
- // (C) Copyright Black Diamond Consulting, Inc 1996. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that Black
- // Diamond Consulting has no warranty obligations or liability
- // for any Sample Application Files which are modified.
- //
- // Revision History:
- //
- /////////////////////////////////////////////////////////////////////////////
-
- #include "stdafx.h"
- #include <afxpriv.h>
- #include "mainfrm.h"
-
- #ifndef __HOTSPOT_H__
- #include "hotspot.h"
- #endif
-
- #ifndef __SVVIEW_H__
- #include "SVView.h"
- #endif
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
-
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
-
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_ERASEBKGND()
- ON_WM_CREATE()
- ON_WM_GETMINMAXINFO()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // arrays of IDs used to initialize control bars
-
- static UINT BASED_CODE indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
-
- static const char* WINDOW_SETTINGS_SECTION_NAME = "Window Settings";
- static const char* LOCATION_SETTING_NAME = "Location";
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
-
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
-
- CMainFrame::~CMainFrame()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
-
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status bar\n");
- return -1; // fail to create
- }
-
- return 0;
- }
-
- BOOL CMainFrame::OnEraseBkgnd(CDC* pDC)
- {
- CRect rect;
- this->GetClientRect(rect);
- pDC->FillRect(rect, CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
-
- return TRUE;
- }
-
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- char buffer [256];
-
- if (GetPrivateProfileString(WINDOW_SETTINGS_SECTION_NAME,
- LOCATION_SETTING_NAME,
- "100 100 600 400",
- buffer, sizeof(buffer), AfxGetApp()->m_pszProfileName))
- {
- sscanf(buffer, "%i%i%i%i", &cs.x, &cs.y, &cs.cx, &cs.cy);
- }
-
- return CFrameWnd::PreCreateWindow(cs);
- }
-
- BOOL CMainFrame::DestroyWindow()
- {
- char buffer [256];
- CRect rect;
-
- this->GetWindowRect(&rect);
-
- sprintf(buffer, "%i %i %i %i", rect.left, rect.top, rect.Width(), rect.Height());
-
- WritePrivateProfileString( WINDOW_SETTINGS_SECTION_NAME,
- LOCATION_SETTING_NAME,
- buffer, AfxGetApp()->m_pszProfileName);
-
- return CFrameWnd::DestroyWindow();
- }
-
- void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
- {
- CRect rect;
- SIZE sz;
-
- CSVViewerView *pView = (CSVViewerView *)GetActiveView();
- if( pView && pView->IsKindOf(RUNTIME_CLASS(CSVViewerView)) )
- {
- pView->GetMaxViewSize(&sz);
-
- // if the initial view size is 0, then don't set the limit
- if (sz.cx && sz.cy)
- {
- long lExStyle = GetWindowLong( m_hWnd, GWL_EXSTYLE );
- long lStyle = GetWindowLong( m_hWnd, GWL_STYLE );
-
- rect.SetRect( 0, 0, sz.cx, sz.cy );
- AdjustWindowRectEx( &rect, lStyle, TRUE, lExStyle );
-
- lpMMI->ptMaxTrackSize.x = rect.Width();
- lpMMI->ptMaxSize.y = rect.Height();
-
- // Add in the status bar window height
- m_wndStatusBar.GetWindowRect( &rect );
- lpMMI->ptMaxSize.y += rect.Height();
-
- lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
-
- lpMMI->ptMaxSize.x = min(lpMMI->ptMaxSize.x, lpMMI->ptMaxTrackSize.x);
- return;
- }
- }
- }
-