LiFan
2025-02-13 03ef0b51103c735077c784c7df81ae2bcc1599ab
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
#pragma once
 
#include "wobject/xcontrol.hpp"
#include "win32/win.hpp"
 
 
class xdatetimepick:  public xcontrol
{
public:
    xdatetimepick() :xcontrol(nullptr) {}
    xdatetimepick(void* implptr) :xcontrol(implptr) {}
 
    int SetDatetime(int wYear, int wMonth, int wDay)
    {
        SYSTEMTIME fdate;
        fdate.wYear = wYear;
        fdate.wMonth = wMonth;
        fdate.wDay = wDay;
        //fdate.wDayOfWeek=0;
        //fdate.wHour=0;
        //fdate.wMinute=0;
        //fdate.wSecond=0;
        //fdate.wMilliseconds=0;
 
        int GDT_VALID = 0x0;
        int DTM_FIRST = 0x1000;
        int DTM_SETSYSTEMTIME = DTM_FIRST + 2;
        int WM_KILLFOCUS = 0x0008;
        int WM_SETFOCUS = 0x0007;
        SendMessage(GetHWND(), DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM) & fdate);
        return 1;
    }
 
    int IsChecked()
    {
        int GDT_VALID = 0x0;
        int GDT_NONE = 0x1;
 
        int DTM_FIRST = 0x1000;
        int DTM_GETSYSTEMTIME = DTM_FIRST + 1;
 
        SYSTEMTIME fdate;
        int ret = SendMessage(GetHWND(), 0x1001, 0, (LPARAM)&fdate);
        if (ret == GDT_NONE) return 0;
        return 1;
    }
};