-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCtrlWnd.hpp
839 lines (678 loc) · 20.4 KB
/
CtrlWnd.hpp
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
#pragma once
//---------------------------------------------------------------------------//
//
// CtrlWnd.hpp
// Wrappers for various controls
// Copyright (C) 2015-2018 tapetums
//
//---------------------------------------------------------------------------//
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#pragma comment(lib, "comctl32.lib") // InitCommonControls
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib") // StrToInt
#include "UWnd.hpp"
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
//---------------------------------------------------------------------------//
// Forward Declarations
//---------------------------------------------------------------------------//
namespace tapetums
{
class CtrlWnd;
class LabelWnd;
class BtnWnd;
class EditWnd;
class ComboBox;
class ListWnd;
class TreeWnd;
class TrackbarWnd;
class UpDownWnd;
class DateTimeWnd;
}
//---------------------------------------------------------------------------//
// Classes
//---------------------------------------------------------------------------//
class tapetums::CtrlWnd : public tapetums::UWnd
{
using super = UWnd;
public:
CtrlWnd() noexcept { static Init init; }
~CtrlWnd() = default;
CtrlWnd(const CtrlWnd&) = delete;
CtrlWnd& operator =(const CtrlWnd&) = delete;
CtrlWnd(CtrlWnd&&) noexcept = default;
CtrlWnd& operator =(CtrlWnd&&) noexcept = default;
private:
struct Init
{
Init() noexcept
{
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES | ICC_USEREX_CLASSES;
::InitCommonControlsEx(&icex);
}
};
public:
INT16 id() const
{
return (INT16)::GetWindowLongPtr(m_hwnd, GWLP_ID);
}
void id(INT16 id)
{
::SetWindowLongPtr(m_hwnd, GWLP_ID, LONG_PTR(id));
}
public:
HWND WINAPI Create
(
LPCTSTR class_name,
DWORD style,
DWORD styleEx,
HWND hwndParent,
INT16 id
)
{
if ( m_hwnd ) { return m_hwnd; }
style |= WS_CHILD | WS_VISIBLE;
const auto hwnd = ::CreateWindowEx
(
styleEx, class_name, nullptr, style,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwndParent, HMENU(id), ::GetModuleHandle(nullptr),
reinterpret_cast<LPVOID>(this)
);
if ( hwnd == nullptr )
{
return nullptr;
}
const auto ret = ::SetWindowSubclass
(
hwnd, SubclassWndProc, id, DWORD_PTR(this)
);
if ( ret == false )
{
return nullptr;
}
const auto cs = CREATESTRUCT
{
this, ::GetModuleHandle(nullptr),
HMENU(id), hwndParent,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
LONG(style), nullptr, class_name, 0
};
::SendMessage(hwnd, WM_CREATE, 0, LPARAM(&cs));
return hwnd;
}
public:
static LRESULT CALLBACK SubclassWndProc
(
HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
UINT_PTR, DWORD_PTR dwRefData
)
{
auto wnd = reinterpret_cast<CtrlWnd*>(dwRefData);
if ( wnd == nullptr )
{
return ::DefSubclassProc(hwnd, msg, wp, lp);
}
if ( msg == WM_CREATE )
{
wnd->m_hwnd = hwnd;
}
return wnd->WndProc(hwnd, msg, wp, lp);
}
public:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) override
{
return ::DefSubclassProc(hwnd, msg, wp, lp);
}
};
//---------------------------------------------------------------------------//
class tapetums::LabelWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
LabelWnd() = default;
~LabelWnd() = default;
LabelWnd(const LabelWnd&) = delete;
LabelWnd& operator =(const LabelWnd&) = delete;
LabelWnd(LabelWnd&&) noexcept = default;
LabelWnd& operator =(LabelWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(WC_STATIC, style, styleEx, hwndParent, id);
}
};
//---------------------------------------------------------------------------//
class tapetums::BtnWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
BtnWnd() noexcept = default;
~BtnWnd() = default;
BtnWnd(const BtnWnd&) = delete;
BtnWnd& operator =(const BtnWnd&) = delete;
BtnWnd(BtnWnd&&) noexcept = default;
BtnWnd& operator =(BtnWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(WC_BUTTON, style, styleEx, hwndParent, id);
}
bool WINAPI IsChecked()
{
return Send(BM_GETCHECK, 0, 0) ? true : false;
}
void WINAPI Check(UINT32 state = BST_CHECKED)
{
Send(BM_SETCHECK, WPARAM(state), 0);
}
void WINAPI Uncheck()
{
Send(BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
}
};
//---------------------------------------------------------------------------//
class tapetums::EditWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
EditWnd() noexcept = default;
~EditWnd() = default;
EditWnd(const EditWnd&) = delete;
EditWnd& operator =(const EditWnd&) = delete;
EditWnd(EditWnd&&) noexcept = default;
EditWnd& operator =(EditWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(WC_EDIT, style, styleEx, hwndParent, id);
}
};
//---------------------------------------------------------------------------//
class tapetums::ComboBox : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
ComboBox() = default;
~ComboBox() = default;
ComboBox(const ComboBox&) = delete;
ComboBox& operator =(const ComboBox&) = delete;
ComboBox(ComboBox&&) noexcept = default;
ComboBox& operator =(ComboBox&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(WC_COMBOBOX, style, styleEx, hwndParent, id);
}
void WINAPI AddString(LPCSTR text)
{
::SendMessageA(m_hwnd, CB_ADDSTRING, 0, LPARAM(text));
}
void WINAPI AddString(LPCWSTR text)
{
::SendMessageW(m_hwnd, CB_ADDSTRING, 0, LPARAM(text));
}
INT32 WINAPI SelectedIndex()
{
return (INT32)Send(CB_GETCURSEL, 0, 0);
}
void WINAPI Select(INT32 index)
{
Send(CB_SETCURSEL, index, 0);
}
INT32 WINAPI Count()
{
return (INT32)Send(CB_GETCOUNT, 0, 0);
}
void Clear()
{
while ( Send(CB_GETCOUNT, 0, 0 ) )
{
Send(CB_DELETESTRING, 0, 0);
}
}
};
//---------------------------------------------------------------------------//
class tapetums::ListWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
ListWnd() = default;
~ListWnd() = default;
ListWnd(const ListWnd&) = delete;
ListWnd& operator =(const ListWnd&) = delete;
ListWnd(ListWnd&&) noexcept = default;
ListWnd& operator =(ListWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
super::Create(WC_LISTVIEW, style, 0, hwndParent, id);
ListView_SetExtendedListViewStyle(m_hwnd, styleEx);
return m_hwnd;
}
INT32 WINAPI InsertColumn
(
LPCSTR text, INT32 width, INT32 index = 0, INT32 fmt = LVCFMT_LEFT
)
{
LVCOLUMNA col;
col.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
col.fmt = fmt;
col.cx = width;
col.iSubItem = index;
col.pszText = LPSTR(text);
return (INT32)::SendMessageA
(
m_hwnd, LVM_INSERTCOLUMNA, WPARAM(index) , LPARAM(&col)
);
}
INT32 WINAPI InsertColumn
(
LPCWSTR text, INT32 width, INT32 index = 0, INT32 fmt = LVCFMT_LEFT
)
{
LVCOLUMNW col;
col.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
col.fmt = fmt;
col.cx = width;
col.iSubItem = index;
col.pszText = LPWSTR(text);
return (INT32)::SendMessageW
(
m_hwnd, LVM_INSERTCOLUMNW, WPARAM(index) , LPARAM(&col)
);
}
INT32 WINAPI InsertItem(LPCSTR text, INT32 index)
{
return InsertItem(text, index, 0, 0) ? true : false;
}
INT32 WINAPI InsertItem(LPCWSTR text, INT32 index)
{
return InsertItem(text, index, 0, 0) ? true : false;
}
INT32 WINAPI InsertItem(LPCSTR text, INT32 index, LPARAM lp)
{
return InsertItem(text, index, 0, lp) ? true : false;
}
INT32 WINAPI InsertItem(LPCWSTR text, INT32 index, LPARAM lp)
{
return InsertItem(text, index, 0, lp) ? true : false;
}
INT32 WINAPI InsertItem(LPCSTR text, INT32 index, INT32 image, LPARAM lp)
{
LVITEMA item;
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
item.pszText = LPSTR(text);
item.iItem = index;
item.iSubItem = 0;
item.iImage = image;
item.lParam = lp;
return ::SendMessageA
(
m_hwnd, LVM_INSERTITEMA, WPARAM(0), LPARAM(&item)
)
? true : false;
}
INT32 WINAPI InsertItem(LPCWSTR text, INT32 index, INT32 image, LPARAM lp)
{
LVITEMW item;
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
item.pszText = LPWSTR(text);
item.iItem = index;
item.iSubItem = 0;
item.iImage = image;
item.lParam = lp;
return ::SendMessageW
(
m_hwnd, LVM_INSERTITEMW, WPARAM(0), LPARAM(&item)
)
? true : false;
}
INT32 WINAPI SetItem(LPCSTR text, INT32 index, INT32 sub_index)
{
LVITEMA item;
item.mask = LVIF_TEXT;
item.pszText = LPSTR(text);
item.iItem = index;
item.iSubItem = sub_index;
return ::SendMessageA
(
m_hwnd, LVM_SETITEMA, WPARAM(0), LPARAM(&item)
)
? true : false;
}
INT32 WINAPI SetItem(LPCWSTR text, INT32 index, INT32 sub_index)
{
LVITEMW item;
item.mask = LVIF_TEXT;
item.pszText = LPWSTR(text);
item.iItem = index;
item.iSubItem = sub_index;
return ::SendMessageW
(
m_hwnd, LVM_SETITEMW, WPARAM(0), LPARAM(&item)
)
? true : false;
}
void WINAPI DeleteItem(INT32 index)
{
ListView_DeleteItem(m_hwnd, index);
}
void WINAPI DeleteAllItems()
{
ListView_DeleteAllItems(m_hwnd);
}
void WINAPI SetImageList(HIMAGELIST list)
{
ListView_SetImageList(m_hwnd, list, LVSIL_NORMAL);
}
INT32 WINAPI Count()
{
return ListView_GetItemCount(m_hwnd);
}
void WINAPI Select(INT32 index)
{
ListView_SetItemState
(
m_hwnd, index,
LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED
);
}
void WINAPI ClearSelect()
{
INT32 index = -1;
while ( true )
{
index = ListView_GetNextItem
(
m_hwnd, index, LVNI_ALL | LVNI_SELECTED
);
if ( index == -1 ) { break; }
ListView_SetItemState
(
m_hwnd, index, 0, LVIS_SELECTED
);
}
}
INT32 WINAPI SelectedIndex()
{
return ListView_GetNextItem(m_hwnd, -1, LVNI_ALL | LVNI_SELECTED);
}
void WINAPI GetItemText(INT32 index, INT32 sub_index, LPSTR pszText, INT32 cchTextMax)
{
LVITEMA item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = sub_index;
item.pszText = pszText;
item.cchTextMax = cchTextMax;
::SendMessageA(m_hwnd, LVM_GETITEMA, WPARAM(0), LPARAM(&item));
}
void WINAPI GetItemText(INT32 index, INT32 sub_index, LPWSTR pszText, INT32 cchTextMax)
{
LVITEMW item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = sub_index;
item.pszText = pszText;
item.cchTextMax = cchTextMax;
::SendMessageW(m_hwnd, LVM_GETITEMW, WPARAM(0), LPARAM(&item));
}
INT32 WINAPI GetItemToInt(INT32 index, INT32 sub_index)
{
constexpr size_t cchTextMax { 16 };
TCHAR buf[cchTextMax];
LVITEM item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = sub_index;
item.pszText = buf;
item.cchTextMax = cchTextMax;
ListView_GetItem(m_hwnd, &item);
buf[cchTextMax - 1] = TCHAR('\0');
return ::StrToInt(buf);
}
UINT WINAPI GetItemSatte(INT32 index, INT32 sub_index)
{
LVITEM item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = sub_index;
ListView_GetItem(m_hwnd, &item);
return item.state;
}
LPARAM WINAPI GetItemLPARAM(INT32 index)
{
LVITEM item;
item.mask = LVIF_PARAM;
item.iItem = index;
item.iSubItem = 0;
ListView_GetItem(m_hwnd, &item);
return item.lParam;
}
bool WINAPI IsChecked(INT32 index)
{
return ListView_GetCheckState(m_hwnd, index) ? true : false;
}
void WINAPI Check(INT32 index)
{
ListView_SetCheckState(m_hwnd, index, true);
}
void WINAPI Uncheck(INT32 index)
{
ListView_SetCheckState(m_hwnd, index, false);
}
};
//---------------------------------------------------------------------------//
class tapetums::TreeWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
TreeWnd() = default;
~TreeWnd() = default;
TreeWnd(const TreeWnd&) = delete;
TreeWnd& operator =(const TreeWnd&) = delete;
TreeWnd(TreeWnd&&) noexcept = default;
TreeWnd& operator =(TreeWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(WC_TREEVIEW, style, styleEx, hwndParent, id);
}
HTREEITEM WINAPI InsertItem(LPCSTR text, HTREEITEM parent = TVI_ROOT)
{
TVINSERTSTRUCTA tvis;
tvis.hParent = parent;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT;
tvis.item.pszText = LPSTR(text);
return (HTREEITEM)::SendMessageA
(
m_hwnd, TVM_INSERTITEMA, WPARAM(0), LPARAM(&tvis)
);
}
HTREEITEM WINAPI InsertItem(LPCWSTR text, HTREEITEM parent = TVI_ROOT)
{
TVINSERTSTRUCTW tvis;
tvis.hParent = parent;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT;
tvis.item.pszText = LPWSTR(text);
return (HTREEITEM)::SendMessageW
(
m_hwnd, TVM_INSERTITEMW, WPARAM(0), LPARAM(&tvis)
);
}
void WINAPI SetImageList(HIMAGELIST list)
{
TreeView_SetImageList(m_hwnd, list, TVSIL_NORMAL);
}
void WINAPI Select(HTREEITEM hitem)
{
TreeView_Select(m_hwnd, hitem, TVGN_CARET);
}
HTREEITEM WINAPI GetSelection()
{
return TreeView_GetSelection(m_hwnd);
}
public:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) override
{
if ( msg == WM_HSCROLL || msg == WM_VSCROLL )
{
return ::SendMessage(GetParent(), msg, wp, lp);
}
else
{
return super::WndProc(hwnd, msg, wp, lp);
}
}
};
//---------------------------------------------------------------------------//
class tapetums::TrackbarWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
struct RANGE { UINT min; UINT max; };
public:
TrackbarWnd() = default;
~TrackbarWnd() = default;
TrackbarWnd(const TrackbarWnd&) = delete;
TrackbarWnd& operator =(const TrackbarWnd&) = delete;
TrackbarWnd(TrackbarWnd&&) noexcept = default;
TrackbarWnd& operator =(TrackbarWnd&&) noexcept = default;
public:
UINT WINAPI position() const noexcept
{
return (UINT)::SendMessage(m_hwnd, TBM_GETPOS, 0, 0);
}
void WINAPI position(UINT pos) noexcept
{
Post(TBM_SETPOS, TRUE, LPARAM(pos));
}
UINT WINAPI page_size() const noexcept
{
return (UINT)::SendMessage(m_hwnd, TBM_GETPAGESIZE, 0, 0);
}
void WINAPI page_size(UINT size) noexcept
{
Post(TBM_SETPAGESIZE, 0, LPARAM(size));
}
RANGE WINAPI range() const noexcept
{
const auto min = (UINT)::SendMessage(m_hwnd, TBM_GETRANGEMIN, 0, 0);
const auto max = (UINT)::SendMessage(m_hwnd, TBM_GETRANGEMAX, 0, 0);
return RANGE{ min, max };
}
void WINAPI range(UINT min, UINT max) noexcept
{
::PostMessage(m_hwnd, TBM_SETTICFREQ, 1, 0);
::PostMessage(m_hwnd, TBM_SETRANGE, TRUE, MAKELPARAM(min, max));
}
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(TRACKBAR_CLASS, style, styleEx, hwndParent, id);
}
public:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) override
{
if ( msg == WM_HSCROLL || msg == WM_VSCROLL )
{
return ::SendMessage(GetParent(), msg, wp, lp);
}
else
{
return super::WndProc(hwnd, msg, wp, lp);
}
}
};
//---------------------------------------------------------------------------//
class tapetums::UpDownWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
struct RANGE { UINT min; UINT max; };
public:
UpDownWnd() = default;
~UpDownWnd() = default;
UpDownWnd(const UpDownWnd&) = delete;
UpDownWnd& operator =(const UpDownWnd&) = delete;
UpDownWnd(UpDownWnd&&) noexcept = default;
UpDownWnd& operator =(UpDownWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(UPDOWN_CLASS, style, styleEx, hwndParent, id);
}
HWND buddy()
{
return (HWND)::SendMessage(m_hwnd, UDM_GETBUDDY, WPARAM(0), LPARAM(0));
}
HWND buddy(HWND hBuddy)
{
return (HWND)::SendMessage(m_hwnd, UDM_SETBUDDY, WPARAM(hBuddy), LPARAM(0));
}
INT32 position()
{
return (INT32)::SendMessage(m_hwnd, UDM_GETPOS32, WPARAM(0), LPARAM(0));
}
INT32 position(INT32 value)
{
return (INT32)::SendMessage(m_hwnd, UDM_SETPOS32, WPARAM(0), LPARAM(value));
}
RANGE range()
{
RANGE range;
::SendMessage(m_hwnd, UDM_GETRANGE32, WPARAM(&range.min), LPARAM(&range.max));
return range;
}
void range(INT32 min, INT32 max)
{
::SendMessage(m_hwnd, UDM_SETRANGE32, WPARAM(min), LPARAM(max));
}
};
//---------------------------------------------------------------------------//
class tapetums::DateTimeWnd : public tapetums::CtrlWnd
{
using super = CtrlWnd;
public:
DateTimeWnd() = default;
~DateTimeWnd() = default;
DateTimeWnd(const DateTimeWnd&) = delete;
DateTimeWnd& operator =(const DateTimeWnd&) = delete;
DateTimeWnd(DateTimeWnd&&) noexcept = default;
DateTimeWnd& operator =(DateTimeWnd&&) noexcept = default;
public:
HWND WINAPI Create(DWORD style, DWORD styleEx, HWND hwndParent, INT16 id)
{
return super::Create(DATETIMEPICK_CLASS, style, styleEx, hwndParent, id);
}
public:
void WINAPI GetDateTime(SYSTEMTIME* p_st)
{
::SendMessage(m_hwnd, DTM_GETSYSTEMTIME, 0, LPARAM(p_st));
}
void WINAPI SetDateTime(const SYSTEMTIME& st)
{
::SendMessage(m_hwnd, DTM_SETSYSTEMTIME, 0, LPARAM(&st));
}
void WINAPI SetFormat(LPCSTR format)
{
::SendMessageA(m_hwnd, DTM_SETFORMATA, 0, LPARAM(format));
}
void WINAPI SetFormat(LPCWSTR format)
{
::SendMessageW(m_hwnd, DTM_SETFORMATW, 0, LPARAM(format));
}
};
//---------------------------------------------------------------------------//
// CtrlWnd.hpp