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
use crate::{bit_manipulation::Width32BitPortion, windows, wnds_and_msging::TimerProcExt};
use windows::Win32::{
    Foundation::{HWND, LPARAM, WPARAM},
    UI::WindowsAndMessaging::TIMERPROC,
};

pub fn translate_command_msg(wparam: WPARAM, lparam: LPARAM) -> CommandMsg {
    match wparam.high_u16() {
        0 => CommandMsg::MenuItem {
            id: wparam.low_u16(),
        },
        1 => CommandMsg::Accelerator {
            id: wparam.low_u16(),
        },
        wparam_high_u16 => CommandMsg::ControlMsg {
            msg_id: wparam_high_u16,
            control_id: wparam.low_u16(),
            control_hwnd: HWND(lparam.0),
        },
    }
}

pub enum CommandMsg {
    MenuItem {
        id: u16,
    },
    Accelerator {
        id: u16,
    },
    ControlMsg {
        msg_id: u16,
        control_id: u16,
        control_hwnd: HWND,
    },
}

pub unsafe fn translate_timer_msg(wparam: WPARAM, lparam: LPARAM) -> TimerMsg {
    TimerMsg {
        timer_id: wparam.0,
        callback: TIMERPROC::from_lparam(lparam),
    }
}

pub struct TimerMsg {
    pub timer_id: usize,
    pub callback: TIMERPROC,
}