Subversion Repositories Games.Chess Giants

Rev

Rev 21 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
// window_opponents.cpp
2
 
3
#include "../common.h"
4
 
5
 
6
// window parameters
7
#define WINDOW_CLASSNAME PROGRAM_NAME L" Opponents WndClass"
8
#define WINDOW_DEFAULT_WIDTH 822
9
#define WINDOW_DEFAULT_HEIGHT 600
10
#define WINDOW_MIN_WIDTH 822
11
#define WINDOW_MIN_HEIGHT 200
12
 
13
 
14
// local definitions
15
#define WINDOW_TEXT_DOUBLECLICKORNARROWDOWN 1
16
#define WINDOW_TEXT_NAMECONTAINS 2
17
#define WINDOW_EDITBOX_NAMECONTAINS 3
18
#define WINDOW_TEXT_STATUSIS 4
19
#define WINDOW_COMBOBOX_STATUSIS 5
20
#define WINDOW_TEXT_LEVELFROM 6
21
#define WINDOW_EDITBOX_LEVELFROM 7
22
#define WINDOW_TEXT_LEVELTO 8
23
#define WINDOW_EDITBOX_LEVELTO 9
24
#define WINDOW_LIST_OPPONENTS 10
25
#define WINDOW_TEXT_STATUSBAR 11
26
#define WINDOW_TIMER_REFRESH 1
27
#define TICKED_COLUMN_WIDTH 41
28
#define STRING_FIDEGM ((wchar_t *) "G\x00M\x00 \x00\x42\x26\x00") // "GM " + male sign
29
#define STRING_FIDEIM ((wchar_t *) "I\x00M\x00 \x00\x42\x26\x00") // "IM " + male sign
30
#define STRING_FIDEWGM ((wchar_t *) "G\x00M\x00 \x00\x40\x26\x00") // "GM " + female sign
31
#define STRING_FIDEWIM ((wchar_t *) "I\x00M\x00 \x00\x40\x26\x00") // "IM " + female sign
32
 
33
 
34
// list view column definition
35
typedef struct listviewcolumn_s
36
{
37
   int width;
38
   int alignment;
39
   bool sort_descending;
40
   wchar_t *text;
41
   HWND hToolTipWnd;
42
} listviewcolumn_t;
43
 
44
 
45
// global variables used in this module only
46
static bool is_classregistered = false;
47
static int listviewicons[sizeof (handlestatus) / sizeof (handlestatus_t)]; // as big as the handlestatus global array
48
static listviewcolumn_t listviewcolumns[] =
49
{
50
   { 140, LVCFMT_LEFT, true, NULL /*LOCALIZE (L"Opponents_ColumnNickname")*/, NULL }, // text address needs to be set at runtime, because it's mallocated
51
   { 60, LVCFMT_LEFT, false, NULL /*LOCALIZE (L"Opponents_ColumnFIDERank")*/, NULL },
52
   { 120, LVCFMT_LEFT, false, NULL /*LOCALIZE (L"Opponents_ColumnStatus")*/, NULL },
53
   { 60, LVCFMT_LEFT, false, NULL /*LOCALIZE (L"Opponents_ColumnRating")*/, NULL },
54
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnComputer")*/, NULL },
55
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnAdministrator")*/, NULL },
56
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnBlindfold")*/, NULL },
57
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnTeam")*/, NULL },
58
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnChessAdvisor")*/, NULL },
59
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnServiceRepresentative")*/, NULL },
60
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnTournamentDirector")*/, NULL },
61
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnMamerManager")*/, NULL },
62
   { TICKED_COLUMN_WIDTH, LVCFMT_CENTER, false, NULL /*LOCALIZE (L"Opponents_ColumnUnregistered")*/, NULL },
63
};
64
static int current_sortcolumn = 0;
65
static wchar_t window_title[256];
66
static wchar_t opponent_namecontains[64];
67
static wchar_t rating_string[64];
68
//static HWND hThisWnd = NULL;
69
#define hThisWnd hOpponentsWnd // shared variable
70
 
71
 
72
// prototypes of local functions
73
static LRESULT CALLBACK WindowProc_ThisWindow (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
74
static int CALLBACK CompareProc_ListOpponents (LPARAM lParam1, LPARAM lParam2, LPARAM column);
75
static int WINAPI ListView_WndProc (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
76
 
77
 
78
void Window_Opponents (void)
79
{
80
   // helper function to fire up the child window
81
 
82
   WNDCLASSEX wc;
83
   player_t *network_player;
84
 
85
   // is the window we want to display already displayed ?
86
   if (IsWindow (hThisWnd))
87
      SetForegroundWindow (hThisWnd); // if so, just bring it to front
88
 
89
   // else the way is clear
90
   else
91
   {
92
      // find the network player and make him ask an update from the server
93
      if ((network_player = Player_FindByType (PLAYER_INTERNET)) != NULL)
94
      {
95
         SAFE_free ((void **) &onlineplayers); // free the online players list we know
96
         onlineplayer_count = -1; // and reset its count (-1 means "reply not arrived")
97
         Player_SendBuffer_Add (network_player, 1000, L"who\n"); // send the players update request
98
      }
99
 
100
      // is the window class NOT registered yet ?
101
      if (!is_classregistered)
102
      {
103
         // if so, register the window class once and for all
104
         memset (&wc, 0, sizeof (wc));
105
         wc.cbSize = sizeof (wc);
106
         wc.style = CS_HREDRAW | CS_VREDRAW;
107
         wc.lpfnWndProc = WindowProc_ThisWindow;
108
         wc.hInstance = hAppInstance;
109
         wc.hIcon = LoadIcon (hAppInstance, (wchar_t *) ICON_MAIN);
110
         wc.hCursor = LoadCursor (NULL, IDC_ARROW);
111
         wc.hbrBackground = GetSysColorBrush (COLOR_3DFACE);
112
         wc.lpszClassName = WINDOW_CLASSNAME;
113
         RegisterClassEx (&wc);
114
 
115
         is_classregistered = true; // remember this window class is registered
116
      }
117
 
118
      // create the child window
119
      hThisWnd = CreateWindowEx (WS_EX_CLIENTEDGE, WINDOW_CLASSNAME, LOCALIZE (L"Opponents_TitleBuildingList"), WS_OVERLAPPEDWINDOW,
120
                                 CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGHT,
121
                                 hMainWnd, NULL, hAppInstance, NULL);
122
   }
123
 
124
   return; // return as soon as the thread is fired up
125
}
126
 
127
 
128
void Window_Opponents_Validated (void)
129
{
130
   // callback function called by the main game thread when the window is validated
131
 
132
   // remember this callback is no longer to be called
133
   is_window_opponents_validated = false;
134
 
135
   return; // finished
136
}
137
 
138
 
139
static LRESULT CALLBACK WindowProc_ThisWindow (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
140
{
141
   // message handler for the child window
142
 
143
   unsigned short wParam_hiword;
144
   unsigned short wParam_loword;
145
   int opponent_statusis;
146
   int opponent_ratingfrom;
147
   int opponent_ratingto;
148
   int result;
149
   HWND hListWnd;
150
   LVCOLUMN lvc;
151
   LVITEM lvi;
152
   HDITEM hdi;
153
   NMLISTVIEW *lv;
154
   NMITEMACTIVATE *clickeditem;
155
   HIMAGELIST imagelist;
156
   MINMAXINFO *minmax;
157
   RECT client_rect;
158
   onlineplayer_t *onlineplayer;
159
   player_t *local_player;
160
   int onlineplayer_index;
161
   int column_index;
162
   int insert_index;
163
   int displayed_count;
164
 
165
   // filter out the commonly used message values
166
   wParam_hiword = HIWORD (wParam);
167
   wParam_loword = LOWORD (wParam);
168
 
169
   // have we just fired up this window ?
170
   if (message == WM_CREATE)
171
   {
172
      // center the window
173
      CenterWindow (hWnd, hMainWnd);
174
 
175
      // populate the window
176
      CreateWindowEx (0, L"static", L"",
177
                      WS_CHILD | WS_VISIBLE,
178
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_DOUBLECLICKORNARROWDOWN, hAppInstance, NULL);
179
      CreateWindowEx (WS_EX_RIGHT, L"static", L"",
180
                      WS_CHILD | WS_VISIBLE,
181
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_NAMECONTAINS, hAppInstance, NULL);
182
      CreateWindowEx (WS_EX_CLIENTEDGE, L"edit", L"",
183
                      WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
184
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_EDITBOX_NAMECONTAINS, hAppInstance, NULL);
185
      CreateWindowEx (WS_EX_RIGHT, L"static", L"",
186
                      WS_CHILD | WS_VISIBLE,
187
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_STATUSIS, hAppInstance, NULL);
188
      CreateWindowEx (WS_EX_CLIENTEDGE, L"combobox", L"",
189
                      WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
190
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_COMBOBOX_STATUSIS, hAppInstance, NULL);
191
      CreateWindowEx (WS_EX_RIGHT, L"static", L"",
192
                      WS_CHILD | WS_VISIBLE,
193
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_LEVELFROM, hAppInstance, NULL);
194
      CreateWindowEx (WS_EX_CLIENTEDGE, L"edit", L"",
195
                      WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | SS_CENTERIMAGE,
196
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_EDITBOX_LEVELFROM, hAppInstance, NULL);
197
      CreateWindowEx (WS_EX_RIGHT, L"static", L"",
198
                      WS_CHILD | WS_VISIBLE,
199
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_LEVELTO, hAppInstance, NULL);
200
      CreateWindowEx (WS_EX_CLIENTEDGE, L"edit", L"",
201
                      WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | SS_CENTERIMAGE,
202
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_EDITBOX_LEVELTO, hAppInstance, NULL);
203
      CreateWindowEx (WS_EX_STATICEDGE, L"syslistview32", L"",
204
                      WS_CHILD | WS_VISIBLE | WS_TABSTOP | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT,
205
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_LIST_OPPONENTS, hAppInstance, NULL);
206
      CreateWindowEx (WS_EX_RIGHT, L"static", L"",
207
                      WS_CHILD | WS_VISIBLE,
208
                      0, 0, 0, 0, hWnd, (HMENU) WINDOW_TEXT_STATUSBAR, hAppInstance, NULL);
209
 
210
      // prepare the list view : do it before anything that could trigger a fill
211
 
212
      // get a quick access to the list control
213
      hListWnd = GetDlgItem (hWnd, WINDOW_LIST_OPPONENTS);
214
 
215
      // add full row select and header columns rearranging to it
216
      ListView_SetExtendedListViewStyle (hListWnd, ListView_GetExtendedListViewStyle (hListWnd)
217
                                                   | LVS_EX_GRIDLINES | LVS_EX_LABELTIP
218
                                                   | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
219
 
220
      // subclass the list view procedure to handle header tooltips and save the old procedure as one of the window's property
221
      SetProp (hListWnd, L"BaseWndProc", (HANDLE) SetWindowLongPtr (hListWnd, GWL_WNDPROC, (long) ListView_WndProc));
222
 
223
      // tell Windows which members of the LVCOLUMN structure we're filling
224
      memset (&lvc, 0, sizeof (lvc));
225
      lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
226
      for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
227
      {
228
         lvc.iSubItem = column_index;
229
         if (column_index == 0) lvc.pszText = LOCALIZE (L"Opponents_ColumnNickname");
230
         else if (column_index == 1) lvc.pszText = LOCALIZE (L"Opponents_ColumnFIDERank");
231
         else if (column_index == 2) lvc.pszText = LOCALIZE (L"Opponents_ColumnStatus");
232
         else if (column_index == 3) lvc.pszText = LOCALIZE (L"Opponents_ColumnRating");
233
         else if (column_index == 4) lvc.pszText = LOCALIZE (L"Opponents_ColumnComputer");
234
         else if (column_index == 5) lvc.pszText = LOCALIZE (L"Opponents_ColumnAdministrator");
235
         else if (column_index == 6) lvc.pszText = LOCALIZE (L"Opponents_ColumnBlindfold");
236
         else if (column_index == 7) lvc.pszText = LOCALIZE (L"Opponents_ColumnTeam");
237
         else if (column_index == 8) lvc.pszText = LOCALIZE (L"Opponents_ColumnChessAdvisor");
238
         else if (column_index == 9) lvc.pszText = LOCALIZE (L"Opponents_ColumnServiceRepresentative");
239
         else if (column_index == 10) lvc.pszText = LOCALIZE (L"Opponents_ColumnTournamentDirector");
240
         else if (column_index == 11) lvc.pszText = LOCALIZE (L"Opponents_ColumnMamerManager");
241
         else if (column_index == 12) lvc.pszText = LOCALIZE (L"Opponents_ColumnUnregistered");
242
         lvc.cx = listviewcolumns[column_index].width;
243
         lvc.fmt = listviewcolumns[column_index].alignment;
244
         ListView_InsertColumn (hListWnd, column_index, &lvc); // add each column to list view
245
      }
246
 
247
      // create the listview image list
248
      imagelist = ImageList_Create (16, 16, ILC_COLOR32, sizeof (handlestatus) / sizeof (handlestatus_t), 1); // create an imagelist holding N 32-bit images
249
      for (insert_index = 1; insert_index < sizeof (handlestatus) / sizeof (handlestatus_t); insert_index++)
250
         listviewicons[insert_index] = ImageList_AddIcon (imagelist, handlestatus[insert_index].icon); // add our icons in the image list
251
      ListView_SetImageList (hListWnd, imagelist, LVSIL_SMALL); // associate it with the listview
252
 
253
      // associate the default GUI font with the "double-click or narrow down" message and set its text
254
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_DOUBLECLICKORNARROWDOWN), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
255
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_DOUBLECLICKORNARROWDOWN), LOCALIZE (L"Opponents_DoubleClickOrNarrowDown"));
256
 
257
      // associate the default GUI font with the "name contains" message and set its text
258
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_NAMECONTAINS), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
259
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_NAMECONTAINS), LOCALIZE (L"Opponents_NameContains"));
260
 
261
      // associate the default GUI font with the "name contains" edit box and reset it
262
      SendMessage (GetDlgItem (hWnd, WINDOW_EDITBOX_NAMECONTAINS), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
263
      SetDlgItemText (hWnd, WINDOW_EDITBOX_NAMECONTAINS, L"");
264
 
265
      // associate the default GUI font with the "status is" message and set its text
266
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_STATUSIS), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
267
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_STATUSIS), LOCALIZE (L"Opponents_StatusIs"));
268
 
269
      // associate the default GUI font with the "status is" combo box and populate the combo box
270
      SendMessage (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
271
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), L"");
272
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusInGame"));
273
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusInSimulation"));
274
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusInTournament"));
275
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusExaminingAGame"));
276
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusNotOpenForAMatch"));
277
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusInactiveOrBusy"));
278
      ComboBox_AddString (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), LOCALIZE (L"Opponents_StatusAvailable"));
279
 
280
      // associate the default GUI font with the "level from" message and set its text
281
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_LEVELFROM), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
282
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_LEVELFROM), LOCALIZE (L"Opponents_LevelFrom"));
283
 
284
      // associate the default GUI font with the "level from" edit box and reset it
285
      SendMessage (GetDlgItem (hWnd, WINDOW_EDITBOX_LEVELFROM), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
286
      SetDlgItemText (hWnd, WINDOW_EDITBOX_LEVELFROM, L"");
287
 
288
      // associate the default GUI font with the "level to" message and set its text
289
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_LEVELTO), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
290
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_LEVELTO), LOCALIZE (L"Opponents_LevelTo"));
291
 
292
      // associate the default GUI font with the "level to" edit box and reset it
293
      SendMessage (GetDlgItem (hWnd, WINDOW_EDITBOX_LEVELTO), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
294
      SetDlgItemText (hWnd, WINDOW_EDITBOX_LEVELTO, L"");
295
 
296
      // associate the default GUI font with the status bar and set its text
297
      SendMessage (GetDlgItem (hWnd, WINDOW_TEXT_STATUSBAR), WM_SETFONT, (WPARAM) GetStockObject (DEFAULT_GUI_FONT), false);
298
      SetWindowText (GetDlgItem (hWnd, WINDOW_TEXT_STATUSBAR), LOCALIZE (L"Opponents_StatusBar"));
299
 
300
      // refresh the window every second
301
      SetTimer (hWnd, WINDOW_TIMER_REFRESH, 1000, NULL);
302
 
303
      // convert the status bar message to a hyperlink
304
      ConvertStaticToHyperlink (GetDlgItem (hWnd, WINDOW_TEXT_STATUSBAR));
305
 
306
      // now show the window
307
      ShowWindow (hWnd, SW_SHOW);
308
 
309
      // and send focus to the player name filter field (note: GetDlgItem works ALSO with windows! MSDN certified :))
310
      if (GetForegroundWindow () == hWnd)
311
         SetFocus (GetDlgItem (hWnd, WINDOW_EDITBOX_NAMECONTAINS));
124 pmbaty 312
 
313
      return (0); // as MSDN says
1 pmbaty 314
   }
315
 
316
   // else did we click the close button on the title bar ?
317
   else if (message == WM_CLOSE)
124 pmbaty 318
   {
21 pmbaty 319
      DestroyWindow (hWnd); // close the window
124 pmbaty 320
      return (0); // as MSDN says
321
   }
1 pmbaty 322
 
323
   // else are we destroying this window ?
324
   else if (message == WM_DESTROY)
325
   {
326
      KillTimer (hWnd, WINDOW_TIMER_REFRESH); // destroy the timer we used to refresh the window
327
      hThisWnd = NULL; // window is closed
328
      SetForegroundWindow (hMainWnd); // restore focus on the main window
329
      is_window_opponents_validated = true; // remember we closed this window
124 pmbaty 330
      the_board.reevaluate = true; // refresh the GUI buttons if needed
331
      return (0); // as MSDN says
1 pmbaty 332
   }
333
 
334
   // else are we resizing the window ?
335
   else if (message == WM_SIZE)
336
   {
337
      // get the new window size
338
      GetClientRect (hWnd, &client_rect);
339
 
340
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_DOUBLECLICKORNARROWDOWN), NULL, 16, 16, client_rect.right - 32, 16, SWP_NOZORDER);
341
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_NAMECONTAINS), NULL, 16, 40, 136, 16, SWP_NOZORDER);
342
      SetWindowPos (GetDlgItem (hWnd, WINDOW_EDITBOX_NAMECONTAINS), NULL, 160, 38, 128, 20, SWP_NOZORDER);
343
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_STATUSIS), NULL, 288, 40, 88, 16, SWP_NOZORDER);
344
      SetWindowPos (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS), NULL, 384, 38, 128, 20, SWP_NOZORDER);
345
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_LEVELFROM), NULL, 512, 40, 120, 16, SWP_NOZORDER);
346
      SetWindowPos (GetDlgItem (hWnd, WINDOW_EDITBOX_LEVELFROM), NULL, 640, 38, 48, 20, SWP_NOZORDER);
347
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_LEVELTO), NULL, 688, 40, 40, 16, SWP_NOZORDER);
348
      SetWindowPos (GetDlgItem (hWnd, WINDOW_EDITBOX_LEVELTO), NULL, 736, 38, 48, 20, SWP_NOZORDER);
349
      SetWindowPos (GetDlgItem (hWnd, WINDOW_LIST_OPPONENTS), NULL, 16, 64, client_rect.right - 32, client_rect.bottom - 80, SWP_NOZORDER);
350
      SetWindowPos (GetDlgItem (hWnd, WINDOW_TEXT_STATUSBAR), NULL, 0, client_rect.bottom - 16, client_rect.right, 16, SWP_NOZORDER);
124 pmbaty 351
 
352
      return (0); // as MSDN says
1 pmbaty 353
   }
354
 
355
   // else are we asking how big/small we can resize ?
356
   else if (message == WM_GETMINMAXINFO)
357
   {
358
      minmax = (MINMAXINFO *) lParam; // get a pointer to the min/max info structure
359
 
360
      minmax->ptMinTrackSize.x = WINDOW_MIN_WIDTH;
361
      minmax->ptMinTrackSize.y = WINDOW_MIN_HEIGHT;
124 pmbaty 362
 
363
      return (0); // as MSDN says
1 pmbaty 364
   }
365
 
366
   // else is it a timer event AND is it our refresh timer ?
367
   else if ((message == WM_TIMER) && (wParam == WINDOW_TIMER_REFRESH))
368
   {
369
      // do we need to update the opponents list ?
370
      if (onlineplayers_updated)
371
      {
372
         hListWnd = GetDlgItem (hWnd, WINDOW_LIST_OPPONENTS); // get a quick access to the list control
373
 
374
         // grab the different filters
375
         GetDlgItemText (hWnd, WINDOW_EDITBOX_NAMECONTAINS, opponent_namecontains, WCHAR_SIZEOF (opponent_namecontains));
376
         opponent_statusis = ComboBox_GetCurSel (GetDlgItem (hWnd, WINDOW_COMBOBOX_STATUSIS));
377
         opponent_ratingfrom = GetDlgItemInt (hWnd, WINDOW_EDITBOX_LEVELFROM, &result, false);
378
         opponent_ratingto = GetDlgItemInt (hWnd, WINDOW_EDITBOX_LEVELTO, &result, false);
379
         if (result == 0)
380
            opponent_ratingto = 9999; // if we couldn't read a number, set the default value
381
 
382
         // populate the list control
383
         ListView_DeleteAllItems (hListWnd); // start by emptying it first
384
         displayed_count = 0;
385
 
386
         // tell Windows which members of the LVCOLUMN structure we're filling
387
         memset (&lvi, 0, sizeof (lvi));
388
         lvi.mask = LVIF_IMAGE | LVIF_PARAM; // we want to set the image and the item's pointer
389
         for (onlineplayer_index = 0; onlineplayer_index < onlineplayer_count; onlineplayer_index++)
390
         {
391
            onlineplayer = &onlineplayers[onlineplayer_index]; // quick access to online player
392
 
393
            // should item be skipped because of its name ?
394
            if ((opponent_namecontains[0] != 0) && (wcsistr (onlineplayer->nickname, opponent_namecontains) == NULL))
395
               continue; // if so, skip it
396
 
397
            // should item be skipped because of its status ?
398
            if ((opponent_statusis == 1) && (onlineplayer->handlestatus != HANDLESTATUS_INGAME))
399
               continue; // if so, skip it
400
            else if ((opponent_statusis == 2) && (onlineplayer->handlestatus != HANDLESTATUS_INSIMULATION))
401
               continue; // if so, skip it
402
            else if ((opponent_statusis == 3) && (onlineplayer->handlestatus != HANDLESTATUS_INTOURNAMENT))
403
               continue; // if so, skip it
404
            else if ((opponent_statusis == 4) && (onlineplayer->handlestatus != HANDLESTATUS_EXAMININGAGAME))
405
               continue; // if so, skip it
406
            else if ((opponent_statusis == 5) && (onlineplayer->handlestatus != HANDLESTATUS_NOTOPENFORAMATCH))
407
               continue; // if so, skip it
408
            else if ((opponent_statusis == 6) && (onlineplayer->handlestatus != HANDLESTATUS_INACTIVEORBUSY))
409
               continue; // if so, skip it
410
            else if ((opponent_statusis == 7) && (onlineplayer->handlestatus != HANDLESTATUS_AVAILABLE))
411
               continue; // if so, skip it
412
 
413
            // should it be skipped because of its rating (low value) ?
414
            if (onlineplayer->rating < opponent_ratingfrom)
415
               continue; // if so, skip it
416
            else if (onlineplayer->rating > opponent_ratingto)
417
               continue; // if so, skip it
418
 
419
            // first, attach the right structure to this item
420
            lvi.lParam = (LPARAM) onlineplayer;
421
 
422
            // set item's image and name
423
            lvi.iItem = onlineplayer_index;
424
            lvi.iImage = listviewicons[onlineplayer->handlestatus];
425
            insert_index = ListView_InsertItem (hListWnd, &lvi); // add each item to list view
426
 
427
            // set item's substrings
428
 
429
            // nickname
430
            ListView_SetItemText (hListWnd, insert_index, 0, onlineplayer->nickname);
431
 
432
            // FIDE rank
433
            if (onlineplayer->handlecodes & HANDLECODE_FIDEGREATMASTER)
434
               ListView_SetItemText (hListWnd, insert_index, 1, STRING_FIDEGM)
435
            else if (onlineplayer->handlecodes & HANDLECODE_FIDEINTERNATIONALMASTER)
436
               ListView_SetItemText (hListWnd, insert_index, 1, STRING_FIDEIM)
437
            else if (onlineplayer->handlecodes & HANDLECODE_FIDEMASTER)
438
               ListView_SetItemText (hListWnd, insert_index, 1, L"M")
439
            else if (onlineplayer->handlecodes & HANDLECODE_FIDEWOMENSGREATMASTER)
440
               ListView_SetItemText (hListWnd, insert_index, 1, STRING_FIDEWGM)
441
            else if (onlineplayer->handlecodes & HANDLECODE_FIDEWOMENSINTERNATIONALMASTER)
442
               ListView_SetItemText (hListWnd, insert_index, 1, STRING_FIDEWIM)
443
 
444
            // status
445
            ListView_SetItemText (hListWnd, insert_index, 2, handlestatus[onlineplayer->handlestatus].text)
446
 
447
            // rating
448
            if (onlineplayer->ratingtype == OPPONENTRATINGTYPE_ESTIMATED)
449
               swprintf_s (rating_string, WCHAR_SIZEOF (rating_string), L"%d (est.)", onlineplayer->rating);
450
            else if (onlineplayer->ratingtype == OPPONENTRATINGTYPE_PROVISIONAL)
451
               swprintf_s (rating_string, WCHAR_SIZEOF (rating_string), L"%d (prov.)", onlineplayer->rating);
452
            else
453
               swprintf_s (rating_string, WCHAR_SIZEOF (rating_string), L"%d", onlineplayer->rating);
454
            ListView_SetItemText (hListWnd, insert_index, 3, rating_string);
455
 
456
            // characteristics coulumns
457
            if (onlineplayer->handlecodes & HANDLECODE_COMPUTER)
458
               ListView_SetItemText (hListWnd, insert_index, 4, L"×");
459
            if (onlineplayer->handlecodes & HANDLECODE_ADMINISTRATOR)
460
               ListView_SetItemText (hListWnd, insert_index, 5, L"×");
461
            if (onlineplayer->handlecodes & HANDLECODE_BLINDFOLD)
462
               ListView_SetItemText (hListWnd, insert_index, 6, L"×");
463
            if (onlineplayer->handlecodes & HANDLECODE_TEAM)
464
               ListView_SetItemText (hListWnd, insert_index, 7, L"×");
465
            if (onlineplayer->handlecodes & HANDLECODE_CHESSADVISOR)
466
               ListView_SetItemText (hListWnd, insert_index, 8, L"×");
467
            if (onlineplayer->handlecodes & HANDLECODE_SERVICEREPRESENTATIVE)
468
               ListView_SetItemText (hListWnd, insert_index, 9, L"×");
469
            if (onlineplayer->handlecodes & HANDLECODE_TOURNAMENTDIRECTOR)
470
               ListView_SetItemText (hListWnd, insert_index, 10, L"×");
471
            if (onlineplayer->handlecodes & HANDLECODE_MAMERMANAGER)
472
               ListView_SetItemText (hListWnd, insert_index, 11, L"×");
473
            if (onlineplayer->handlecodes & HANDLECODE_UNREGISTERED)
474
               ListView_SetItemText (hListWnd, insert_index, 12, L"×");
475
 
476
            displayed_count++; // we displayed now one player more
477
         }
478
 
479
         // now sort the list view according to the column we selected and its current sort order
480
         ListView_SortItems (hListWnd, CompareProc_ListOpponents, current_sortcolumn);
481
 
482
         // cycle through all columns and reset their sort order
483
         for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
484
         {
485
            memset (&hdi, 0, sizeof (hdi));
486
            hdi.mask = HDI_FORMAT;
487
            Header_GetItem (ListView_GetHeader (hListWnd), column_index, &hdi); // get the column's sort arrow state
488
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
489
            if (column_index == current_sortcolumn)
490
               hdi.fmt |= (listviewcolumns[column_index].sort_descending ? HDF_SORTDOWN : HDF_SORTUP);
491
            Header_SetItem (ListView_GetHeader (hListWnd), column_index, &hdi); // update the column's sort arrow state
492
         }
493
 
494
         // now that the display is finished, IF the reply is arrived, set the totals in the window title
495
         if (onlineplayer_count >= 0)
496
         {
497
            swprintf_s (window_title, WCHAR_SIZEOF (window_title), LOCALIZE (L"Opponents_Title"), onlineplayer_count, displayed_count);
498
            SetWindowText (hWnd, window_title);
499
         }
500
 
501
         onlineplayers_updated = false; // remember we updated the list (don't do it twice)
502
      }
124 pmbaty 503
 
504
      return (0); // as MSDN says
1 pmbaty 505
   }
506
 
507
   // is it a list view message ?
508
   else if ((message == WM_NOTIFY) && (wParam == WINDOW_LIST_OPPONENTS))
509
   {
510
      lv = (NMLISTVIEW *) lParam; // quick access to list view
511
 
512
      // is it a click on one of the headers' columns ?
513
      if (lv->hdr.code == LVN_COLUMNCLICK)
514
      {
515
         // cycle through all columns and reset their sort order
516
         for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
517
         {
518
            memset (&hdi, 0, sizeof (hdi));
519
            hdi.mask = HDI_FORMAT;
520
            Header_GetItem (ListView_GetHeader (lv->hdr.hwndFrom), column_index, &hdi); // get the column's sort arrow state
521
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
522
            if (column_index == lv->iSubItem)
523
            {
524
               listviewcolumns[column_index].sort_descending ^= true; // revert the sort order for the clicked column
525
               hdi.fmt |= (listviewcolumns[column_index].sort_descending ? HDF_SORTDOWN : HDF_SORTUP);
526
               current_sortcolumn = column_index; // save the current sort column
527
            }
528
            else
529
               listviewcolumns[column_index].sort_descending = false; // reset the sort order for all the other ones
530
            Header_SetItem (ListView_GetHeader (lv->hdr.hwndFrom), column_index, &hdi); // update the column's sort arrow state
531
         }
532
 
533
         // now sort the list view according to the column we selected and its current sort order
534
         ListView_SortItems (lv->hdr.hwndFrom, CompareProc_ListOpponents, lv->iSubItem);
535
      }
536
 
537
      // else is it a double-click on one of the elements ?
538
      else if (lv->hdr.code == NM_DBLCLK)
539
      {
540
         clickeditem = (NMITEMACTIVATE *) lParam; // get the item it is
541
 
542
         // is it valid ?
543
         if (clickeditem->iItem != -1)
544
         {
545
            // get which item it is in the listview data
546
            memset (&lvi, 0, sizeof (lvi));
547
            lvi.iItem = clickeditem->iItem;
548
            lvi.mask = LVIF_PARAM;
549
            ListView_GetItem (lv->hdr.hwndFrom, &lvi);
550
 
551
            onlineplayer = (onlineplayer_t *) lvi.lParam; // get the online player it is
552
 
553
            local_player = Player_FindByType (PLAYER_HUMAN); // find the local player
554
 
555
            // is it NOT ourselves ? if so, find or create an interlocutor structure for this cc member
556
            if ((local_player != NULL) && (wcscmp (onlineplayer->nickname, local_player->name) != 0))
557
               Interlocutor_FindOrCreate (onlineplayer->nickname);
558
            else
559
               PlayerCard_FindOrCreate (onlineplayer->nickname); // else just display his player card
560
         }
561
      }
124 pmbaty 562
 
563
      return (0); // as MSDN says
1 pmbaty 564
   }
565
 
566
   // else did we take action on one of the controls ?
567
   else if (message == WM_COMMAND)
568
   {
569
      // was the name edit box changed ?
570
      if ((wParam_loword == WINDOW_EDITBOX_NAMECONTAINS) && (wParam_hiword == EN_CHANGE))
571
      {
572
         onlineplayers_updated = true; // remember online player list is to be updated
573
         SendMessage (hWnd, WM_TIMER, WINDOW_TIMER_REFRESH, NULL); // refresh window now
574
      }
575
 
576
      // else was the filter combo box changed ?
577
      else if ((wParam_loword == WINDOW_COMBOBOX_STATUSIS) && (wParam_hiword == CBN_SELCHANGE))
578
      {
579
         onlineplayers_updated = true; // remember online player list is to be updated
580
         SendMessage (hWnd, WM_TIMER, WINDOW_TIMER_REFRESH, NULL); // refresh window now
581
      }
582
 
583
      // else was either of the rating edit box changed ?
584
      else if ((wParam_loword == WINDOW_EDITBOX_LEVELFROM) && (wParam_hiword == EN_CHANGE))
585
      {
586
         onlineplayers_updated = true; // remember online player list is to be updated
587
         SendMessage (hWnd, WM_TIMER, WINDOW_TIMER_REFRESH, NULL); // refresh window now
588
      }
589
      else if ((wParam_loword == WINDOW_EDITBOX_LEVELTO) && (wParam_hiword == EN_CHANGE))
590
      {
591
         onlineplayers_updated = true; // remember online player list is to be updated
592
         SendMessage (hWnd, WM_TIMER, WINDOW_TIMER_REFRESH, NULL); // refresh window now
593
      }
594
 
595
      // else was it the status bar hyperlink ?
596
      else if (wParam_loword == WINDOW_TEXT_STATUSBAR)
597
         ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized
124 pmbaty 598
 
599
      return (0); // as MSDN says
1 pmbaty 600
   }
601
 
602
   // call the default window message processing function to keep things going
603
   return (DefWindowProc (hWnd, message, wParam, lParam));
604
}
605
 
606
 
607
static int CALLBACK CompareProc_ListOpponents (LPARAM lParam1, LPARAM lParam2, LPARAM column)
608
{
609
   // callback function that tells whether the lParam1 listview element comes before lParam2 in the
610
   // sort order of the specified column
611
 
612
   wchar_t *string_to_compare1;
613
   wchar_t *string_to_compare2;
614
 
615
   // nickname
616
   if (column == 0)
617
   {
618
      string_to_compare1 = ((onlineplayer_t *) lParam1)->nickname;
619
      string_to_compare2 = ((onlineplayer_t *) lParam2)->nickname;
620
   }
621
 
622
   // FIDE rank
623
   else if (column == 1)
624
   {
625
      if (((onlineplayer_t *) lParam1)->handlecodes & HANDLECODE_FIDEGREATMASTER)
626
         string_to_compare1 = STRING_FIDEGM;
627
      else if (((onlineplayer_t *) lParam1)->handlecodes & HANDLECODE_FIDEINTERNATIONALMASTER)
628
         string_to_compare1 = STRING_FIDEIM;
629
      else if (((onlineplayer_t *) lParam1)->handlecodes & HANDLECODE_FIDEMASTER)
630
         string_to_compare1 = L"M";
631
      else if (((onlineplayer_t *) lParam1)->handlecodes & HANDLECODE_FIDEWOMENSGREATMASTER)
632
         string_to_compare1 = STRING_FIDEWGM;
633
      else if (((onlineplayer_t *) lParam1)->handlecodes & HANDLECODE_FIDEWOMENSINTERNATIONALMASTER)
634
         string_to_compare1 = STRING_FIDEWIM;
635
      else
636
         string_to_compare1 = L"";
637
 
638
      if (((onlineplayer_t *) lParam2)->handlecodes & HANDLECODE_FIDEGREATMASTER)
639
         string_to_compare2 = STRING_FIDEGM;
640
      else if (((onlineplayer_t *) lParam2)->handlecodes & HANDLECODE_FIDEINTERNATIONALMASTER)
641
         string_to_compare2 = STRING_FIDEIM;
642
      else if (((onlineplayer_t *) lParam2)->handlecodes & HANDLECODE_FIDEMASTER)
643
         string_to_compare2 = L"M";
644
      else if (((onlineplayer_t *) lParam2)->handlecodes & HANDLECODE_FIDEWOMENSGREATMASTER)
645
         string_to_compare2 = STRING_FIDEWGM;
646
      else if (((onlineplayer_t *) lParam2)->handlecodes & HANDLECODE_FIDEWOMENSINTERNATIONALMASTER)
647
         string_to_compare2 = STRING_FIDEWIM;
648
      else
649
         string_to_compare2 = L"";
650
   }
651
 
652
   // status
653
   else if (column == 2)
654
   {
655
      string_to_compare1 = handlestatus[((onlineplayer_t *) lParam1)->handlestatus].text;
656
      string_to_compare2 = handlestatus[((onlineplayer_t *) lParam2)->handlestatus].text;
657
   }
658
 
659
   // FIDE rating
660
   else if (column == 3)
661
   {
662
      if (listviewcolumns[column].sort_descending)
663
         return (((onlineplayer_t *) lParam1)->rating <= ((onlineplayer_t *) lParam2)->rating);
664
      else
665
         return (((onlineplayer_t *) lParam1)->rating >= ((onlineplayer_t *) lParam2)->rating);
666
   }
667
 
668
#define ELSE_IF_COLUMN_SORT_BY_FLAG(col,flag) \
669
   else if (column == (col)) \
670
   { \
671
      string_to_compare1 = (((onlineplayer_t *) lParam1)->handlecodes & (flag) ? L"×" : L" "); \
672
      string_to_compare2 = (((onlineplayer_t *) lParam2)->handlecodes & (flag) ? L"×" : L" "); \
673
   }
674
 
675
   ELSE_IF_COLUMN_SORT_BY_FLAG (4, HANDLECODE_COMPUTER)
676
   ELSE_IF_COLUMN_SORT_BY_FLAG (5, HANDLECODE_ADMINISTRATOR)
677
   ELSE_IF_COLUMN_SORT_BY_FLAG (6, HANDLECODE_BLINDFOLD)
678
   ELSE_IF_COLUMN_SORT_BY_FLAG (7, HANDLECODE_TEAM)
679
   ELSE_IF_COLUMN_SORT_BY_FLAG (8, HANDLECODE_CHESSADVISOR)
680
   ELSE_IF_COLUMN_SORT_BY_FLAG (9, HANDLECODE_SERVICEREPRESENTATIVE)
681
   ELSE_IF_COLUMN_SORT_BY_FLAG (10, HANDLECODE_TOURNAMENTDIRECTOR)
682
   ELSE_IF_COLUMN_SORT_BY_FLAG (11, HANDLECODE_MAMERMANAGER)
683
   ELSE_IF_COLUMN_SORT_BY_FLAG (12, HANDLECODE_UNREGISTERED)
684
 
685
#undef ELSE_IF_COLUMN_SORT_BY_FLAG
686
 
687
   // which order do we want this column to be sorted ?
688
   if (listviewcolumns[column].sort_descending)
689
      return (_wcsicmp (string_to_compare1, string_to_compare2)); // normal order
690
   else
691
      return (-_wcsicmp (string_to_compare1, string_to_compare2)); // reverse order
692
}
693
 
694
 
695
static int WINAPI ListView_WndProc (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
696
{
697
   // callback that subclasses the original ListView window procedure, so that we can hook
698
   // some of its messages
699
 
700
   static bool tooltips_initialized = false;
701
   static bool update_tooltips = false;
702
   WNDPROC BaseWndProc;
703
   TOOLINFO toolinfo;
704
   HWND hHeaderWnd;
705
   int column_index;
706
 
707
   // get a pointer to the base window procedure (it was stored as a window property)
708
   BaseWndProc = (WNDPROC) GetProp (hWnd, L"BaseWndProc");
709
   if (BaseWndProc == NULL)
710
      return (DefWindowProc (hWnd, message, wParam, lParam)); // consistency check
711
 
712
   // is the mouse moving around ?
713
   if (message == WM_MOUSEMOVE)
714
   {
715
      // do the tooltips need to be created ?
716
      if (!tooltips_initialized)
717
      {
718
         hHeaderWnd = (HWND) SendMessage (hWnd, LVM_GETHEADER, 0, 0); // get listview header
719
 
720
         // add a tooltip for each column
721
         for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
722
         {
723
            // create the tooltip and set its window topmost
724
            listviewcolumns[column_index].hToolTipWnd = CreateWindowEx (WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
725
                                                                        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
726
                                                                        hHeaderWnd, NULL, hAppInstance, NULL);
727
 
728
            // associate the tooltip with the tool
729
            memset (&toolinfo, 0, sizeof (toolinfo));
730
            toolinfo.cbSize = sizeof (toolinfo);
731
            toolinfo.uFlags = TTF_SUBCLASS;
732
            toolinfo.hwnd = hHeaderWnd; // this tooltip works on the list header window handle
733
            toolinfo.uId = column_index; // tooltip ID will be column ID
734
            toolinfo.hinst = hAppInstance;
735
            toolinfo.lpszText = listviewcolumns[column_index].text; // tooltip text
736
            Header_GetItemRect (hHeaderWnd, column_index, &toolinfo.rect); // get header's item rectangle
737
            SendMessage (listviewcolumns[column_index].hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM) &toolinfo);
738
         }
739
 
740
         tooltips_initialized = true; // do this only once
741
      }
742
 
743
      // else do the tooltips need to be updated ?
744
      else if (update_tooltips)
745
      {
746
         hHeaderWnd = (HWND) SendMessage (hWnd, LVM_GETHEADER, 0, 0); // get listview header
747
 
748
         // cycle through all columns
749
         for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
750
         {
751
            // update the tooltip rectangle
752
            memset (&toolinfo, 0, sizeof (toolinfo));
753
            toolinfo.cbSize = sizeof (toolinfo);
754
            toolinfo.hwnd = hHeaderWnd; // this tooltip works on the list header window handle
755
            toolinfo.uId = column_index; // tooltip ID is column ID
756
            Header_GetItemRect (hHeaderWnd, column_index, &toolinfo.rect); // get header's item rectangle
757
            SendMessage (listviewcolumns[column_index].hToolTipWnd, TTM_NEWTOOLRECT, 0, (LPARAM) &toolinfo);
758
         }
759
 
760
         update_tooltips = false; // do this only once
761
      }
762
   }
763
 
764
   // else has the user finished dragging/resizing a column header ?
765
   else if ((message == WM_NOTIFY) && ((((NMHDR *) lParam)->code == HDN_ENDTRACK) || (((NMHDR *) lParam)->code == HDN_ENDDRAG)))
766
      update_tooltips = true; // if so, remember to update tooltips on the next mouse move
767
 
768
   // in any case, forward all messages to the original ListView hook procedure
769
   return (CallWindowProc (BaseWndProc, hWnd, message, wParam, lParam));
770
}