-
Notifications
You must be signed in to change notification settings - Fork 30
/
dlgproc.cpp
1467 lines (1341 loc) · 58.5 KB
/
dlgproc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
Copyright 2004 Sebastian Ewert
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
#include "globals.h"
#include "resource.h"
#include <process.h>
#include <commctrl.h>
#include <windowsx.h>
#include <Shobjidl.h>
#include "CSyncQueue.h"
/*****************************************************************************
* INLINE FUNCTIONS for this file *
* functions that are just called at one place (and called often) or that are *
* small and called often are canditates for explicit inlining *
*****************************************************************************/
__inline VOID ProcessTextQuery(NMLVDISPINFO * pnmlvdispinfo);
__inline VOID ProcessColumnClick(CONST HWND arrHwnd[ID_NUM_WINDOWS], CONST NMLISTVIEW * pnmlistview, DWORD * pdwSortStatus);
__inline VOID ProcessSelChangeInList(CONST HWND arrHwnd[ID_NUM_WINDOWS], NMLISTVIEW * pnmlistview, SHOWRESULT_PARAMS * pshowresult_params);
__inline VOID ProcessClickInList(CONST HWND arrHwnd[ID_NUM_WINDOWS], NMITEMACTIVATE * pnmitemactivate, SHOWRESULT_PARAMS * pshowresult_params);
__inline BOOL ProcessKeyPressedInList(CONST HWND arrHwnd[ID_NUM_WINDOWS], CONST LPNMLVKEYDOWN pnkd);
__inline VOID MoveAndSizeWindows(CONST HWND arrHwnd[ID_NUM_WINDOWS], CONST WORD wWidth, CONST WORD wHeight, CONST LONG lACW, CONST LONG lACH);
/*****************************************************************************
LRESULT CALLBACK WndProcMain(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
hWnd : (IN) Handle to the main window
message : (IN) message code
wParam : (IN) wParam
lParam : (IN) lParam
Return Value:
returns 0 or an error code or DefWindowProc()
Notes:
- main window procedure
*****************************************************************************/
LRESULT CALLBACK WndProcMain(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND arrHwnd[ID_NUM_WINDOWS];
static WNDPROC arrOldWndProcs[ID_LAST_TAB_CONTROL - ID_FIRST_TAB_CONTROL + 1];
static LONG lAveCharWidth, lAveCharHeight;
static IDropTarget * pDropTarget;
static THREAD_PARAMS_CALC thread_params_calc;
static HANDLE hThread;
static UINT uiThreadID;
static DWORD dwSortStatus;
static SHOWRESULT_PARAMS showresult_params = {NULL, FALSE, FALSE};
static HMENU popupMenu, headerPopupMenu, hashInNamePopup, hashInStreamPopup, shaPopup, crcPopup, blakePopup;
static std::list<UINT> fileThreadIds;
static int iTimerCount;
lFILEINFO *fileList;
static ITaskbarList3* pTaskbarList = NULL;
static UINT uiTaskbarButtonCreatedMessage = 0;
if(uiTaskbarButtonCreatedMessage && message == uiTaskbarButtonCreatedMessage) {
if(!SUCCEEDED(CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pTaskbarList))))
pTaskbarList = NULL;
}
switch (message)
{
case DM_GETDEFID: break;
case DM_SETDEFID: break;
case WM_CREATE:
SetPriorityClass(GetCurrentProcess(), MyPriorityToPriorityClass(g_program_options.uiPriority));
CreateAndInitChildWindows(arrHwnd, arrOldWndProcs, & lAveCharWidth, & lAveCharHeight, hWnd);
CreateListViewPopupMenu(&popupMenu);
CreateListViewHeaderPopupMenu(&headerPopupMenu);
CreateHashFilenameButtonPopupMenu(&hashInNamePopup);
CreateHashStreamButtonPopupMenu(&hashInStreamPopup);
CreateBlakeButtonPopupMenu(&blakePopup);
CreateShaButtonPopupMenu(&shaPopup);
CreateCrcButtonPopupMenu(&crcPopup);
RegisterDropWindow(arrHwnd, & pDropTarget);
uiTaskbarButtonCreatedMessage = RegisterWindowMessage(L"TaskbarButtonCreated");
return 0;
case WM_CONTEXTMENU:
if((HWND)wParam == arrHwnd[ID_LISTVIEW]) {
int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
if(x == -1 && y == -1) {
POINT pt = {0, 0};
int index = ListView_GetNextItem(arrHwnd[ID_LISTVIEW], -1, LVNI_SELECTED);
if(index >= 0) {
RECT rect;
ListView_GetItemRect(arrHwnd[ID_LISTVIEW], index, &rect, LVIR_LABEL);
pt.x = rect.left;
pt.y = rect.top;
}
ClientToScreen(arrHwnd[ID_LISTVIEW], &pt);
x = pt.x;
y = pt.y;
}
ListViewPopup(arrHwnd, popupMenu, x, y, &showresult_params);
return 0;
}
if((HWND)wParam == arrHwnd[ID_BTN_CRC_IN_FILENAME]) {
int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
if(x == -1 && y == -1) {
POINT pt = {0, 0};
ClientToScreen(arrHwnd[ID_BTN_CRC_IN_FILENAME], &pt);
x = pt.x;
y = pt.y;
}
int ret = TrackPopupMenu(hashInNamePopup, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, arrHwnd[ID_BTN_CRC_IN_FILENAME], NULL);
if(ret)
ActionHashIntoFilename(arrHwnd, ret - IDM_CRC_FILENAME);
return 0;
} else if((HWND)wParam == arrHwnd[ID_BTN_CRC_IN_SFV]) {
int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
if(x == -1 && y == -1) {
POINT pt = {0, 0};
ClientToScreen(arrHwnd[ID_BTN_CRC_IN_SFV], &pt);
x = pt.x;
y = pt.y;
}
int ret = TrackPopupMenu(crcPopup, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, arrHwnd[ID_BTN_CRC_IN_SFV], NULL);
if(ret)
CreateChecksumFiles(arrHwnd, ret - IDM_CRC_SFV);
return 0;
} else if ((HWND)wParam == arrHwnd[ID_BTN_CRC_IN_STREAM]) {
int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
if (x == -1 && y == -1) {
POINT pt = { 0, 0 };
ClientToScreen(arrHwnd[ID_BTN_CRC_IN_STREAM], &pt);
x = pt.x;
y = pt.y;
}
int ret = TrackPopupMenu(hashInStreamPopup, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, arrHwnd[ID_BTN_CRC_IN_STREAM], NULL);
if (ret)
ActionHashIntoStream(arrHwnd, ret - IDM_CRC_STREAM);
return 0;
}
break;
case WM_NOTIFY:
switch(wParam)
{
case 0:
switch (((LPNMHDR) lParam)->code)
{
case NM_RCLICK:
// we need screen coordintes for the popup window
DWORD dwPos;
dwPos = GetMessagePos();
if(ListViewHeaderPopup(arrHwnd[ID_LISTVIEW], headerPopupMenu, GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos)))
UpdateListViewColumns(arrHwnd, lAveCharWidth);
return 1;
}
break;
case ID_LISTVIEW:
switch (((LPNMHDR) lParam)->code)
{
case LVN_GETDISPINFO:
ProcessTextQuery((NMLVDISPINFO *) lParam);
return 0;
case LVN_COLUMNCLICK:
ProcessColumnClick(arrHwnd, (NMLISTVIEW *) lParam, & dwSortStatus);
return 0;
case LVN_ITEMCHANGED:
if((((NMLISTVIEW *)lParam)->uChanged & LVIF_STATE) && (((NMLISTVIEW *)lParam)->uNewState & LVIS_SELECTED))
ProcessSelChangeInList(arrHwnd, (NMLISTVIEW *) lParam, & showresult_params);
return 0;
case NM_CLICK: //now handled by LVN_ITEMCHANGED
//ProcessClickInList(arrHwnd, (NMITEMACTIVATE *) lParam, & showresult_params);
//return 0;
break;
case NM_RCLICK:
// we need screen coordintes for the popup window
//ClientToScreen(arrHwnd[ID_LISTVIEW],&(((NMITEMACTIVATE *)lParam)->ptAction));
//ListViewPopup(arrHwnd,popupMenu,((NMITEMACTIVATE *)lParam)->ptAction.x,((NMITEMACTIVATE *)lParam)->ptAction.y,&showresult_params);
return 0;
case LVN_KEYDOWN: //now handled by LVN_ITEMCHANGED
if(ProcessKeyPressedInList(arrHwnd, (LPNMLVKEYDOWN) lParam))
return 0;
break;
case LVN_INSERTITEM:
if(g_program_options.bAutoScrollListView)
ListView_EnsureVisible(arrHwnd[ID_LISTVIEW],((LPNMLISTVIEW)lParam)->iItem,FALSE);
return 0;
}
break;
}
break;
case WM_CTLCOLORSTATIC:
for(int i=0;i<NUM_HASH_TYPES;i++) {
if(showresult_params.bHashIsWrong[i]){
if((HWND)lParam == arrHwnd[ID_EDIT_CRC_VALUE + i]){
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHT));
return (LRESULT)GetSysColorBrush(COLOR_HIGHLIGHT);
}
}
}
break;
case WM_GETMINMAXINFO:
((MINMAXINFO *)lParam)->ptMinTrackSize.x = lAveCharWidth * 125;
((MINMAXINFO *)lParam)->ptMinTrackSize.y = lAveCharHeight * 25;
return 0;
case WM_SIZE:
MoveAndSizeWindows(arrHwnd, LOWORD(lParam), HIWORD(lParam), lAveCharWidth, lAveCharHeight);
RedrawWindow(arrHwnd[ID_MAIN_WND], NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
return 0;
case WM_THREAD_FILEINFO_START:
fileList = (lFILEINFO *)wParam;
fileThreadIds.push_back(StartFileInfoThread(arrHwnd,&showresult_params,fileList));
return TRUE;
case WM_THREAD_FILEINFO_DONE:
for(std::list<UINT>::iterator it = fileThreadIds.begin(); it != fileThreadIds.end(); it++) {
if((*it) == wParam) {
fileThreadIds.erase(it);
break;
}
}
DisplayStatusOverview(arrHwnd[ID_EDIT_STATUS]);
// go on with the CRC Calculation
case WM_START_THREAD_CALC:
//only start thread if not currently running
if(!SyncQueue.bThreadDone) return 0;
thread_params_calc.arrHwnd = arrHwnd;
thread_params_calc.signalExit = FALSE;
thread_params_calc.signalStop = FALSE;
thread_params_calc.pshowresult_params = & showresult_params;
thread_params_calc.qwBytesReadAllFiles = 0;
thread_params_calc.qwBytesReadCurFile = 0;
thread_params_calc.pFileinfo_cur = NULL;
//reset filesize count for current thread run
SyncQueue.setFileAccForCalc();
SyncQueue.bThreadDone = false;
iTimerCount = 0;
hThread = (HANDLE)_beginthreadex(NULL, 0, ThreadProc_Calc, &thread_params_calc, 0, &uiThreadID);
SendMessage(arrHwnd[ID_PROGRESS_FILE], PBM_SETPOS , (WPARAM) 0, 0);
SendMessage(arrHwnd[ID_PROGRESS_GLOBAL], PBM_SETPOS , (WPARAM) 0, 0);
if(pTaskbarList)
pTaskbarList->SetProgressValue(hWnd, 0, 100);
SetTimer(hWnd, WM_TIMER_PROGRESS_500, 500, NULL);
return 0;
case WM_THREAD_CALC_DONE:
CloseHandle(hThread);
SyncQueue.bThreadDone = true;
KillTimer(hWnd, WM_TIMER_PROGRESS_500); // does not remove existing WM_TIMER messages
// set the progress bar explicitly because in some situations with 0 byte files it is
// not set to 100% via WM_TIMER
SendMessage(arrHwnd[ID_PROGRESS_FILE], PBM_SETPOS , (WPARAM) 100, 0);
SendMessage(arrHwnd[ID_PROGRESS_GLOBAL], PBM_SETPOS , (WPARAM) 100, 0);
if(pTaskbarList)
pTaskbarList->SetProgressState(hWnd, TBPF_NOPROGRESS);
//if queue is empty start another thread
//message is ignored if another WM_START_THREAD_CALC is already in the message queue
if(!SyncQueue.isQueueEmpty()) {
PostMessage(arrHwnd[ID_MAIN_WND], WM_START_THREAD_CALC, NULL,NULL);
return 0;
}
SetMainWindowTitle(hWnd, 0, 0.);
DisplayStatusOverview(arrHwnd[ID_EDIT_STATUS]);
if (g_pstatus.bStartedWithClosableShellExtAction &&
g_program_options.bCloseAfterActionFromShellExt &&
SyncQueue.dwCountErrors == 0)
{
PostQuitMessage(0);
}
return 0;
case WM_ACCEPT_PIPE: //message generated by another rapidcrc instance if queueing is enabled
//wparam is the action to perform (if invoked by the shell extension)
fileList = new lFILEINFO;
fileList->uiCmdOpts = (UINT)wParam;
StartAcceptPipeThread(arrHwnd,fileList);
return 0;
case WM_COPYDATA:
{
fileList = new lFILEINFO;
FILEINFO fileinfoTmp = {0};
LPTSTR* argv;
INT argc;
argv = CommandLineToArgv((TCHAR *)((PCOPYDATASTRUCT) lParam)->lpData, &argc);
fileList->uiCmdOpts = CMD_NORMAL;
fileinfoTmp.parentList = fileList;
for(INT i = 0; i < argc - 1; ++i){
fileinfoTmp.szFilename = argv[i+1];
fileList->fInfos.push_back(fileinfoTmp);
}
LocalFree(argv);
PostMessage(arrHwnd[ID_MAIN_WND],WM_THREAD_FILEINFO_START,(WPARAM)fileList,NULL);
return TRUE;
}
case WM_TIMER:
if(!SyncQueue.bThreadSuspended)
iTimerCount++;
if(!SyncQueue.bThreadDone && thread_params_calc.pFileinfo_cur != NULL){
if(thread_params_calc.pFileinfo_cur->qwFilesize != 0){
INT iNewPos = (INT)((thread_params_calc.qwBytesReadCurFile * 100 ) /
thread_params_calc.pFileinfo_cur->qwFilesize);
// default range is 0 - 100. If below or beyond these limits: iNewPos is set to 0 or 100
SendMessage(arrHwnd[ID_PROGRESS_FILE], PBM_SETPOS , (WPARAM) (INT) iNewPos, 0);
}
if(SyncQueue.qwNewFileAcc != 0){
INT iNewPos = (INT)((thread_params_calc.qwBytesReadAllFiles * 100 ) / SyncQueue.qwNewFileAcc);
SendMessage(arrHwnd[ID_PROGRESS_GLOBAL], PBM_SETPOS , (WPARAM) (INT) iNewPos, 0);
if(pTaskbarList)
pTaskbarList->SetProgressValue(hWnd, iNewPos, 100);
double bytes_per_second = thread_params_calc.qwBytesReadAllFiles / ( iTimerCount * 0.5 );
int seconds = (int)((SyncQueue.qwNewFileAcc - thread_params_calc.qwBytesReadAllFiles) / bytes_per_second);
SetMainWindowTitle(hWnd, seconds, bytes_per_second);
}
}
return 0;
case WM_KEYDOWN:
if(VK_TAB == wParam)
SetFocus(arrHwnd[ID_FIRST_TAB_CONTROL]);
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_BTN_EXIT:
if(HIWORD(wParam) == BN_CLICKED){
SendMessage(hWnd, WM_CLOSE, 0, 0);
return 0;
}
break;
case ID_BTN_CRC_IN_STREAM:
if(HIWORD(wParam) == BN_CLICKED){
ActionHashIntoStream(arrHwnd, HASH_TYPE_CRC32);
return 0;
}
break;
case ID_BTN_CRC_IN_FILENAME:
if(HIWORD(wParam) == BN_CLICKED){
ActionHashIntoFilename(arrHwnd, HASH_TYPE_CRC32);
return 0;
}
break;
case ID_BTN_CRC_IN_SFV:
if(HIWORD(wParam) == BN_CLICKED){
CreateChecksumFiles(arrHwnd, MODE_SFV);
return 0;
}
break;
case ID_BTN_MD5_IN_MD5:
if(HIWORD(wParam) == BN_CLICKED){
CreateChecksumFiles(arrHwnd, MODE_MD5);
return 0;
}
break;
case ID_BTN_SHA_IN_SHA:
if(HIWORD(wParam) == BN_CLICKED){
RECT rect;
GetWindowRect(arrHwnd[ID_BTN_SHA_IN_SHA], &rect);
int x = rect.left, y = rect.bottom;
int ret = TrackPopupMenu(shaPopup, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, arrHwnd[ID_BTN_SHA_IN_SHA], NULL);
if(ret)
CreateChecksumFiles(arrHwnd, MODE_SHA1 + ret - IDM_SHA1);
return 0;
}
break;
case ID_BTN_BLAKE_IN_BLAKE:
if (HIWORD(wParam) == BN_CLICKED) {
RECT rect;
GetWindowRect(arrHwnd[ID_BTN_BLAKE_IN_BLAKE], &rect);
int x = rect.left, y = rect.bottom;
int ret = TrackPopupMenu(blakePopup, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, arrHwnd[ID_BTN_BLAKE_IN_BLAKE], NULL);
if (ret)
CreateChecksumFiles(arrHwnd, MODE_BLAKE2SP + ret - IDM_BLAKE);
return 0;
}
break;
case ID_BTN_ERROR_DESCR:
if(HIWORD(wParam) == BN_CLICKED){
ShowErrorMsg(hWnd, showresult_params.pFileinfo_cur_displayed->dwError );
return 0;
}
break;
case ID_BTN_OPENFILES_PAUSE:
if(HIWORD(wParam) == BN_CLICKED){
OpenFiles(arrHwnd);
return 0;
}
break;
case ID_BTN_PLAY_PAUSE:
if(!SyncQueue.bThreadDone)
if(SyncQueue.bThreadSuspended){
ResumeThread(hThread);
SendMessage(arrHwnd[ID_BTN_PLAY_PAUSE],BM_SETIMAGE,IMAGE_ICON,(LPARAM)LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON_PAUSE),IMAGE_ICON,16,16,LR_DEFAULTCOLOR|LR_SHARED));
SyncQueue.bThreadSuspended = FALSE;
if(pTaskbarList)
pTaskbarList->SetProgressState(hWnd, TBPF_NORMAL);
}
else{
SuspendThread(hThread);
SendMessage(arrHwnd[ID_BTN_PLAY_PAUSE],BM_SETIMAGE,IMAGE_ICON,(LPARAM)LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON_PLAY),IMAGE_ICON,16,16,LR_DEFAULTCOLOR|LR_SHARED));
SyncQueue.bThreadSuspended = TRUE;
if(pTaskbarList)
pTaskbarList->SetProgressState(hWnd, TBPF_PAUSED);
}
break;
case ID_BTN_STOP:
if(!SyncQueue.bThreadDone) {
thread_params_calc.signalStop = TRUE;
// if paused resume, thread will stop
if(SyncQueue.bThreadSuspended){
PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(ID_BTN_PLAY_PAUSE, 0), 0);
}
}
break;
case ID_BTN_OPTIONS:
if(HIWORD(wParam) == BN_CLICKED){
BOOL prevQueue=g_program_options.bEnableQueue;
if( DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_OPTIONS), hWnd, DlgProcOptions) == IDOK) {
//if the queueing option has been changed we need to clear the lists, since this also enables/disables grouping
if(prevQueue!=g_program_options.bEnableQueue) {
ClearAllItems(arrHwnd,&showresult_params);
if(g_pstatus.bHaveComCtrlv6)
ListView_EnableGroupView(arrHwnd[ID_LISTVIEW],g_program_options.bEnableQueue);
}
UpdateListViewColumns(arrHwnd, lAveCharWidth);
}
return 0;
}
break;
case ID_COMBO_PRIORITY:
if(HIWORD(wParam) == CBN_SELCHANGE){
g_program_options.uiPriority = (UINT) SendMessage(arrHwnd[ID_COMBO_PRIORITY], CB_GETCURSEL, 0, 0);
SetPriorityClass(GetCurrentProcess(), MyPriorityToPriorityClass(g_program_options.uiPriority));
return 0;
}
break;
}
break;
case WM_ENDSESSION:
case WM_CLOSE:
WriteOptions(hWnd, lAveCharWidth, lAveCharHeight);
UnregisterDropWindow(arrHwnd[ID_LISTVIEW], pDropTarget);
//signal the calculation thread that we want to exit
//this causes the theads to end in a controlled manner
if(!SyncQueue.bThreadDone){
thread_params_calc.signalStop = TRUE;
thread_params_calc.signalExit = TRUE;
if(SyncQueue.bThreadSuspended)
ResumeThread(hThread);
while(MsgWaitForMultipleObjects(1, &hThread, FALSE, 4000, QS_SENDMESSAGE) == WAIT_OBJECT_0 + 1) {
MSG msg;
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
}
}
// if file info threads are still running simply kill them to avoid access violations
for(std::list<UINT>::iterator it = fileThreadIds.begin(); it != fileThreadIds.end(); it++) {
if(HANDLE thread = OpenThread(THREAD_TERMINATE, FALSE, (*it)))
TerminateThread(thread, 1);
}
OleUninitialize();
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
/*****************************************************************************
INT_PTR CALLBACK DlgProcOptions (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
hDlg : (IN) Handle to the Dialog / Window
message : (IN) message code
wParam : (IN) wParam
lParam : (IN) lParam
Return Value:
returns TRUE if a message was processed. FALSE otherwise
Notes:
- dialog procedure for options dialog
*****************************************************************************/
INT_PTR CALLBACK DlgProcOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static PROGRAM_OPTIONS program_options_temp;
TCHAR szTemp[MAX_PATH_EX];
size_t szLen;
HWND dlgItem;
switch (message)
{
case WM_INITDIALOG :
dlgItem = GetDlgItem(hDlg,IDC_UNICODE_TYPE);
ComboBox_SetItemData(dlgItem,ComboBox_AddString(dlgItem,TEXT("UTF-8 with BOM")),UTF_8_BOM);
ComboBox_SetItemData(dlgItem,ComboBox_AddString(dlgItem,TEXT("UTF-16 LE")),UTF_16LE);
ComboBox_SetItemData(dlgItem,ComboBox_AddString(dlgItem,TEXT("UTF-8")),UTF_8);
dlgItem = GetDlgItem(hDlg,IDC_DEFAULT_CP);
ComboBox_SetItemData(dlgItem,ComboBox_AddString(dlgItem,TEXT("System Codepage")),CP_ACP);
ComboBox_SetItemData(dlgItem,ComboBox_AddString(dlgItem,TEXT("UTF-8")),CP_UTF8);
// copy current options to local copy
CopyJustProgramOptions(& g_program_options, & program_options_temp);
UpdateOptionsDialogControls(hDlg, TRUE, & program_options_temp);
EnableWindow(GetDlgItem(hDlg,IDC_ENABLE_QUEUE),g_pstatus.bHaveComCtrlv6);
EnableWindow(GetDlgItem(hDlg, IDC_ALWAYS_USE_NEW_WINDOW), program_options_temp.bEnableQueue);
return TRUE;
//is fired when the user clicks on a control; the id of the control is in LOWORD (wParam)
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDCANCEL:
if(HIWORD(wParam) == BN_CLICKED){
// this is also TRUE if the user clicks on the close box in the title bar
EndDialog (hDlg, IDCANCEL) ;
return TRUE ;
}
break;
case IDOK:
if(HIWORD(wParam) == BN_CLICKED){
// accept the changes and copy back the local options to the global one
CopyJustProgramOptions(& program_options_temp, & g_program_options);
EndDialog (hDlg, IDOK) ;
return TRUE;
}
break;
case IDC_EDIT_FILENAME_PATTERN:
if(HIWORD(wParam) == EN_CHANGE){
GetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_PATTERN), szTemp, MAX_PATH_EX);
if(IsLegalFilename(szTemp)){
StringCchCopy(program_options_temp.szFilenamePattern, MAX_PATH_EX, szTemp);
UpdateOptionsDialogControls(hDlg, FALSE, & program_options_temp);
}
else
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_PATTERN), program_options_temp.szFilenamePattern);
return TRUE;
}
break;
case IDC_EDIT_EXCLUDE_LIST:
if(HIWORD(wParam) == EN_CHANGE){
GetWindowText(GetDlgItem(hDlg, IDC_EDIT_EXCLUDE_LIST), szTemp, MAX_PATH_EX);
StringCchLength(szTemp,MAX_PATH_EX,&szLen);
if(szLen!=0 && *(szTemp + szLen - 1) != TEXT(';')) {
StringCchCat(szTemp,MAX_PATH_EX,TEXT(";"));
}
StringCchCopy(program_options_temp.szExcludeString, MAX_PATH_EX, szTemp);
return TRUE;
}
break;
case IDC_CRC_DELIM_LIST:
if(HIWORD(wParam) == EN_CHANGE){
GetWindowText(GetDlgItem(hDlg, IDC_CRC_DELIM_LIST), szTemp, MAX_PATH_EX);
StringCchCopy(program_options_temp.szCRCStringDelims, MAX_PATH_EX, szTemp);
return TRUE;
}
break;
case IDC_EDIT_READ_BUFFER_SIZE:
if(HIWORD(wParam) == EN_CHANGE){
GetWindowText(GetDlgItem(hDlg, IDC_EDIT_READ_BUFFER_SIZE), szTemp, MAX_PATH_EX);
program_options_temp.uiReadBufferSizeKb =_ttoi(szTemp);
if(program_options_temp.uiReadBufferSizeKb < 1 || program_options_temp.uiReadBufferSizeKb > 20 * 1024)
program_options_temp.uiReadBufferSizeKb = DEFAULT_BUFFER_SIZE_CALC;
return TRUE;
}
break;
case IDC_BTN_DEFAULT:
if(HIWORD(wParam) == BN_CLICKED){
SetDefaultOptions(& program_options_temp);
UpdateOptionsDialogControls(hDlg, TRUE, & program_options_temp);
return TRUE;
}
break;
case IDC_BTN_CONTEXT_MENU:
if(HIWORD(wParam) == BN_CLICKED){
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_CONTEXT_MENU), hDlg, DlgProcCtxMenu);
return TRUE;
}
break;
case IDC_CHECK_SORT_LIST:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bSortList = (IsDlgButtonChecked(hDlg, IDC_CHECK_SORT_LIST) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_AUTO_SCROLL:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bAutoScrollListView = (IsDlgButtonChecked(hDlg, IDC_CHECK_AUTO_SCROLL) == BST_CHECKED);
return TRUE;
}
break;
case IDC_ENABLE_QUEUE:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bEnableQueue = (IsDlgButtonChecked(hDlg, IDC_ENABLE_QUEUE) == BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_ALWAYS_USE_NEW_WINDOW), program_options_temp.bEnableQueue);
return TRUE;
}
break;
case IDC_ALWAYS_USE_NEW_WINDOW:
if (HIWORD(wParam) == BN_CLICKED) {
program_options_temp.bAlwaysUseNewWindow = (IsDlgButtonChecked(hDlg, IDC_ALWAYS_USE_NEW_WINDOW) == BST_CHECKED);
return TRUE;
}
break;
case IDC_USE_DEFAULT_CP:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bUseDefaultCP = (IsDlgButtonChecked(hDlg, IDC_USE_DEFAULT_CP) == BST_CHECKED);
return TRUE;
}
break;
case IDC_ENABLE_UNBUFFERED_READS:
if (HIWORD(wParam) == BN_CLICKED) {
program_options_temp.bUseUnbufferedReads = (IsDlgButtonChecked(hDlg, IDC_ENABLE_UNBUFFERED_READS) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CLOSE_AFTER_SHELLEXT_ACTION:
if (HIWORD(wParam) == BN_CLICKED) {
program_options_temp.bCloseAfterActionFromShellExt = (IsDlgButtonChecked(hDlg, IDC_CLOSE_AFTER_SHELLEXT_ACTION) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_HASHTYPE_FROM_FILENAME:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bHashtypeFromFilename = (IsDlgButtonChecked(hDlg, IDC_CHECK_HASHTYPE_FROM_FILENAME) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_WINSFV_COMP:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bWinsfvComp = (IsDlgButtonChecked(hDlg, IDC_CHECK_WINSFV_COMP) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_DO_NOT_OVERRIDE:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bNoHashFileOverride = (IsDlgButtonChecked(hDlg, IDC_CHECK_DO_NOT_OVERRIDE) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_INCLUDE_COMMENTS:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bIncludeFileComments = (IsDlgButtonChecked(hDlg, IDC_CHECK_INCLUDE_COMMENTS) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_CREATE_UNIX_STYLE:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bCreateUnixStyle = (IsDlgButtonChecked(hDlg, IDC_CHECK_CREATE_UNIX_STYLE) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_CREATE_UNICODE_FILES:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bCreateUnicodeFiles = (IsDlgButtonChecked(hDlg, IDC_CHECK_CREATE_UNICODE_FILES) == BST_CHECKED);
return TRUE;
}
break;
case IDC_RADIO_HEX_DEFAULT:
case IDC_RADIO_HEX_UPPERCASE:
case IDC_RADIO_HEX_LOWERCASE:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.iHexFormat = (HEX_FORMAT)(LOWORD (wParam) - IDC_RADIO_HEX_DEFAULT);
return TRUE;
}
break;
case IDC_CHECK_CRC_DEFAULT:
case IDC_CHECK_MD5_DEFAULT:
case IDC_CHECK_ED2K_DEFAULT:
case IDC_CHECK_SHA1_DEFAULT:
case IDC_CHECK_SHA256_DEFAULT:
case IDC_CHECK_SHA512_DEFAULT:
case IDC_CHECK_SHA3_224_DEFAULT:
case IDC_CHECK_SHA3_256_DEFAULT:
case IDC_CHECK_SHA3_512_DEFAULT:
case IDC_CHECK_CRCC_DEFAULT:
case IDC_CHECK_BLAKE2SP_DEFAULT:
case IDC_CHECK_BLAKE3_DEFAULT:
if(HIWORD(wParam) == BN_CLICKED){
unsigned int offset = LOWORD(wParam) - IDC_CHECK_CRC_DEFAULT;
program_options_temp.bCalcPerDefault[offset] = (IsDlgButtonChecked(hDlg, LOWORD(wParam)) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_DISPLAY_CRC_IN_LIST:
case IDC_CHECK_DISPLAY_ED2K_IN_LIST:
case IDC_CHECK_DISPLAY_MD5_IN_LIST:
case IDC_CHECK_DISPLAY_SHA1_IN_LIST:
case IDC_CHECK_DISPLAY_SHA256_IN_LIST:
case IDC_CHECK_DISPLAY_SHA512_IN_LIST:
case IDC_CHECK_DISPLAY_SHA3_224_IN_LIST:
case IDC_CHECK_DISPLAY_SHA3_256_IN_LIST:
case IDC_CHECK_DISPLAY_SHA3_512_IN_LIST:
case IDC_CHECK_DISPLAY_CRCC_IN_LIST:
case IDC_CHECK_DISPLAY_BLAKE2SP_IN_LIST:
case IDC_CHECK_DISPLAY_BLAKE3_IN_LIST:
if(HIWORD(wParam) == BN_CLICKED){
unsigned int offset = LOWORD(wParam) - IDC_CHECK_DISPLAY_CRC_IN_LIST;
program_options_temp.bDisplayInListView[offset] = (IsDlgButtonChecked(hDlg, LOWORD(wParam)) == BST_CHECKED);
return TRUE;
}
break;
case IDC_CHECK_HIDE_VERIFIED:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bHideVerified = (IsDlgButtonChecked(hDlg, IDC_CHECK_HIDE_VERIFIED) == BST_CHECKED);
return TRUE;
}
break;
case IDC_ALLOW_CRC_ANYWHERE:
if(HIWORD(wParam) == BN_CLICKED){
program_options_temp.bAllowCrcAnywhere = (IsDlgButtonChecked(hDlg, IDC_ALLOW_CRC_ANYWHERE) == BST_CHECKED);
return TRUE;
}
break;
case IDC_UNICODE_TYPE:
if(HIWORD(wParam) == CBN_SELCHANGE){
dlgItem = GetDlgItem(hDlg, IDC_UNICODE_TYPE);
program_options_temp.iUnicodeSaveType = (UNICODE_TYPE)ComboBox_GetItemData(dlgItem, ComboBox_GetCurSel(dlgItem));
return TRUE;
}
break;
case IDC_DEFAULT_CP:
if(HIWORD(wParam) == CBN_SELCHANGE){
dlgItem = GetDlgItem(hDlg, IDC_DEFAULT_CP);
program_options_temp.uiDefaultCP = (UINT)ComboBox_GetItemData(dlgItem, ComboBox_GetCurSel(dlgItem));
return TRUE;
}
break;
}
break;
}
return FALSE ;
}
INT_PTR CALLBACK DlgProcCtxMenu(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static std::map<int,int> checkbox_y_map;
#define MAX_CONTEX_CHECKBOXES_ID 16
switch (message)
{
case WM_INITDIALOG :
{
unsigned int mask = 0;
HKEY hKey;
if(RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\RapidCRC"),
0, KEY_QUERY_VALUE
#ifdef _WIN64
| KEY_WOW64_32KEY
#endif
, &hKey) == ERROR_SUCCESS)
{
DWORD dwRegLength = 4;
DWORD dwRegContent, dwRegType;
if(RegQueryValueEx(hKey, TEXT("ShellExtMenuItemsMask"), NULL, & dwRegType, (LPBYTE)&dwRegContent, & dwRegLength) == ERROR_SUCCESS ) {
if(dwRegType == REG_DWORD)
mask = dwRegContent;
}
RegCloseKey(hKey);
}
// order the checkboxes by ascending y position in this map
checkbox_y_map.clear();
for(int i = 0; i < MAX_CONTEX_CHECKBOXES_ID; i++) {
if(!(1 << i & mask)) {
CheckDlgButton(hDlg, IDC_CHECK_CONTEXT1 + i, BST_CHECKED);
}
RECT rect;
GetClientRect(GetDlgItem(hDlg, IDC_CHECK_CONTEXT1 + i), &rect);
MapWindowPoints(GetDlgItem(hDlg, IDC_CHECK_CONTEXT1 + i), hDlg, (LPPOINT)&rect, 2);
checkbox_y_map.insert(std::pair<int,int>(rect.bottom, i));
}
}
return TRUE;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDCANCEL:
if(HIWORD(wParam) == BN_CLICKED){
// this is also TRUE if the user clicks on the close box in the title bar
EndDialog (hDlg, IDCANCEL) ;
return TRUE ;
}
break;
case IDOK:
if(HIWORD(wParam) == BN_CLICKED){
unsigned mask = 0;
for(int i = 0; i < MAX_CONTEX_CHECKBOXES_ID; i++) {
if(!IsDlgButtonChecked(hDlg, IDC_CHECK_CONTEXT1 + i) == BST_CHECKED) {
mask |= 1 << i;
}
}
HKEY hKey;
if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\RapidCRC"), 0, NULL,
0, KEY_SET_VALUE
#ifdef _WIN64
| KEY_WOW64_32KEY
#endif
, NULL
, &hKey
, NULL ) == ERROR_SUCCESS)
{
if(LONG regResult = RegSetValueEx(hKey, TEXT("ShellExtMenuItemsMask"), NULL, REG_DWORD, (BYTE *)&mask, 4) != ERROR_SUCCESS){
ShowErrorMsg(NULL, regResult);
}
RegCloseKey(hKey);
}
EndDialog (hDlg, IDOK) ;
return TRUE;
}
break;
case IDC_STATIC_CTX:
if(HIWORD(wParam) == STN_CLICKED){
DWORD dwPos = GetMessagePos();
POINT pos = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) };
ScreenToClient(hDlg, &pos);
// check y positions in ascending order to see which checkbox should be toggled
for(std::map<int,int>::iterator it = checkbox_y_map.begin(); it != checkbox_y_map.end(); it++) {
if(pos.y < it->first) {
CheckDlgButton(hDlg, IDC_CHECK_CONTEXT1 + it->second, IsDlgButtonChecked(hDlg, IDC_CHECK_CONTEXT1 + it->second) ? BST_UNCHECKED : BST_CHECKED);
break;
}
}
return TRUE ;
}
break;
}
}
return FALSE ;
}
/*****************************************************************************
INT_PTR CALLBACK DlgProcFileCreation(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
hDlg : (IN) Handle to the Dialog / Window
message : (IN) message code
wParam : (IN) wParam
lParam : (IN) lParam
Return Value:
returns TRUE if a message was processed. FALSE otherwise
Notes:
- dialog procedure for file creation dialog; displays 3 options how to create sfv/md5 files
*****************************************************************************/
INT_PTR CALLBACK DlgProcFileCreation(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
TCHAR szString[MAX_PATH_EX];
static FILECREATION_OPTIONS * pfco;
static TCHAR szFilenameChecksumTemp[MAX_PATH_EX];
TCHAR *hashExt;
switch (message)
{
case WM_INITDIALOG :
pfco = (FILECREATION_OPTIONS *)lParam;
StringCchCopy(szFilenameChecksumTemp, MAX_PATH_EX, pfco->szFilename);
case WM_SET_CTRLS_STATE:
hashExt = g_hash_ext[pfco->uiMode];
StringCchPrintf(szString, MAX_PATH_EX, TEXT("How to create the .%s file(s)?"), hashExt);
SetWindowText(hDlg, szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Please choose how you want to write %s files into the .%s file:"),
pfco->uiNumSelected == 0 ? TEXT("all") : TEXT("the selected"), hashExt);
SetWindowText(GetDlgItem(hDlg, IDC_STATIC_INTRO_TEXT), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create a .%s file for every single file%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (md5sum compatible)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_PER_FILE), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create a .%s file for every directory%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (md5sum compatible)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_PER_DIR), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create one .%s file for all files%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (potentially not md5sum compatible *)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_FILE), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create one .%s file for all files with automatic name%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (*)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_FILE_DIR_NAME), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create one .%s file per job%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (potentially not md5sum compatible *)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_PER_JOB), szString);
StringCchPrintf(szString, MAX_PATH_EX, TEXT("Create one .%s file per job with automatic name%s"),
hashExt, pfco->uiMode == MODE_MD5 ? TEXT(" (*)") : TEXT("") );
SetWindowText(GetDlgItem(hDlg, IDC_RADIO_ONE_PER_JOB_DIR_NAME), szString);
SetWindowText(GetDlgItem(hDlg, IDC_STATIC_EXPLANATION),
pfco->uiMode == MODE_MD5 ? TEXT("* : md5sum compatible .MD5 files cannot hold directory information") : TEXT(""));
switch(pfco->uiCreateFileMode){
case CREATE_ONE_PER_FILE:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_PER_FILE, BM_CLICK, 0, 0);
break;
case CREATE_ONE_PER_DIR:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_PER_DIR, BM_CLICK, 0, 0);
break;
case CREATE_ONE_FILE:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_FILE, BM_CLICK, 0, 0);
break;
case CREATE_ONE_FILE_DIR_NAME:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_FILE_DIR_NAME, BM_CLICK, 0, 0);
break;
case CREATE_ONE_PER_JOB:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_PER_JOB, BM_CLICK, 0, 0);
break;
case CREATE_ONE_PER_JOB_DIR_NAME:
SendDlgItemMessage(hDlg, IDC_RADIO_ONE_PER_JOB_DIR_NAME, BM_CLICK, 0, 0);
break;
}
if(pfco->bSaveAbsolute)
SendDlgItemMessage(hDlg, IDC_CHECK_ABSOLUTE_PATHS, BM_CLICK, 0, 0);
return TRUE;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDC_RADIO_ONE_PER_FILE:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TEXT("<Created from filename>"));
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), FALSE);
return TRUE;
}
break;
case IDC_RADIO_ONE_PER_DIR:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), szFilenameChecksumTemp);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TRUE);
return TRUE;
}
break;
case IDC_RADIO_ONE_FILE:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TEXT("<You are asked in the next step>"));
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), FALSE);
return TRUE;
}
break;
case IDC_RADIO_ONE_FILE_DIR_NAME:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TEXT("<You are asked in the next step>"));
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), FALSE);
return TRUE;
}
break;
case IDC_RADIO_ONE_PER_JOB:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TEXT("<You are asked in the next step>"));
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), FALSE);
return TRUE;
}
break;
case IDC_RADIO_ONE_PER_JOB_DIR_NAME:
if(HIWORD(wParam) == BN_CLICKED){
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), TEXT("<You are asked in the next step>"));
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), FALSE);
return TRUE;
}
break;
case IDC_EDIT_FILENAME_CHECKSUM:
if(HIWORD(wParam) == EN_CHANGE){
if(IsDlgButtonChecked(hDlg, IDC_RADIO_ONE_PER_DIR) == BST_CHECKED){
GetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), szString, MAX_PATH_EX);
if(IsLegalFilename(szString))
StringCchCopy(szFilenameChecksumTemp, MAX_PATH_EX, szString);
else
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_FILENAME_CHECKSUM), szFilenameChecksumTemp);
}
return TRUE;