ReactOS  0.4.12-dev-36-g472787f
splitter.cpp File Reference
#include "rapps.h"
Include dependency graph for splitter.cpp:

Go to the source code of this file.

Functions

int GetHSplitterPos (VOID)
 
VOID SetHSplitterPos (int Pos)
 
LRESULT CALLBACK HSplitterWindowProc (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL CreateHSplitBar (HWND hwnd)
 
LRESULT CALLBACK VSplitterWindowProc (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL CreateVSplitBar (HWND hwnd)
 

Variables

HWND hVSplitter = NULL
 
HWND hHSplitter = NULL
 
static int HSplitterPos = 0
 

Function Documentation

◆ CreateHSplitBar()

BOOL CreateHSplitBar ( HWND  hwnd)

Definition at line 121 of file splitter.cpp.

122 {
123  WCHAR szWindowClass[] = L"HSplitterWindowClass";
124  WNDCLASSEXW WndClass = {0};
125 
126  WndClass.cbSize = sizeof(WndClass);
127  WndClass.lpszClassName = szWindowClass;
128  WndClass.lpfnWndProc = HSplitterWindowProc;
129  WndClass.hInstance = hInst;
130  WndClass.style = CS_HREDRAW | CS_VREDRAW;
131  WndClass.hCursor = LoadCursor(0, IDC_SIZENS);
132  WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
133 
134  if (RegisterClassExW(&WndClass) == (ATOM) 0)
135  {
136  /* TODO: Show error message */
137  return FALSE;
138  }
139 
141  szWindowClass,
142  NULL,
144  205, 180, 465, SPLIT_WIDTH,
145  hwnd,
146  NULL,
147  hInst,
148  NULL);
149 
150  if (hHSplitter == NULL)
151  {
152  /* TODO: Show error message */
153  return FALSE;
154  }
155 
158 
159  return TRUE;
160 }
#define TRUE
Definition: types.h:120
WORD ATOM
Definition: dimm.idl:113
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define CS_HREDRAW
Definition: winuser.h:648
HWND hHSplitter
Definition: splitter.cpp:12
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SPLIT_WIDTH
Definition: eventvwr.c:62
#define IDC_SIZENS
Definition: winuser.h:690
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
const TCHAR szWindowClass[]
Definition: magnifier.c:29
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
LPCWSTR lpszClassName
Definition: winuser.h:3179
#define CS_VREDRAW
Definition: winuser.h:653
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
HINSTANCE hInstance
Definition: winuser.h:3174
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define COLOR_BTNFACE
Definition: winuser.h:918
HCURSOR hCursor
Definition: winuser.h:3176
UINT style
Definition: winuser.h:3170
#define LoadCursor
Definition: winuser.h:5678
WNDPROC lpfnWndProc
Definition: winuser.h:3171
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT CALLBACK HSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: splitter.cpp:30
#define WS_VISIBLE
Definition: pedump.c:620
WCHAR WndClass[]
Definition: capicon.c:23

◆ CreateVSplitBar()

BOOL CreateVSplitBar ( HWND  hwnd)

Definition at line 261 of file splitter.cpp.

262 {
263  WCHAR szWindowClass[] = L"VSplitterWindowClass";
264  WNDCLASSEXW WndClass = {0};
265 
266  WndClass.cbSize = sizeof(WndClass);
267  WndClass.lpszClassName = szWindowClass;
268  WndClass.lpfnWndProc = VSplitterWindowProc;
269  WndClass.hInstance = hInst;
270  WndClass.style = CS_HREDRAW | CS_VREDRAW;
271  WndClass.hCursor = LoadCursor(0, IDC_SIZEWE);
272  WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
273 
274  if (RegisterClassExW(&WndClass) == (ATOM) 0)
275  {
276  /* TODO: Show error message */
277  return FALSE;
278  }
279 
281  szWindowClass,
282  NULL,
284  201, 28, SPLIT_WIDTH, 350,
285  hwnd,
286  NULL,
287  hInst,
288  NULL);
289 
290  if (!hVSplitter)
291  {
292  /* TODO: Show error message */
293  return FALSE;
294  }
295 
298 
299  return TRUE;
300 }
#define IDC_SIZEWE
Definition: winuser.h:689
#define TRUE
Definition: types.h:120
WORD ATOM
Definition: dimm.idl:113
__wchar_t WCHAR
Definition: xmlstorage.h:180
LRESULT CALLBACK VSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: splitter.cpp:164
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define CS_HREDRAW
Definition: winuser.h:648
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND hVSplitter
Definition: splitter.cpp:11
#define SPLIT_WIDTH
Definition: eventvwr.c:62
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
const TCHAR szWindowClass[]
Definition: magnifier.c:29
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
LPCWSTR lpszClassName
Definition: winuser.h:3179
#define CS_VREDRAW
Definition: winuser.h:653
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
HINSTANCE hInstance
Definition: winuser.h:3174
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define COLOR_BTNFACE
Definition: winuser.h:918
HCURSOR hCursor
Definition: winuser.h:3176
UINT style
Definition: winuser.h:3170
#define LoadCursor
Definition: winuser.h:5678
WNDPROC lpfnWndProc
Definition: winuser.h:3171
HINSTANCE hInst
Definition: dxdiag.c:13
#define WS_VISIBLE
Definition: pedump.c:620
WCHAR WndClass[]
Definition: capicon.c:23

◆ GetHSplitterPos()

int GetHSplitterPos ( VOID  )

Definition at line 17 of file splitter.cpp.

Referenced by VSplitterWindowProc().

18 {
19  return HSplitterPos;
20 }
static int HSplitterPos
Definition: splitter.cpp:14

◆ HSplitterWindowProc()

LRESULT CALLBACK HSplitterWindowProc ( HWND  hwnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 30 of file splitter.cpp.

Referenced by CreateHSplitBar().

31 {
32  switch (Msg)
33  {
34  case WM_CREATE:
35  {
37  }
38  break;
39 
40  case WM_LBUTTONDOWN:
41  {
42  SetCapture(hwnd);
43  }
44  break;
45 
46  case WM_LBUTTONUP:
47  case WM_RBUTTONDOWN:
48  if (GetCapture() == hwnd)
49  {
51  }
52  break;
53 
54  case WM_MOUSEMOVE:
55  if (GetCapture() == hwnd)
56  {
57  int Width = GetClientWindowWidth(hMainWnd) - GetWindowWidth(hTreeView) - SPLIT_WIDTH;
58  int NewPos;
59  HDWP hdwp;
60  POINT Point;
61 
62  GetCursorPos(&Point);
63  ScreenToClient(hMainWnd, &Point);
64 
65  NewPos = Point.y;
66 
68  break;
69 
70  if ((GetWindowHeight(hToolBar) + SPLIT_WIDTH) > NewPos)
71  break;
72 
73  SetHSplitterPos(NewPos);
74 
75  hdwp = BeginDeferWindowPos(3);
76 
77  /* Size HSplitBar */
78  if (hdwp)
79  hdwp = DeferWindowPos(hdwp,
80  hHSplitter,
81  0,
82  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
83  Point.y,
84  Width,
87 
88  /* Size ListView */
89  if (hdwp)
90  hdwp = DeferWindowPos(hdwp,
91  hListView,
92  0,
93  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
95  Width,
96  Point.y - GetWindowHeight(hToolBar),
98 
99  /* Size RichEdit */
100  if (hdwp)
101  hdwp = DeferWindowPos(hdwp,
102  hRichEdit,
103  0,
104  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
105  Point.y + SPLIT_WIDTH,
106  Width,
109 
110  if (hdwp)
111  EndDeferWindowPos(hdwp);
112  }
113  break;
114  }
115 
116  return DefWindowProc(hwnd, Msg, wParam, lParam);
117 }
HDWP WINAPI BeginDeferWindowPos(_In_ int)
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
HWND hHSplitter
Definition: splitter.cpp:12
HWND hToolBar
Definition: mplay32.c:17
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
WPARAM wParam
Definition: combotst.c:138
#define SPLIT_WIDTH
Definition: eventvwr.c:62
struct @1571 Msg[]
VOID SetHSplitterPos(int Pos)
Definition: splitter.cpp:23
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HWND WINAPI GetCapture(void)
Definition: message.c:2855
#define DefWindowProc
Definition: ros2win.h:31
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
INT GetClientWindowWidth(HWND hwnd)
Definition: misc.cpp:33
HWND hStatusBar
Definition: main.cpp:35
HWND hMainWnd
Definition: magnifier.c:33
struct Point Point
INT GetWindowHeight(HWND hwnd)
Definition: misc.cpp:25
HWND hListView
Definition: gui.cpp:29
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WM_LBUTTONUP
Definition: winuser.h:1753
INT GetWindowWidth(HWND hwnd)
Definition: misc.cpp:17
#define WM_MOUSEMOVE
Definition: winuser.h:1751
INT GetClientWindowHeight(HWND hwnd)
Definition: misc.cpp:41
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2864
#define WM_CREATE
Definition: winuser.h:1590
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139

◆ SetHSplitterPos()

VOID SetHSplitterPos ( int  Pos)

Definition at line 23 of file splitter.cpp.

Referenced by HSplitterWindowProc().

24 {
25  HSplitterPos = Pos;
26 }
static int HSplitterPos
Definition: splitter.cpp:14
ush Pos
Definition: deflate.h:92

◆ VSplitterWindowProc()

LRESULT CALLBACK VSplitterWindowProc ( HWND  hwnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 164 of file splitter.cpp.

Referenced by CreateVSplitBar().

165 {
166  switch (Msg)
167  {
168  case WM_LBUTTONDOWN:
169  SetCapture(hwnd);
170  break;
171 
172  case WM_LBUTTONUP:
173  case WM_RBUTTONDOWN:
174  if (GetCapture() == hwnd)
175  {
176  ReleaseCapture();
177  }
178  break;
179 
180  case WM_MOUSEMOVE:
181  if (GetCapture() == hwnd)
182  {
183  HDWP hdwp;
184  POINT Point;
185 
186  GetCursorPos(&Point);
187  ScreenToClient(hMainWnd, &Point);
188 
189  if ((GetClientWindowWidth(hMainWnd) - SPLIT_WIDTH) < Point.x)
190  break;
191 
192  if (SPLIT_WIDTH > Point.x)
193  break;
194 
195  hdwp = BeginDeferWindowPos(5);
196 
197  /* Size VSplitBar */
198  if (hdwp)
199  hdwp = DeferWindowPos(hdwp,
200  hwnd,
201  0,
202  Point.x,
204  SPLIT_WIDTH,
207 
208  /* Size TreeView */
209  if (hdwp)
210  hdwp = DeferWindowPos(hdwp,
211  hTreeView,
212  0,
213  0,
215  Point.x,
218 
219  /* Size ListView */
220  if (hdwp)
221  hdwp = DeferWindowPos(hdwp,
222  hListView,
223  0,
224  Point.x + SPLIT_WIDTH,
229 
230  if (hdwp)
231  hdwp = DeferWindowPos(hdwp,
232  hRichEdit,
233  0,
234  Point.x + SPLIT_WIDTH,
239 
240  if (hdwp)
241  hdwp = DeferWindowPos(hdwp,
242  hHSplitter,
243  0,
244  Point.x + SPLIT_WIDTH,
245  GetHSplitterPos(),
247  SPLIT_WIDTH,
249 
250  if (hdwp)
251  EndDeferWindowPos(hdwp);
252  }
253  break;
254  }
255 
256  return DefWindowProc(hwnd, Msg, wParam, lParam);
257 }
HDWP WINAPI BeginDeferWindowPos(_In_ int)
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
long x
Definition: polytest.cpp:48
HWND hHSplitter
Definition: splitter.cpp:12
HWND hToolBar
Definition: mplay32.c:17
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
WPARAM wParam
Definition: combotst.c:138
#define SPLIT_WIDTH
Definition: eventvwr.c:62
struct @1571 Msg[]
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HWND WINAPI GetCapture(void)
Definition: message.c:2855
#define DefWindowProc
Definition: ros2win.h:31
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
INT GetClientWindowWidth(HWND hwnd)
Definition: misc.cpp:33
HWND hStatusBar
Definition: main.cpp:35
int GetHSplitterPos(VOID)
Definition: splitter.cpp:17
HWND hMainWnd
Definition: magnifier.c:33
struct Point Point
INT GetWindowHeight(HWND hwnd)
Definition: misc.cpp:25
HWND hListView
Definition: gui.cpp:29
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define WM_MOUSEMOVE
Definition: winuser.h:1751
INT GetClientWindowHeight(HWND hwnd)
Definition: misc.cpp:41
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2864
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139

Variable Documentation

◆ hHSplitter

HWND hHSplitter = NULL

Definition at line 12 of file splitter.cpp.

◆ HSplitterPos

int HSplitterPos = 0
static

Definition at line 14 of file splitter.cpp.

Referenced by GetHSplitterPos(), and SetHSplitterPos().

◆ hVSplitter

HWND hVSplitter = NULL

Definition at line 11 of file splitter.cpp.