OSDN Git Service

Shell Extension for Windows 11 or later (5)
[winmerge-jp/winmerge-jp.git] / Src / LocationBar.cpp
1 /** 
2  * @file  LocationBar.cpp
3  *
4  * @brief Implementation file for CLocationBar
5  *
6  */
7
8 #include "stdafx.h"
9 #include "LocationBar.h"
10
11 #ifdef _DEBUG
12 #define new DEBUG_NEW
13 #endif
14
15 IMPLEMENT_DYNAMIC(CLocationBar, TViewBarBase);
16
17 //////////////////////////////////////////////////////////////////////
18 // Construction/Destruction
19 //////////////////////////////////////////////////////////////////////
20
21 CLocationBar::CLocationBar()
22 : m_hwndFrame(nullptr)
23 {
24 }
25
26
27 CLocationBar::~CLocationBar()
28 {
29 }
30
31
32 BEGIN_MESSAGE_MAP(CLocationBar, TViewBarBase)
33         //{{AFX_MSG_MAP(CRegBar)
34         ON_WM_CREATE()
35         ON_WM_LBUTTONDOWN()
36         ON_WM_SIZE()
37         ON_WM_WINDOWPOSCHANGED()
38         //}}AFX_MSG_MAP
39 END_MESSAGE_MAP()
40
41 /////////////////////////////////////////////////////////////////////////////
42 // CLocationBar message handlers
43
44 /**
45 * @brief Just create ourself
46 *
47 * @note The control are created in the parent frame CMergeEditFrame
48 *
49 */
50 BOOL CLocationBar::Create(
51         CWnd* pParentWnd,
52         LPCTSTR lpszWindowName,
53         DWORD dwStyle,
54         UINT nID)
55 {
56         return TViewBarBase::Create(
57                 lpszWindowName,
58                 pParentWnd,
59                 nID,
60                 dwStyle);
61 }
62
63
64 ///     Create the frame window associated with the view bar.
65 int CLocationBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
66 {
67         if (TViewBarBase::OnCreate(lpCreateStruct) == -1)
68                 return -1;
69
70         SetSCBStyle(SCBS_EDGELEFT | SCBS_EDGERIGHT | SCBS_SIZECHILD);
71         return 0;
72 }
73
74 /**
75 * @note The window must always be docked after movement
76 * there are too much troubles if we get reparented to some minidockbar 
77 *
78 */
79 void CLocationBar::OnLButtonDown(UINT nFlags, CPoint point)
80 {
81         TViewBarBase::OnLButtonDown(nFlags, point);
82         if (m_pDockBar != nullptr)
83         {
84                 if (!IsVertDocked())
85                         m_pDockContext->ToggleDocking();
86         }
87 }
88
89 void CLocationBar::OnSize(UINT nType, int cx, int cy) 
90 {
91         TViewBarBase::OnSize(nType, cx, cy);
92 }
93
94 /** 
95  * @brief Informs parent frame (CMergeEditFrame) when bar is closed.
96  *
97  * After bar is closed parent frame saves bar states.
98  */
99 void CLocationBar::OnWindowPosChanged(WINDOWPOS* lpwndpos)
100 {
101         TViewBarBase::OnWindowPosChanged(lpwndpos);
102
103         if (m_hwndFrame != nullptr)
104         {
105                 // If WINDOWPOS.flags has SWP_HIDEWINDOW flag set
106                 if ((lpwndpos->flags & SWP_HIDEWINDOW) != 0)
107                         ::PostMessage(m_hwndFrame, MSG_STORE_PANESIZES, 0, 0);
108         }
109 }
110
111 /** 
112  * @brief Stores HWND of frame window (CMergeEditFrame).
113  */
114 void CLocationBar::SetFrameHwnd(HWND hwndFrame)
115 {
116         m_hwndFrame = hwndFrame;
117 }
118 /**
119  * @brief Update any resources necessary after a GUI language change
120  */
121 void CLocationBar::UpdateResources()
122 {
123         String sCaption = _("Location Pane");
124         SetWindowText(sCaption.c_str());
125 }