Closed daurnimator closed 4 months ago
We both elaborated on this. Because currently to call MessageBox with multiple arguments I have to do this:
_ = win.MessageBoxA(null, "File open error.", "Error", @intToEnum(win.MESSAGEBOX_STYLE, @enumToInt(win.MB_OK) | @enumToInt(win.MB_ICONERROR)));
I've run into a similar issue with CreateWindow
's dwStyle
parameter:
const style = @intToEnum(WINDOW_STYLE, SS_SIMPLE | @enumToInt(WS_CHILD) | @enumToInt(WS_VISIBLE));
where SS_SIMPLE
is a flag that is only valid if the window has class STATIC
. It seems the lower 16 bits of WINDOW_STYLE
are reserved for control-specific styles, and the upper 16 bits are for common styles like whether or not a control has a border or is visible. Something akin to the proposed solution would help ergonomics a lot, though this particular case might be a bit tougher to solve because the lower bits form a union over multiple window classes.
Solved by switching to packed structs (see https://github.com/marlersoft/zigwin32/commit/6372ba07b2f5b510ab8021810eeab337b8735471).
MESSAGEBOX_STYLE
isn't really an enum, but a composite integer with some bitflags and some enums. I propose something like: