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

Code Quality: Replace Vanara with CsWin32 #16536

Merged
merged 7 commits into from
Nov 26, 2024
Merged

Conversation

Jack251970
Copy link
Contributor

@Jack251970 Jack251970 commented Nov 26, 2024

Removed Vanara.PInvoke.Shell32.CMF & Vanara.PInvokeVanara.PInvoke.RECT import.
Replaced Vanara.PInvoke.Shell32.IApplicationActivationManage with Windows.Win32.UI.Shell.IApplicationActivationManager.
Removed useless Vanara import.

For #15000

@0x5bfa
Copy link
Member

0x5bfa commented Nov 26, 2024

This looks great, thank you!

While you're at context menu thing, could you replace these manually defined types with cswin32 too?

// Same definition of Vanara.PInvoke.User32.MenuItemType
public enum MenuItemType : uint
{
MFT_STRING = 0,
MFT_BITMAP = 4,
MFT_MENUBARBREAK = 32,
MFT_MENUBREAK = 64,
MFT_OWNERDRAW = 256,
MFT_RADIOCHECK = 512,
MFT_SEPARATOR = 2048,
MFT_RIGHTORDER = 8192,
MFT_RIGHTJUSTIFY = 16384
}
public enum HBITMAP_HMENU : long
{
HBMMENU_CALLBACK = -1,
HBMMENU_MBAR_CLOSE = 5,
HBMMENU_MBAR_CLOSE_D = 6,
HBMMENU_MBAR_MINIMIZE = 3,
HBMMENU_MBAR_MINIMIZE_D = 7,
HBMMENU_MBAR_RESTORE = 2,
HBMMENU_POPUP_CLOSE = 8,
HBMMENU_POPUP_MAXIMIZE = 10,
HBMMENU_POPUP_MINIMIZE = 11,
HBMMENU_POPUP_RESTORE = 9,
HBMMENU_SYSTEM = 1
}

@Jack251970
Copy link
Contributor Author

This looks great, thank you!

While you're at context menu thing, could you replace these manually defined types with cswin32 too?

// Same definition of Vanara.PInvoke.User32.MenuItemType
public enum MenuItemType : uint
{
MFT_STRING = 0,
MFT_BITMAP = 4,
MFT_MENUBARBREAK = 32,
MFT_MENUBREAK = 64,
MFT_OWNERDRAW = 256,
MFT_RADIOCHECK = 512,
MFT_SEPARATOR = 2048,
MFT_RIGHTORDER = 8192,
MFT_RIGHTJUSTIFY = 16384
}
public enum HBITMAP_HMENU : long
{
HBMMENU_CALLBACK = -1,
HBMMENU_MBAR_CLOSE = 5,
HBMMENU_MBAR_CLOSE_D = 6,
HBMMENU_MBAR_MINIMIZE = 3,
HBMMENU_MBAR_MINIMIZE_D = 7,
HBMMENU_MBAR_RESTORE = 2,
HBMMENU_POPUP_CLOSE = 8,
HBMMENU_POPUP_MAXIMIZE = 10,
HBMMENU_POPUP_MINIMIZE = 11,
HBMMENU_POPUP_RESTORE = 9,
HBMMENU_SYSTEM = 1
}

I will check it later.

@Jack251970
Copy link
Contributor Author

@0x5bfa As for MFT_SEPARATOR flag, just write MFT_SEPARATOR in NativeMethods.txt cannot help.

As for HBITMAP_HMENU, it is only used for checking in !Enum.IsDefined(typeof(HBITMAP_HMENU), ((IntPtr)menuItemInfo.hbmpItem).ToInt64()).

@0x5bfa
Copy link
Member

0x5bfa commented Nov 26, 2024

Add MENU_ITEM_TYPE instead.

As for HBITMAP_HMENU, it is only used for checking in !Enum.IsDefined(typeof(HBITMAP_HMENU), ((IntPtr)menuItemInfo.hbmpItem).ToInt64()).

Maybe we should leave it as is.
Or you could add "HBMMENU_*" and make it work like before.

….Win32.UI.WindowsAndMessaging.MENU_ITEM_TYPE
@Jack251970
Copy link
Contributor Author

@0x5bfa Have found MENU_ITEM_TYPE and just keep HBITMAP_HMENU.

Copy link
Member

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much!

@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed needs - code review labels Nov 26, 2024
@yaira2 yaira2 merged commit 20ef76a into files-community:main Nov 26, 2024
6 checks passed
@yaira2
Copy link
Member

yaira2 commented Nov 26, 2024

@Jack251970 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants