ReactOS  0.4.14-dev-376-gaedba84
childwnd.c File Reference
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include <assert.h>
#include "main.h"
#include "childwnd.h"
Include dependency graph for childwnd.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define ASSERT   assert
 

Functions

static void draw_splitbar (HWND hWnd, int x)
 
static void OnPaint (HWND hWnd, ChildWnd *pChildWnd)
 
static void OnSize (ChildWnd *pChildWnd, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK ChildWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT   assert

Definition at line 38 of file childwnd.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 26 of file childwnd.c.

Function Documentation

◆ ChildWndProc()

LRESULT CALLBACK ChildWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 101 of file childwnd.c.

102 {
103  static int last_split;
105  ASSERT(pChildWnd);
106 
107  switch(message) {
108  case WM_CREATE:
109  return 0;
110 
111  case WM_MDIACTIVATE: // set an alternate menu here
112  if (lParam == (LPARAM)hWnd) {
113  } else {
114  }
116  // return 0;
117  break;
118 
119  case WM_PAINT:
120  OnPaint(hWnd, pChildWnd);
121  return 0;
122 
123  case WM_NCDESTROY:
124  // SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
125  break;
126 
127  case WM_SETCURSOR:
128  if (LOWORD(lParam) == HTCLIENT) {
129  POINT pt;
130  GetCursorPos(&pt);
132 
133  if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
135  return TRUE;
136  }
137  }
138  //goto def;
139  break;
140 
141  case WM_LBUTTONDOWN: {
142  RECT rt;
143  int x = LOWORD(lParam);
144  GetClientRect(hWnd, &rt);
145  if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
146  last_split = pChildWnd->nSplitPos;
147 #ifdef _NO_EXTENSIONS
149 #endif
150  SetCapture(hWnd);
151  }
152  break;}
153 
154  case WM_LBUTTONUP:
155  if (GetCapture() == hWnd) {
156 #ifdef _NO_EXTENSIONS
157  RECT rt;
158  int x = LOWORD(lParam);
160  last_split = -1;
161  GetClientRect(hWnd, &rt);
162  pChildWnd->nSplitPos = x;
163  //resize_tree(pChildWnd, rt.right, rt.bottom);
164 #endif
165  ReleaseCapture();
166  }
167  break;
168 
169 #ifdef _NO_EXTENSIONS
170  case WM_CAPTURECHANGED:
171  if (GetCapture()==hWnd && last_split>=0)
173  break;
174 #endif
175  case WM_KEYDOWN:
176  if (wParam == VK_ESCAPE)
177  if (GetCapture() == hWnd) {
178  RECT rt;
179 #ifdef _NO_EXTENSIONS
181 #else
182  pChildWnd->nSplitPos = last_split;
183 #endif
184  GetClientRect(hWnd, &rt);
185  //resize_tree(pChildWnd, rt.right, rt.bottom);
186  last_split = -1;
187  ReleaseCapture();
189  }
190  break;
191 
192  case WM_MOUSEMOVE:
193  if (GetCapture() == hWnd) {
194  RECT rt;
195  int x = LOWORD(lParam);
196 #ifdef _NO_EXTENSIONS
197  HDC hdc = GetDC(hWnd);
198  GetClientRect(hWnd, &rt);
199  rt.left = last_split-SPLIT_WIDTH/2;
200  rt.right = last_split+SPLIT_WIDTH/2+1;
201  InvertRect(hdc, &rt);
202  last_split = x;
203  rt.left = x-SPLIT_WIDTH/2;
204  rt.right = x+SPLIT_WIDTH/2+1;
205  InvertRect(hdc, &rt);
206  ReleaseDC(hWnd, hdc);
207 #else
208  GetClientRect(hWnd, &rt);
209  if (x>=0 && x<rt.right) {
210  pChildWnd->nSplitPos = x;
211  resize_tree(pChildWnd, rt.right, rt.bottom);
212  rt.left = x-SPLIT_WIDTH/2;
213  rt.right = x+SPLIT_WIDTH/2+1;
214  InvalidateRect(hWnd, &rt, FALSE);
215  UpdateWindow(pChildWnd->left.hWnd);
217  UpdateWindow(pChildWnd->right.hWnd);
218  }
219 #endif
220  }
221  break;
222 
223 #ifndef _NO_EXTENSIONS
224  case WM_GETMINMAXINFO:
226  {LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
227  lpmmi->ptMaxTrackSize.x <<= 1;//2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN
228  lpmmi->ptMaxTrackSize.y <<= 1;//2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN
229  break;}
230 #endif
231 
232  case WM_SETFOCUS:
233  SetCurrentDirectory(pChildWnd->szPath);
234  SetFocus(pChildWnd->nFocusPanel? pChildWnd->hRightWnd: pChildWnd->hLeftWnd);
235  break;
236 /*
237  case WM_COMMAND:
238  pane = GetFocus()==pChildWnd->left.hWnd? &pChildWnd->left: &pChildWnd->right;
239  switch(LOWORD(wParam)) {
240  case ID_WINDOW_NEW_WINDOW:
241  return 0;
242  default:
243  return pane_command(pane, LOWORD(wParam));
244  break;
245  }
246  break;
247  */
248  case WM_SIZE:
249  if (wParam != SIZE_MINIMIZED) {
250  OnSize(pChildWnd, wParam, lParam);
251  }
252  // fall through
253  // default: def:
255  }
257 }
#define IDC_SIZEWE
Definition: winuser.h:689
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
BOOL WINAPI DrawMenuBar(_In_ HWND)
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
#define pt(x, y)
Definition: drawing.c:79
#define WM_CAPTURECHANGED
Definition: winuser.h:1790
static HDC
Definition: imagelist.c:92
Pane right
Definition: winefile.c:132
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HWND WINAPI SetFocus(_In_opt_ HWND)
LONG left
Definition: windef.h:291
#define VK_ESCAPE
Definition: winuser.h:2189
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
BOOL WINAPI InvertRect(_In_ HDC, _In_ LPCRECT)
LONG right
Definition: windef.h:293
WPARAM wParam
Definition: combotst.c:138
#define SPLIT_WIDTH
Definition: eventvwr.c:62
HWND hLeftWnd
Definition: main.h:47
int nSplitPos
Definition: main.h:65
#define WM_SETCURSOR
Definition: winuser.h:1618
HWND WINAPI GetCapture(void)
Definition: message.c:2879
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define GWLP_USERDATA
Definition: treelist.c:63
struct tagMINMAXINFO * LPMINMAXINFO
#define WM_KEYDOWN
Definition: winuser.h:1697
LONG_PTR LPARAM
Definition: windef.h:208
#define DefMDIChildProc
Definition: ros2win.h:33
WCHAR szPath[MAX_PATH]
Definition: main.h:67
#define WM_SIZE
Definition: winuser.h:1593
static int last_split
Definition: childwnd.c:24
static void OnPaint(HWND hWnd, ChildWnd *pChildWnd)
Definition: childwnd.c:57
#define WM_NCDESTROY
Definition: winuser.h:1666
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SIZE_MINIMIZED
Definition: winuser.h:2481
HWND hRightWnd
Definition: main.h:48
#define WM_PAINT
Definition: winuser.h:1602
Pane left
Definition: winefile.c:131
HDC hdc
Definition: main.c:9
#define WM_MDIACTIVATE
Definition: winuser.h:1796
#define LoadCursor
Definition: winuser.h:5713
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hFrameWnd
Definition: main.c:30
HWND WINAPI SetCapture(_In_ HWND hWnd)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
static void OnSize(ChildWnd *pChildWnd, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:84
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
Definition: main.h:57
#define WM_CREATE
Definition: winuser.h:1590
static void resize_tree(ChildWnd *child, int cx, int cy)
Definition: winefile.c:2311
LONG bottom
Definition: windef.h:294
POINT ptMaxTrackSize
Definition: winuser.h:3605
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_SETFOCUS
Definition: winuser.h:1595
#define HTCLIENT
Definition: winuser.h:2450
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
static void draw_splitbar(HWND hWnd, int x)
Definition: childwnd.c:45
#define SetCurrentDirectory
Definition: winbase.h:3727
#define ASSERT
Definition: childwnd.c:38
int nFocusPanel
Definition: main.h:64

◆ draw_splitbar()

static void draw_splitbar ( HWND  hWnd,
int  x 
)
static

Definition at line 45 of file childwnd.c.

46 {
47  RECT rt;
48  HDC hdc = GetDC(hWnd);
49 
50  GetClientRect(hWnd, &rt);
51  rt.left = x - SPLIT_WIDTH/2;
52  rt.right = x + SPLIT_WIDTH/2+1;
53  InvertRect(hdc, &rt);
54  ReleaseDC(hWnd, hdc);
55 }
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:291
BOOL WINAPI InvertRect(_In_ HDC, _In_ LPCRECT)
LONG right
Definition: windef.h:293
#define SPLIT_WIDTH
Definition: eventvwr.c:62
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by ChildWndProc().

◆ OnPaint()

static void OnPaint ( HWND  hWnd,
ChildWnd pChildWnd 
)
static

Definition at line 57 of file childwnd.c.

58 {
59  PAINTSTRUCT ps;
60  RECT rt;
61  GetClientRect(hWnd, &rt);
62  BeginPaint(hWnd, &ps);
63 
64 // lastBrush = SelectObject(ps.hdc, (HBRUSH)GetStockObject(WHITE_BRUSH));
65 // Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
66 // SelectObject(ps.hdc, lastBrush);
67 // rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL);
69 /*
70  rt.left = pChildWnd->nSplitPos-SPLIT_WIDTH/2;
71  rt.right = pChildWnd->nSplitPos+SPLIT_WIDTH/2+1;
72  lastBrush = SelectBrush(ps.hdc, (HBRUSH)GetStockObject(COLOR_SPLITBAR));
73  Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
74  SelectObject(ps.hdc, lastBrush);
75 #ifdef _NO_EXTENSIONS
76  rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL);
77  FillRect(ps.hdc, &rt, GetStockObject(BLACK_BRUSH));
78 #endif
79  */
80  EndPaint(hWnd, &ps);
81 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HWND hWnd
Definition: settings.c:17
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define BLACK_BRUSH
Definition: wingdi.h:895
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by ChildWndProc().

◆ OnSize()

static void OnSize ( ChildWnd pChildWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 84 of file childwnd.c.

85 {
86  if (wParam != SIZE_MINIMIZED) {
87  //resize_tree(pChildWnd, LOWORD(lParam), HIWORD(lParam));
88  }
89 }
WPARAM wParam
Definition: combotst.c:138
#define SIZE_MINIMIZED
Definition: winuser.h:2481

Referenced by ChildWndProc().