OSDN Git Service

4f4b918c0276259344246a50eda62e81430baa91
[winmerge-jp/winmerge-jp.git] / Src / OpenFrm.cpp
1 // OpenFrm.cpp : implementation of the COpenFrame class
2 //
3 #include "stdafx.h"
4 #include "OpenFrm.h"
5 #include "OptionsDef.h"
6 #include "OptionsMgr.h"
7 #include "MergeFrameCommon.h"
8
9 #ifdef _DEBUG
10 #define new DEBUG_NEW
11 #endif
12
13
14 // COpenFrame
15
16 IMPLEMENT_DYNCREATE(COpenFrame, CMergeFrameCommon)
17
18 BEGIN_MESSAGE_MAP(COpenFrame, CMergeFrameCommon)
19         //{{AFX_MSG_MAP(COpenFrame)
20         ON_WM_ERASEBKGND()
21         ON_WM_NCHITTEST()
22         ON_WM_WINDOWPOSCHANGING()
23         //}}AFX_MSG_MAP
24 END_MESSAGE_MAP()
25
26
27 // COpenFrame construction/destruction
28
29 COpenFrame::COpenFrame()
30 {
31         // TODO: add member initialization code here
32 }
33
34 COpenFrame::~COpenFrame()
35 {
36 }
37
38
39 BOOL COpenFrame::PreCreateWindow(CREATESTRUCT& cs)
40 {
41         // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
42         if( !CMDIChildWnd::PreCreateWindow(cs) )
43                 return FALSE;
44         cs.style |= WS_CLIPCHILDREN;
45         return TRUE;
46 }
47
48 BOOL COpenFrame::OnEraseBkgnd(CDC* pDC)
49 {
50         CRect rect;
51         GetClientRect(&rect);
52         pDC->FillSolidRect(&rect, ::GetSysColor(COLOR_APPWORKSPACE));
53         return TRUE;
54 }
55
56 LRESULT COpenFrame::OnNcHitTest(CPoint point)
57 {
58         switch (LRESULT const ht = CMDIChildWnd::OnNcHitTest(point))
59         {
60         case HTTOP:
61         case HTBOTTOM:
62         case HTLEFT:
63         case HTTOPLEFT:
64         case HTBOTTOMLEFT:
65                 return HTCAPTION;
66         case HTTOPRIGHT:
67         case HTBOTTOMRIGHT:
68                 return HTRIGHT;
69         default:
70                 return ht;
71         }
72 }
73
74 void COpenFrame::OnWindowPosChanging(WINDOWPOS* lpwndpos)
75 {
76         // Retain frame sizes during tile operations (tolerate overlapping)
77         if ((lpwndpos->flags & (SWP_NOSIZE | SWP_NOOWNERZORDER)) == 0 && !IsZoomed())
78         {
79                 if (CScrollView *const pView = static_cast<CScrollView*>(GetActiveView()))
80                 {
81                         CRect rc;
82                         pView->GetWindowRect(&rc);
83                         CalcWindowRect(&rc, CWnd::adjustOutside);
84                         lpwndpos->cx = rc.Width();
85                         lpwndpos->cy = rc.Height();
86                 }
87         }
88 }
89
90 void COpenFrame::ActivateFrame(int nCmdShow) 
91 {
92         CMergeFrameCommon::ActivateFrame(nCmdShow);
93         if (CView *const pView = GetActiveView())
94         {
95                 WINDOWPLACEMENT wp = {};
96                 wp.length = sizeof wp;
97                 GetWindowPlacement(&wp);
98                 CRect rc;
99                 pView->GetWindowRect(&rc);
100                 CalcWindowRect(&rc, CWnd::adjustOutside);
101                 wp.rcNormalPosition.right = wp.rcNormalPosition.left + rc.Width();
102                 wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + rc.Height();
103                 SetWindowPlacement(&wp);
104                 pView->ShowWindow(SW_SHOW);
105         }
106 }
107
108 /**
109  * @brief Update any resources necessary after a GUI language change
110  */
111 void COpenFrame::UpdateResources()
112 {
113 }
114
115 /**
116  * @brief Save the window's position, free related resources, and destroy the window
117  */
118 BOOL COpenFrame::DestroyWindow() 
119 {
120         SaveWindowState();
121         return CMDIChildWnd::DestroyWindow();
122 }
123
124 // COpenFrame message handlers