marlersoft / zigwin32

Zig bindings for Win32 generated by https://github.com/marlersoft/zigwin32gen
MIT License
229 stars 29 forks source link

Standard cursors ressources #19

Open eddineimad0 opened 1 year ago

eddineimad0 commented 1 year ago

I saw that definitions for IDC constants is skipped in the window_and_messaging.zig

   // skipped 'IDC_IBEAM'
  // skipped 'IDC_WAIT'
  // skipped 'IDC_CROSS'
  // skipped 'IDC_UPARROW'
  // skipped 'IDC_SIZE'
  // skipped 'IDC_ICON'
  // skipped 'IDC_SIZENWSE'
  // skipped 'IDC_SIZENESW'
  // skipped 'IDC_SIZEWE'
  // skipped 'IDC_SIZENS'
  // skipped 'IDC_SIZEALL'
  // skipped 'IDC_NO'
  // skipped 'IDC_HAND'
  // skipped 'IDC_APPSTARTING'
  // skipped 'IDC_HELP'
  // skipped 'IDC_PIN'
  // skipped 'IDC_PERSON'

i'm guessing that the cause of this is pointer alignment but anyway is there any alternative to these constants in the zigwin32 library?

Tired-Fox commented 2 months ago

For anyone looking at this in the future. You can add the following to your own files and it would be a local work around. The key for the fix here is the align(1) for the u16 strings.

const std = @import("std");
const win32 = @import("win32");
const typedConst = win32.zig.typedConst;
const HCURSOR = win32.ui.windows_and_messaging.HCursor;
const HINSTANCE = win32.foundation.HINSTANCE;

pub extern "user32" fn LoadCursorW(
    hInstance: ?HINSTANCE,
    lpCursorName: ?[*:0]align(1) const u16,
) callconv(std.os.windows.WINAPI) ?HCURSOR;

pub const IDC_HAND = typedConst([*:0]align(1) const u16, @as(u32, 32649))
// ... repeat for the rest of the missing constants
// reference the MS docs for their values: https://learn.microsoft.com/en-us/windows/win32/menurc/about-cursors