Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Win32 Macros #921

Closed
ryancerium opened this issue Jun 27, 2021 · 8 comments
Closed

Add Win32 Macros #921

ryancerium opened this issue Jun 27, 2021 · 8 comments
Labels
question Further information is requested

Comments

@ryancerium
Copy link
Contributor

ryancerium commented Jun 27, 2021

I'm porting my tiny window manager from winapi-rs and had to create inline functions for the bit manipulation macros. I'm sure I'm missing tons more, but I can't find a single point of reference in the API docs. Many of them seem to be defined in minwindef.h and winbasex.h

MAKEWORD
MAKELONG
LOWORD
HIWORD
LOBYTE
HIBYTE
GET_X_LPARAM
GET_Y_LPARAM
@kennykerr
Copy link
Collaborator

The win32 metadata, where most of the API definitions come from, doesn't include macros.

https://github.com/microsoft/win32metadata

@kennykerr kennykerr added the question Further information is requested label Jun 28, 2021
@ryancerium
Copy link
Contributor Author

Are you going to add non-metadata things or would that end up in a separate crate? I'd open a PR to add some of these things if you know where you want to put them.

@kennykerr
Copy link
Collaborator

I would think this could live in a separate crate as a set of inline helper functions.

@ryancerium
Copy link
Contributor Author

But should they live in another crate? Those macros are pretty integral to Win32 programming, distasteful as the byte-level manipulations are in Rust.

@kennykerr
Copy link
Collaborator

It's certainly debatable. You'll have to forgive me for being a little cautious as there are thousands of macros in the Windows SDK. 😉

Deciding which are "integral" is going to be an uphill battle.

@ryancerium
Copy link
Contributor Author

Yeah... At this stage of development I think getting the architecture-specific struct packing in is more important than MAKEWORD :-D

Separately, how are you evaluating best practices for Win32 programming in Rust? The fast-and-loose nature of DWORD/INT_PTR/WPARAM conversions is hard. My tiny program has a big chunk of as u32 and as usize in it already, but maybe that just gets abstracted away in a framework at some point.

@ryancerium
Copy link
Contributor Author

I forgot about all the SendMessage macros for UI elements... yeesh...

@kennykerr
Copy link
Collaborator

Yep... the WinRT APIs are mostly idiomatic and directly usable. The Win32 APIs are mostly going to stay faithful to the original definitions and will likely need various specialized hand-written crates wrapping the different APIs to provide a more idiomatic developer experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants