ReactOS 0.4.15-dev-8408-g466a198
draglist.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/debug.h"
Include dependency graph for draglist.c:

Go to the source code of this file.

Classes

struct  _DRAGLISTDATA
 

Macros

#define DRAGLIST_SUBCLASSID   0
 
#define DRAGLIST_SCROLLPERIOD   200
 
#define DRAGLIST_TIMERID   666
 
#define DRAGICON_HOTSPOT_X   17
 
#define DRAGICON_HOTSPOT_Y   7
 
#define DRAGICON_HEIGHT   32
 

Typedefs

typedef struct _DRAGLISTDATA DRAGLISTDATA
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (commctrl)
 
static LRESULT DragList_Notify (HWND hwndLB, UINT uNotification)
 
static void DragList_EndDrag (HWND hwnd, DRAGLISTDATA *data)
 
static LRESULT CALLBACK DragList_SubclassWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
 
BOOL WINAPI MakeDragList (HWND hwndLB)
 
VOID WINAPI DrawInsert (HWND hwndParent, HWND hwndLB, INT nItem)
 
INT WINAPI LBItemFromPt (HWND hwndLB, POINT pt, BOOL bAutoScroll)
 

Variables

UINT uDragListMessage = 0
 
static DWORD dwLastScrollTime = 0
 
static HICON hDragArrow = NULL
 

Macro Definition Documentation

◆ DRAGICON_HEIGHT

#define DRAGICON_HEIGHT   32

Definition at line 52 of file draglist.c.

◆ DRAGICON_HOTSPOT_X

#define DRAGICON_HOTSPOT_X   17

Definition at line 50 of file draglist.c.

◆ DRAGICON_HOTSPOT_Y

#define DRAGICON_HOTSPOT_Y   7

Definition at line 51 of file draglist.c.

◆ DRAGLIST_SCROLLPERIOD

#define DRAGLIST_SCROLLPERIOD   200

Definition at line 46 of file draglist.c.

◆ DRAGLIST_SUBCLASSID

#define DRAGLIST_SUBCLASSID   0

Definition at line 45 of file draglist.c.

◆ DRAGLIST_TIMERID

#define DRAGLIST_TIMERID   666

Definition at line 47 of file draglist.c.

Typedef Documentation

◆ DRAGLISTDATA

Function Documentation

◆ DragList_EndDrag()

static void DragList_EndDrag ( HWND  hwnd,
DRAGLISTDATA data 
)
static

Definition at line 94 of file draglist.c.

95{
98 /* clear any drag insert icon present */
99 InvalidateRect(GetParent(hwnd), &data->last_drag_icon_rect, TRUE);
100 /* clear data for next use */
101 memset(data, 0, sizeof(*data));
102}
#define TRUE
Definition: types.h:120
#define DRAGLIST_TIMERID
Definition: draglist.c:47
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memset(x, y, z)
Definition: compat.h:39
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by DragList_SubclassWindowProc().

◆ DragList_Notify()

static LRESULT DragList_Notify ( HWND  hwndLB,
UINT  uNotification 
)
static

Definition at line 84 of file draglist.c.

85{
86 DRAGLISTINFO dli;
87 dli.hWnd = hwndLB;
88 dli.uNotification = uNotification;
90 return SendMessageW(GetParent(hwndLB), uDragListMessage, GetDlgCtrlID(hwndLB), (LPARAM)&dli);
91}
UINT uDragListMessage
Definition: draglist.c:73
UINT uNotification
Definition: commctrl.h:2092
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2714
int WINAPI GetDlgCtrlID(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DragList_SubclassWindowProc().

◆ DragList_SubclassWindowProc()

static LRESULT CALLBACK DragList_SubclassWindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
UINT_PTR  uIdSubclass,
DWORD_PTR  dwRefData 
)
static

Definition at line 111 of file draglist.c.

112{
114 switch (uMsg)
115 {
116 case WM_LBUTTONDOWN:
117 SetFocus(hwnd);
119 if (data->dragging)
120 {
123 }
124 /* note that we don't absorb this message to let the list box
125 * do its thing (normally selecting an item) */
126 break;
127
128 case WM_KEYDOWN:
129 case WM_RBUTTONDOWN:
130 /* user cancelled drag by either right clicking or
131 * by pressing the escape key */
132 if ((data->dragging) &&
133 ((uMsg == WM_RBUTTONDOWN) || (wParam == VK_ESCAPE)))
134 {
135 /* clean up and absorb message */
138 return 0;
139 }
140 break;
141
142 case WM_MOUSEMOVE:
143 case WM_TIMER:
144 if (data->dragging)
145 {
147 /* optimisation so that we don't have to load the cursor
148 * all of the time whilst dragging */
149 if (data->last_dragging_response != cursor)
150 {
151 switch (cursor)
152 {
153 case DL_STOPCURSOR:
154 data->cursor = LoadCursorW(NULL, (LPCWSTR)IDC_NO);
155 SetCursor(data->cursor);
156 break;
157 case DL_COPYCURSOR:
158#ifndef __REACTOS__
160#else
162#endif
163 SetCursor(data->cursor);
164 break;
165 case DL_MOVECURSOR:
167 SetCursor(data->cursor);
168 break;
169 }
170 data->last_dragging_response = cursor;
171 }
172 /* don't pass this message on to List Box */
173 return 0;
174 }
175 break;
176
177 case WM_LBUTTONUP:
178 if (data->dragging)
179 {
182 }
183 break;
184
185 case WM_GETDLGCODE:
186 /* tell dialog boxes that we want to receive WM_KEYDOWN events
187 * for keys like VK_ESCAPE */
188 if (data->dragging)
189 return DLGC_WANTALLKEYS;
190 break;
191 case WM_NCDESTROY:
193 Free(data);
194 break;
195 }
196 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
197}
#define IDC_COPY
Definition: resource.h:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HMODULE COMCTL32_hModule
Definition: commctrl.c:79
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
Definition: commctrl.c:1390
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define NULL
Definition: types.h:112
static LRESULT CALLBACK DragList_SubclassWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
Definition: draglist.c:111
#define DRAGLIST_SUBCLASSID
Definition: draglist.c:45
static LRESULT DragList_Notify(HWND hwndLB, UINT uNotification)
Definition: draglist.c:84
#define DRAGLIST_SCROLLPERIOD
Definition: draglist.c:46
static void DragList_EndDrag(HWND hwnd, DRAGLISTDATA *data)
Definition: draglist.c:94
const char cursor[]
Definition: icontest.c:13
#define DL_BEGINDRAG
Definition: commctrl.h:2097
#define DL_MOVECURSOR
Definition: commctrl.h:2105
#define DL_CANCELDRAG
Definition: commctrl.h:2100
#define DL_COPYCURSOR
Definition: commctrl.h:2104
#define DL_DRAGGING
Definition: commctrl.h:2098
_In_ SUBCLASSPROC _In_ UINT_PTR _In_ DWORD_PTR dwRefData
Definition: commctrl.h:5058
#define DL_STOPCURSOR
Definition: commctrl.h:2103
#define DL_DROPPED
Definition: commctrl.h:2099
LONG_PTR LRESULT
Definition: windef.h:209
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define IDC_NO
Definition: winuser.h:697
#define DLGC_WANTALLKEYS
Definition: winuser.h:2612
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_TIMER
Definition: winuser.h:1742
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define WM_NCDESTROY
Definition: winuser.h:1684
#define WM_KEYDOWN
Definition: winuser.h:1715
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define VK_ESCAPE
Definition: winuser.h:2214
#define WM_GETDLGCODE
Definition: winuser.h:1689
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by DragList_SubclassWindowProc(), DrawInsert(), and MakeDragList().

◆ DrawInsert()

VOID WINAPI DrawInsert ( HWND  hwndParent,
HWND  hwndLB,
INT  nItem 
)

Definition at line 228 of file draglist.c.

229{
230 RECT rcItem, rcListBox, rcDragIcon;
231 HDC hdc;
233
234 TRACE("(%p %p %d)\n", hwndParent, hwndLB, nItem);
235
236 if (!hDragArrow)
238
239 if (LB_ERR == SendMessageW(hwndLB, LB_GETITEMRECT, nItem, (LPARAM)&rcItem))
240 return;
241
242 if (!GetWindowRect(hwndLB, &rcListBox))
243 return;
244
245 /* convert item rect to parent co-ordinates */
246 if (!MapWindowPoints(hwndLB, hwndParent, (LPPOINT)&rcItem, 2))
247 return;
248
249 /* convert list box rect to parent co-ordinates */
250 if (!MapWindowPoints(HWND_DESKTOP, hwndParent, (LPPOINT)&rcListBox, 2))
251 return;
252
253 rcDragIcon.left = rcListBox.left - DRAGICON_HOTSPOT_X;
254 rcDragIcon.top = rcItem.top - DRAGICON_HOTSPOT_Y;
255 rcDragIcon.right = rcListBox.left;
256 rcDragIcon.bottom = rcDragIcon.top + DRAGICON_HEIGHT;
257
259 return;
260
261 if (nItem < 0)
262 SetRectEmpty(&rcDragIcon);
263
264 /* prevent flicker by only redrawing when necessary */
265 if (!EqualRect(&rcDragIcon, &data->last_drag_icon_rect))
266 {
267 /* get rid of any previous inserts drawn */
268 RedrawWindow(hwndParent, &data->last_drag_icon_rect, NULL,
270
271 data->last_drag_icon_rect = rcDragIcon;
272
273 if (nItem >= 0)
274 {
276
277 DrawIcon(hdc, rcDragIcon.left, rcDragIcon.top, hDragArrow);
278
280 }
281 }
282}
#define IDI_DRAGARROW
Definition: comctl32.h:100
BOOL WINAPI GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID, DWORD_PTR *pdwRef)
Definition: commctrl.c:1348
static HWND hwndParent
Definition: cryptui.c:300
#define DRAGICON_HOTSPOT_Y
Definition: draglist.c:51
#define DRAGICON_HOTSPOT_X
Definition: draglist.c:50
static HICON hDragArrow
Definition: draglist.c:75
#define DRAGICON_HEIGHT
Definition: draglist.c:52
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define TRACE(s)
Definition: solgame.cpp:4
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define LB_ERR
Definition: winuser.h:2432
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI DrawIcon(_In_ HDC, _In_ int, _In_ int, _In_ HICON)
Definition: cursoricon.c:2062
#define LB_GETITEMRECT
Definition: winuser.h:2043
#define RDW_UPDATENOW
Definition: winuser.h:1220
#define RDW_ERASE
Definition: winuser.h:1211
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define HWND_DESKTOP
Definition: winuser.h:1209
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define RDW_INTERNALPAINT
Definition: winuser.h:1213
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2119
#define RDW_INVALIDATE
Definition: winuser.h:1214

Referenced by TOOLBAR_Cust_AvailDragListNotification(), and TOOLBAR_Cust_ToolbarDragListNotification().

◆ LBItemFromPt()

INT WINAPI LBItemFromPt ( HWND  hwndLB,
POINT  pt,
BOOL  bAutoScroll 
)

Definition at line 293 of file draglist.c.

294{
295 RECT rcClient;
296 INT nIndex;
297 DWORD dwScrollTime;
298
299 TRACE("(%p %d x %d %s)\n",
300 hwndLB, pt.x, pt.y, bAutoScroll ? "TRUE" : "FALSE");
301
302 ScreenToClient (hwndLB, &pt);
303 GetClientRect (hwndLB, &rcClient);
304 nIndex = (INT)SendMessageW (hwndLB, LB_GETTOPINDEX, 0, 0);
305
306 if (PtInRect (&rcClient, pt))
307 {
308 /* point is inside -- get the item index */
309 while (TRUE)
310 {
311 if (SendMessageW (hwndLB, LB_GETITEMRECT, nIndex, (LPARAM)&rcClient) == LB_ERR)
312 return -1;
313
314 if (PtInRect (&rcClient, pt))
315 return nIndex;
316
317 nIndex++;
318 }
319 }
320 else
321 {
322 /* point is outside */
323 if (!bAutoScroll)
324 return -1;
325
326 if ((pt.x > rcClient.right) || (pt.x < rcClient.left))
327 return -1;
328
329 if (pt.y < 0)
330 nIndex--;
331 else
332 nIndex++;
333
334 dwScrollTime = GetTickCount ();
335
336 if ((dwScrollTime - dwLastScrollTime) < DRAGLIST_SCROLLPERIOD)
337 return -1;
338
339 dwLastScrollTime = dwScrollTime;
340
341 SendMessageW (hwndLB, LB_SETTOPINDEX, nIndex, 0);
342 }
343
344 return -1;
345}
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
static DWORD dwLastScrollTime
Definition: draglist.c:74
#define pt(x, y)
Definition: drawing.c:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:58
#define LB_SETTOPINDEX
Definition: winuser.h:2070
#define LB_GETTOPINDEX
Definition: winuser.h:2051
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by TOOLBAR_Cust_AvailDragListNotification(), and TOOLBAR_Cust_ToolbarDragListNotification().

◆ MakeDragList()

BOOL WINAPI MakeDragList ( HWND  hwndLB)

Definition at line 208 of file draglist.c.

209{
211
212 TRACE("(%p)\n", hwndLB);
213
214 if (!uDragListMessage)
216
218}
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1261
static const WCHAR DRAGLISTMSGSTRINGW[]
Definition: commctrl.h:27
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)

Referenced by TOOLBAR_CustomizeDialogProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( commctrl  )

Variable Documentation

◆ dwLastScrollTime

DWORD dwLastScrollTime = 0
static

Definition at line 74 of file draglist.c.

Referenced by LBItemFromPt().

◆ hDragArrow

HICON hDragArrow = NULL
static

Definition at line 75 of file draglist.c.

Referenced by DrawInsert().

◆ uDragListMessage

UINT uDragListMessage = 0

Definition at line 73 of file draglist.c.

Referenced by DragList_Notify(), MakeDragList(), and TOOLBAR_CustomizeDialogProc().