1 // **************************************************************************************
2 // File: LeashFrame.cpp
3 // By: Arthur David Leather
4 // Created: 12/02/98
5 // Copyright @1998 Massachusetts Institute of Technology - All rights reserved.
6 // Description: CPP file for LeashFrame.h. Contains variables and functions
7 // for Leash
8 //
9 // History:
10 //
11 // MM/DD/YY Inits Description of Change
12 // 12/02/98 ADL Original
13 // **************************************************************************************
14
15
16 #include "stdafx.h"
17 #include "LeashFrame.h"
18
19 #ifdef _DEBUG
20 #undef THIS_FILE
21 static char BASED_CODE THIS_FILE[] = __FILE__;
22 #endif
23 ///////////////////////////////////////////////////////////////
24 // CLeashFrame
25
26 const CRect CLeashFrame::s_rectDefault(0, 0, 740, 400); // static public (l,t,r,b)
27 const char CLeashFrame::s_profileHeading[] = "Window size";
28 const char CLeashFrame::s_profileRect[] = "Rect";
29 const char CLeashFrame::s_profileIcon[] = "icon";
30 const char CLeashFrame::s_profileMax[] = "max";
31 const char CLeashFrame::s_profileTool[] = "tool";
32 const char CLeashFrame::s_profileStatus[] = "status";
33
IMPLEMENT_DYNAMIC(CLeashFrame,CFrameWndEx)34 IMPLEMENT_DYNAMIC(CLeashFrame, CFrameWndEx)
35
36 BEGIN_MESSAGE_MAP(CLeashFrame, CFrameWndEx)
37 //{{AFX_MSG_MAP(CLeashFrame)
38 ON_WM_DESTROY()
39 //}}AFX_MSG_MAP
40 END_MESSAGE_MAP()
41
42 ///////////////////////////////////////////////////////////////
43 CLeashFrame::CLeashFrame()
44 {
45 m_bFirstTime = TRUE;
46 }
47
48 ///////////////////////////////////////////////////////////////
~CLeashFrame()49 CLeashFrame::~CLeashFrame()
50 {
51 }
52
53 ///////////////////////////////////////////////////////////////
OnDestroy()54 void CLeashFrame::OnDestroy()
55 {
56 CString strText;
57 BOOL bIconic, bMaximized;
58
59 WINDOWPLACEMENT wndpl;
60 wndpl.length = sizeof(WINDOWPLACEMENT);
61 // gets current window position and
62 // iconized/maximized status
63 BOOL bRet = GetWindowPlacement(&wndpl);
64 if (wndpl.showCmd == SW_SHOWNORMAL)
65 {
66 bIconic = FALSE;
67 bMaximized = FALSE;
68 }
69 else if (wndpl.showCmd == SW_SHOWMAXIMIZED)
70 {
71 bIconic = FALSE;
72 bMaximized = TRUE;
73 }
74 else if (wndpl.showCmd == SW_SHOWMINIMIZED)
75 {
76 bIconic = TRUE;
77 if (wndpl.flags)
78 {
79 bMaximized = TRUE;
80 }
81 else
82 {
83 bMaximized = FALSE;
84 }
85 }
86
87 strText.Format("%04d %04d %04d %04d",
88 wndpl.rcNormalPosition.left,
89 wndpl.rcNormalPosition.top,
90 wndpl.rcNormalPosition.right,
91 wndpl.rcNormalPosition.bottom);
92
93 AfxGetApp()->WriteProfileString(s_profileHeading,
94 s_profileRect, strText);
95
96 AfxGetApp()->WriteProfileInt(s_profileHeading,
97 s_profileIcon, bIconic);
98
99 AfxGetApp()->WriteProfileInt(s_profileHeading,
100 s_profileMax, bMaximized);
101
102 SaveBarState(AfxGetApp()->m_pszProfileName);
103
104 CFrameWndEx::OnDestroy();
105 }
106
107 ///////////////////////////////////////////////////////////////
ActivateFrame(int nCmdShow)108 void CLeashFrame::ActivateFrame(int nCmdShow)
109 {
110
111 if (m_bFirstTime)
112 {
113 m_bFirstTime = FALSE;
114
115 }
116
117 CFrameWndEx::ActivateFrame(nCmdShow);
118 }
119