-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipbrd.c
756 lines (622 loc) · 19.8 KB
/
clipbrd.c
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
/*
* PROJECT: ReactOS Clipboard Viewer
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Provides a view of the contents of the ReactOS clipboard.
* COPYRIGHT: Copyright 2015-2018 Ricardo Hanke
* Copyright 2015-2018 Hermes Belusca-Maito
*/
#include "precomp.h"
static const WCHAR szClassName[] = L"ClipBookWClass";
CLIPBOARD_GLOBALS Globals;
SCROLLSTATE Scrollstate;
static void SaveClipboardToFile(void)
{
OPENFILENAMEW sfn;
LPWSTR c;
WCHAR szFileName[MAX_PATH];
WCHAR szFilterMask[MAX_STRING_LEN + 10];
ZeroMemory(&szFilterMask, sizeof(szFilterMask));
c = szFilterMask + LoadStringW(Globals.hInstance, STRING_FORMAT_NT, szFilterMask, MAX_STRING_LEN) + 1;
wcscpy(c, L"*.clp");
ZeroMemory(&szFileName, sizeof(szFileName));
ZeroMemory(&sfn, sizeof(sfn));
sfn.lStructSize = sizeof(sfn);
sfn.hwndOwner = Globals.hMainWnd;
sfn.hInstance = Globals.hInstance;
sfn.lpstrFilter = szFilterMask;
sfn.lpstrFile = szFileName;
sfn.nMaxFile = ARRAYSIZE(szFileName);
sfn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
sfn.lpstrDefExt = L"clp";
if (!GetSaveFileNameW(&sfn))
return;
if (!OpenClipboard(Globals.hMainWnd))
{
ShowLastWin32Error(Globals.hMainWnd);
return;
}
WriteClipboardFile(szFileName, CLIP_FMT_NT /* CLIP_FMT_31 */);
CloseClipboard();
}
static void LoadClipboardDataFromFile(LPWSTR lpszFileName)
{
if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance,
STRING_DELETE_MSG, STRING_DELETE_TITLE,
MB_ICONWARNING | MB_YESNO) != IDYES)
{
return;
}
if (!OpenClipboard(Globals.hMainWnd))
{
ShowLastWin32Error(Globals.hMainWnd);
return;
}
EmptyClipboard();
ReadClipboardFile(lpszFileName);
CloseClipboard();
}
static void LoadClipboardFromFile(void)
{
OPENFILENAMEW ofn;
LPWSTR c;
WCHAR szFileName[MAX_PATH];
WCHAR szFilterMask[MAX_STRING_LEN + 10];
ZeroMemory(&szFilterMask, sizeof(szFilterMask));
c = szFilterMask + LoadStringW(Globals.hInstance, STRING_FORMAT_GEN, szFilterMask, MAX_STRING_LEN) + 1;
wcscpy(c, L"*.clp");
ZeroMemory(&szFileName, sizeof(szFileName));
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = Globals.hMainWnd;
ofn.hInstance = Globals.hInstance;
ofn.lpstrFilter = szFilterMask;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = ARRAYSIZE(szFileName);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
if (!GetOpenFileNameW(&ofn))
return;
LoadClipboardDataFromFile(szFileName);
}
static void LoadClipboardFromDrop(HDROP hDrop)
{
WCHAR szFileName[MAX_PATH];
DragQueryFileW(hDrop, 0, szFileName, ARRAYSIZE(szFileName));
DragFinish(hDrop);
LoadClipboardDataFromFile(szFileName);
}
static void SetDisplayFormat(UINT uFormat)
{
RECT rc;
CheckMenuItem(Globals.hMenu, Globals.uCheckedItem, MF_BYCOMMAND | MF_UNCHECKED);
Globals.uCheckedItem = uFormat + CMD_AUTOMATIC;
CheckMenuItem(Globals.hMenu, Globals.uCheckedItem, MF_BYCOMMAND | MF_CHECKED);
if (uFormat == 0)
{
Globals.uDisplayFormat = GetAutomaticClipboardFormat();
}
else
{
Globals.uDisplayFormat = uFormat;
}
GetClipboardDataDimensions(Globals.uDisplayFormat, &rc);
Scrollstate.CurrentX = Scrollstate.CurrentY = 0;
Scrollstate.iWheelCarryoverX = Scrollstate.iWheelCarryoverY = 0;
UpdateWindowScrollState(Globals.hMainWnd, rc.right, rc.bottom, &Scrollstate);
InvalidateRect(Globals.hMainWnd, NULL, TRUE);
}
static void InitMenuPopup(HMENU hMenu, LPARAM index)
{
if ((GetMenuItemID(hMenu, 0) == CMD_DELETE) || (GetMenuItemID(hMenu, 1) == CMD_SAVE_AS))
{
if (CountClipboardFormats() == 0)
{
EnableMenuItem(hMenu, CMD_DELETE, MF_GRAYED);
EnableMenuItem(hMenu, CMD_SAVE_AS, MF_GRAYED);
}
else
{
EnableMenuItem(hMenu, CMD_DELETE, MF_ENABLED);
EnableMenuItem(hMenu, CMD_SAVE_AS, MF_ENABLED);
}
}
DrawMenuBar(Globals.hMainWnd);
}
static void UpdateDisplayMenu(void)
{
UINT uFormat;
HMENU hMenu;
WCHAR szFormatName[MAX_FMT_NAME_LEN + 1];
hMenu = GetSubMenu(Globals.hMenu, DISPLAY_MENU_POS);
while (GetMenuItemCount(hMenu) > 1)
{
DeleteMenu(hMenu, 1, MF_BYPOSITION);
}
if (CountClipboardFormats() == 0)
return;
if (!OpenClipboard(Globals.hMainWnd))
return;
AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
/* Display the supported clipboard formats first */
for (uFormat = EnumClipboardFormats(0); uFormat;
uFormat = EnumClipboardFormats(uFormat))
{
if (IsClipboardFormatSupported(uFormat))
{
RetrieveClipboardFormatName(Globals.hInstance, uFormat, TRUE,
szFormatName, ARRAYSIZE(szFormatName));
AppendMenuW(hMenu, MF_STRING, CMD_AUTOMATIC + uFormat, szFormatName);
}
}
/* Now display the unsupported clipboard formats */
for (uFormat = EnumClipboardFormats(0); uFormat;
uFormat = EnumClipboardFormats(uFormat))
{
if (!IsClipboardFormatSupported(uFormat))
{
RetrieveClipboardFormatName(Globals.hInstance, uFormat, TRUE,
szFormatName, ARRAYSIZE(szFormatName));
AppendMenuW(hMenu, MF_STRING | MF_GRAYED, 0, szFormatName);
}
}
CloseClipboard();
}
static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam))
{
case CMD_OPEN:
{
LoadClipboardFromFile();
break;
}
case CMD_SAVE_AS:
{
SaveClipboardToFile();
break;
}
case CMD_EXIT:
{
PostMessageW(Globals.hMainWnd, WM_CLOSE, 0, 0);
break;
}
case CMD_DELETE:
{
if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance,
STRING_DELETE_MSG, STRING_DELETE_TITLE,
MB_ICONWARNING | MB_YESNO) != IDYES)
{
break;
}
DeleteClipboardContent();
break;
}
case CMD_AUTOMATIC:
{
SetDisplayFormat(0);
break;
}
case CMD_HELP:
{
HtmlHelpW(Globals.hMainWnd, L"clipbrd.chm", 0, 0);
break;
}
case CMD_ABOUT:
{
WCHAR szTitle[MAX_STRING_LEN];
LoadStringW(Globals.hInstance, STRING_CLIPBOARD, szTitle, ARRAYSIZE(szTitle));
ShellAboutW(Globals.hMainWnd, szTitle, NULL,
LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(CLIPBRD_ICON)));
break;
}
default:
{
break;
}
}
return 0;
}
static void OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
COLORREF crOldBkColor, crOldTextColor;
RECT rc;
if (!OpenClipboard(Globals.hMainWnd))
return;
hdc = BeginPaint(hWnd, &ps);
/* Erase the background if needed */
if (ps.fErase)
FillRect(ps.hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
/* Set the correct background and text colors */
crOldBkColor = SetBkColor(ps.hdc, GetSysColor(COLOR_WINDOW));
crOldTextColor = SetTextColor(ps.hdc, GetSysColor(COLOR_WINDOWTEXT));
/* Realize the clipboard palette if there is one */
RealizeClipboardPalette(ps.hdc);
switch (Globals.uDisplayFormat)
{
case CF_NONE:
{
/* The clipboard is empty */
break;
}
case CF_DSPTEXT:
case CF_TEXT:
case CF_OEMTEXT:
case CF_UNICODETEXT:
{
DrawTextFromClipboard(Globals.uDisplayFormat, ps, Scrollstate);
break;
}
case CF_DSPBITMAP:
case CF_BITMAP:
{
BitBltFromClipboard(ps, Scrollstate, SRCCOPY);
break;
}
case CF_DIB:
case CF_DIBV5:
{
SetDIBitsToDeviceFromClipboard(Globals.uDisplayFormat, ps, Scrollstate, DIB_RGB_COLORS);
break;
}
case CF_DSPMETAFILEPICT:
case CF_METAFILEPICT:
{
GetClientRect(hWnd, &rc);
PlayMetaFileFromClipboard(hdc, &rc);
break;
}
case CF_DSPENHMETAFILE:
case CF_ENHMETAFILE:
{
GetClientRect(hWnd, &rc);
PlayEnhMetaFileFromClipboard(hdc, &rc);
break;
}
// case CF_PALETTE:
// TODO: Draw a palette with squares filled with colors.
// break;
case CF_OWNERDISPLAY:
{
HGLOBAL hglb;
PPAINTSTRUCT pps;
hglb = GlobalAlloc(GMEM_MOVEABLE, sizeof(ps));
if (hglb)
{
pps = GlobalLock(hglb);
CopyMemory(pps, &ps, sizeof(ps));
GlobalUnlock(hglb);
SendClipboardOwnerMessage(TRUE, WM_PAINTCLIPBOARD,
(WPARAM)hWnd, (LPARAM)hglb);
GlobalFree(hglb);
}
break;
}
case CF_HDROP:
{
GetClientRect(hWnd, &rc);
HDropFromClipboard(hdc, &rc);
break;
}
default:
{
GetClientRect(hWnd, &rc);
DrawTextFromResource(Globals.hInstance, ERROR_UNSUPPORTED_FORMAT,
hdc, &rc, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX);
break;
}
}
/* Restore the original colors */
SetTextColor(ps.hdc, crOldTextColor);
SetBkColor(ps.hdc, crOldBkColor);
EndPaint(hWnd, &ps);
CloseClipboard();
}
static LRESULT WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_CREATE:
{
TEXTMETRICW tm;
HDC hDC = GetDC(hWnd);
/*
* Note that the method with GetObjectW just returns
* the original parameters with which the font was created.
*/
if (GetTextMetricsW(hDC, &tm))
{
Globals.CharWidth = tm.tmMaxCharWidth; // tm.tmAveCharWidth;
Globals.CharHeight = tm.tmHeight + tm.tmExternalLeading;
}
ReleaseDC(hWnd, hDC);
Globals.hMenu = GetMenu(hWnd);
Globals.hWndNext = SetClipboardViewer(hWnd);
// For now, the Help dialog item is disabled because of lacking of HTML support
EnableMenuItem(Globals.hMenu, CMD_HELP, MF_BYCOMMAND | MF_GRAYED);
UpdateLinesToScroll(&Scrollstate);
UpdateDisplayMenu();
SetDisplayFormat(0);
DragAcceptFiles(hWnd, TRUE);
break;
}
case WM_CLOSE:
{
DestroyWindow(hWnd);
break;
}
case WM_DESTROY:
{
ChangeClipboardChain(hWnd, Globals.hWndNext);
if (Globals.uDisplayFormat == CF_OWNERDISPLAY)
{
HGLOBAL hglb;
PRECT prc;
hglb = GlobalAlloc(GMEM_MOVEABLE, sizeof(*prc));
if (hglb)
{
prc = GlobalLock(hglb);
SetRectEmpty(prc);
GlobalUnlock(hglb);
SendClipboardOwnerMessage(TRUE, WM_SIZECLIPBOARD,
(WPARAM)hWnd, (LPARAM)hglb);
GlobalFree(hglb);
}
}
PostQuitMessage(0);
break;
}
case WM_PAINT:
{
OnPaint(hWnd, wParam, lParam);
break;
}
case WM_KEYDOWN:
{
OnKeyScroll(hWnd, wParam, lParam, &Scrollstate);
break;
}
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{
OnMouseScroll(hWnd, uMsg, wParam, lParam, &Scrollstate);
break;
}
case WM_HSCROLL:
{
// NOTE: Windows uses an offset of 16 pixels
OnScroll(hWnd, SB_HORZ, wParam, 5, &Scrollstate);
break;
}
case WM_VSCROLL:
{
// NOTE: Windows uses an offset of 16 pixels
OnScroll(hWnd, SB_VERT, wParam, 5, &Scrollstate);
break;
}
case WM_SIZE:
{
RECT rc;
if (Globals.uDisplayFormat == CF_OWNERDISPLAY)
{
HGLOBAL hglb;
PRECT prc;
hglb = GlobalAlloc(GMEM_MOVEABLE, sizeof(*prc));
if (hglb)
{
prc = GlobalLock(hglb);
if (wParam == SIZE_MINIMIZED)
SetRectEmpty(prc);
else
GetClientRect(hWnd, prc);
GlobalUnlock(hglb);
SendClipboardOwnerMessage(TRUE, WM_SIZECLIPBOARD,
(WPARAM)hWnd, (LPARAM)hglb);
GlobalFree(hglb);
}
break;
}
GetClipboardDataDimensions(Globals.uDisplayFormat, &rc);
UpdateWindowScrollState(hWnd, rc.right, rc.bottom, &Scrollstate);
// NOTE: There still are little problems drawing
// the background when displaying clipboard text.
if (!IsClipboardFormatSupported(Globals.uDisplayFormat) ||
Globals.uDisplayFormat == CF_DSPTEXT ||
Globals.uDisplayFormat == CF_TEXT ||
Globals.uDisplayFormat == CF_OEMTEXT ||
Globals.uDisplayFormat == CF_UNICODETEXT)
{
InvalidateRect(Globals.hMainWnd, NULL, TRUE);
}
else
{
InvalidateRect(Globals.hMainWnd, NULL, FALSE);
}
break;
}
case WM_CHANGECBCHAIN:
{
/* Transmit through the clipboard viewer chain */
if ((HWND)wParam == Globals.hWndNext)
{
Globals.hWndNext = (HWND)lParam;
}
else if (Globals.hWndNext != NULL)
{
SendMessageW(Globals.hWndNext, uMsg, wParam, lParam);
}
break;
}
case WM_DESTROYCLIPBOARD:
break;
case WM_RENDERALLFORMATS:
{
/*
* When the user has cleared the clipboard via the DELETE command,
* we (clipboard viewer) become the clipboard owner. When we are
* subsequently closed, this message is then sent to us so that
* we get a chance to render everything we can. Since we don't have
* anything to render, just empty the clipboard.
*/
DeleteClipboardContent();
break;
}
case WM_RENDERFORMAT:
// TODO!
break;
case WM_DRAWCLIPBOARD:
{
UpdateDisplayMenu();
SetDisplayFormat(0);
/* Pass the message to the next window in clipboard viewer chain */
SendMessageW(Globals.hWndNext, uMsg, wParam, lParam);
break;
}
case WM_COMMAND:
{
if ((LOWORD(wParam) > CMD_AUTOMATIC))
{
SetDisplayFormat(LOWORD(wParam) - CMD_AUTOMATIC);
}
else
{
OnCommand(hWnd, uMsg, wParam, lParam);
}
break;
}
case WM_INITMENUPOPUP:
{
InitMenuPopup((HMENU)wParam, lParam);
break;
}
case WM_DROPFILES:
{
LoadClipboardFromDrop((HDROP)wParam);
break;
}
case WM_PALETTECHANGED:
{
/* Ignore if this comes from ourselves */
if ((HWND)wParam == hWnd)
break;
/* Fall back to WM_QUERYNEWPALETTE */
}
case WM_QUERYNEWPALETTE:
{
BOOL Success;
HDC hDC;
if (!OpenClipboard(Globals.hMainWnd))
return FALSE;
hDC = GetDC(hWnd);
if (!hDC)
{
CloseClipboard();
return FALSE;
}
Success = RealizeClipboardPalette(hDC);
ReleaseDC(hWnd, hDC);
CloseClipboard();
if (Success)
{
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
return TRUE;
}
return FALSE;
}
case WM_SYSCOLORCHANGE:
{
SetDisplayFormat(Globals.uDisplayFormat);
break;
}
case WM_SETTINGCHANGE:
{
if (wParam == SPI_SETWHEELSCROLLLINES)
{
UpdateLinesToScroll(&Scrollstate);
}
break;
}
default:
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}
return 0;
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HACCEL hAccel;
HWND hPrevWindow;
WNDCLASSEXW wndclass;
WCHAR szBuffer[MAX_STRING_LEN];
hPrevWindow = FindWindowW(szClassName, NULL);
if (hPrevWindow)
{
BringWindowToFront(hPrevWindow);
return 0;
}
switch (GetUserDefaultUILanguage())
{
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
SetProcessDefaultLayout(LAYOUT_RTL);
break;
default:
break;
}
ZeroMemory(&Globals, sizeof(Globals));
Globals.hInstance = hInstance;
ZeroMemory(&wndclass, sizeof(wndclass));
wndclass.cbSize = sizeof(wndclass);
wndclass.lpfnWndProc = MainWndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(CLIPBRD_ICON));
wndclass.hCursor = LoadCursorW(0, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = MAKEINTRESOURCEW(MAIN_MENU);
wndclass.lpszClassName = szClassName;
if (!RegisterClassExW(&wndclass))
{
ShowLastWin32Error(NULL);
return 0;
}
ZeroMemory(&Scrollstate, sizeof(Scrollstate));
LoadStringW(hInstance, STRING_CLIPBOARD, szBuffer, ARRAYSIZE(szBuffer));
Globals.hMainWnd = CreateWindowExW(WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES,
szClassName,
szBuffer,
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
Globals.hInstance,
NULL);
if (!Globals.hMainWnd)
{
ShowLastWin32Error(NULL);
return 0;
}
ShowWindow(Globals.hMainWnd, nCmdShow);
UpdateWindow(Globals.hMainWnd);
hAccel = LoadAcceleratorsW(Globals.hInstance, MAKEINTRESOURCEW(ID_ACCEL));
if (!hAccel)
{
ShowLastWin32Error(Globals.hMainWnd);
}
/* If the user provided a path to a clipboard data file, try to open it */
if (__argc >= 2)
LoadClipboardDataFromFile(__wargv[1]);
while (GetMessageW(&msg, 0, 0, 0))
{
if (!TranslateAcceleratorW(Globals.hMainWnd, hAccel, &msg))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
return (int)msg.wParam;
}