LorenzCK / WindowsFormsAero

A Windows Forms library that provides common controls with many of the modern features introduced with Vista and more recent Windows versions.
Other
61 stars 14 forks source link

Change message WParam and LParam properties to IntPtr for x64 support #5

Closed pziezio closed 5 years ago

pziezio commented 5 years ago

Hello, First, I'd like to thank you for your library. I've been using it for some time with great success.

Recently I changed all of my WinForms applications to 64-bit versions. After that TaskDialogs stopped working. Showing of a simple dialog still works, but you can't change any of the properties of a dialog that is already shown. Application is failing with System.OverflowException.

I tracked the problem to windows message loop procedure and message class itself. Currently Message class has WParam and LParam properties defined as int (32bit) and that is causing problems.

Setting a new property value actually sends new windows message, so for example: There is a Message class constructor that takes string as a parameter. It uses Marshal runtime to get a pointer (IntPtr) to character data and it tries to assing that value to LParam - which is 32bit int. That results in an overflow exception.

It seems that the problem is easily solved by changing type of WParam and LParam properties to IntPtr - a type whose size is platform dependent, just like the underlying WPARAM and LPARAM types from WinAPI.

Please take a look at the following changes that I made: https://github.com/pziezio/WindowsFormsAero/commit/0a4cef194d40760f58e10427e1bb8b41c5b0d854#diff-3d7d9b2fdd0df5be3ed6890538248201

I could submit a pull request for this change, but I don't have any experience with creating configuration for multi-platform NuGet packages and I don't know how a new package configuration should look.

Best regards Piotr Zięzio

LorenzCK commented 5 years ago

Hello @pziezio, sorry for the late reply, thank you for the heads up and for the detailed explanation: the issue should now be fixed. I included the suggested changes in this commit (which preserves the authorship of your suggestions). I'll try to pack up the changes in a NuGet update as soon as possible.

Thanks again!