M2Team / NanaZip

The 7-Zip derivative intended for the modern Windows experience
https://sourceforge.net/projects/nanazip/
Other
8.89k stars 225 forks source link

Context menu windows 11 duplicated #328

Open modz2014 opened 1 year ago

modz2014 commented 1 year ago

hi i notice the context menu is duplicted under show more options and the windows 11 context menu so if im on windows 11 it should only show up when i right click but not under show more options

modz2014 commented 1 year ago

i have made temporary fix to it

MouriNaruto commented 1 year ago

It's not duplicated due to some third-party apps like Everything will show the classic context menu in their UI. But I think next version of NanaZip will try to add an option for achieve your idea.

Kenji Mouri

modz2014 commented 1 year ago

any update on it don't mind helping

modz2014 commented 1 year ago

I trust this contribution proves valuable to you.

bool IsWindows11OrLater()
    {
        OSVERSIONINFOEX osvi;
        ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
        osvi.dwBuildNumber = 22000; // Minimum build number for Windows 11
        DWORDLONG dwlConditionMask = 0;
        VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);

        return VerifyVersionInfo(&osvi, VER_BUILDNUMBER, dwlConditionMask);
    }

    IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
    {

        bool isWindows11OrLater = IsWindows11OrLater();

        if (isWindows11OrLater)
        {
            if (selection && okToBeSlow)
            {
                *cmdState = ECS_ENABLED;
                return S_OK;
            }
            *cmdState = ECS_HIDDEN; // Hides the classic context menu on Windows 11
        }
        else
        {
            // Handle other cases, if necessary.
            *cmdState = ECS_ENABLED; // Show the context menu item by default on other versions.
        }

        return S_OK;
    }
MouriNaruto commented 1 year ago

@modz2014

I will try to integrate that in recent days.

Kenji Mouri

modz2014 commented 1 year ago

did you want me to create a pull request I don't mind

MouriNaruto commented 1 year ago

did you want me to create a pull request I don't mind

I think I will make some modifications. So, I will make a git co-authored commit with you.

I hope you can provide me something like that:

Co-authored-by: NAME NAME@EXAMPLE.COM

Kenji Mouri

modz2014 commented 1 year ago

Co-authored-by: Modz2014 dawgz1992.jp@gmail.com is this what you want sorry I'm a bit confused

MouriNaruto commented 1 year ago

is this what you want sorry I'm a bit confused

It can help me to create a commit about those changes co-authored with you.

Kenji Mouri

modz2014 commented 1 year ago

Ok is that all you need

modz2014 commented 1 year ago

@MouriNaruto, I've also observed certain aspects of the user interface that require adjustments. As I await your guidance, I'd like to draw attention to the size of elements such as "Extract" and other options, which currently appear quite large. It would greatly enhance the visual harmony of the UI if we could resize these elements slightly, ensuring they maintain a reasonable size consistent with the file toolbar. This adjustment would not only improve aesthetics but also contribute to a cleaner overall appearance. Additionally, I'm contemplating the inclusion of an Inno Setup .ssi file, though its necessity is still under consideration. Your insights on this matter would be greatly appreciated.

modz2014 commented 1 year ago

@MouriNaruto is there going to be new updates to this soon

modz2014 commented 1 year ago

@MouriNaruto can i send you some archive formats to be added i tried to add them myself but the porject is all the place for me to understand i can email them to you

MouriNaruto commented 1 year ago

can i send you some archive formats to be added i tried to add them myself but the porject is all the place for me to understand i can email them to you

Of course, you can.

Kenji Mouri

modz2014 commented 1 year ago

ok what is your email address

MouriNaruto commented 1 year ago

ok what is your email address

KurikoMouri@outlook.jp

Kenji Mouri

modz2014 commented 1 year ago

@MouriNaruto i sent they now sorry i had to finish up

modz2014 commented 1 year ago

@MouriNaruto I'm trying to add Inno Setup scripts, but it seems a lot harder are you working on adding this as well as other installer

modz2014 commented 1 year ago

@MouriNaruto ill create a pull request with some changes in the next hour or something for you

MouriNaruto commented 1 year ago

I won't accept the suggestion and the PR of hiding NanaZip item in the legacy context menu because there is no proper way to implement.

Due to packaged shell extensions running out of process, we cannot check the process is File Explorer or third-party applications which need shell extensions. (For example, the common open and save dialog.)

Due to many people may like to select all files in the folder which the file count is large like the System32 folder, it's not suitable for using okToBeSlow to optimize.

Kenji Mouri

modz2014 commented 1 year ago

@MouriNaruto wait im confused do you mean about the context menu showing up the new windows 11 one stay hidden under show more options

MouriNaruto commented 1 year ago

do you mean about the context menu showing up the new windows 11 one stay hidden under show more options

Yes, the common open and save dialog only uses the legacy context menu.

Kenji Mouri

modz2014 commented 1 year ago

can you screenshot to me because it works fine for me

MouriNaruto commented 1 year ago

can you screenshot to me because it works fine for me

image

The simplest way to show what I said is using the Browse dialog when you use Windows Run dialog.

Kenji Mouri

MouriNaruto commented 1 year ago

image

Also, when you open File Explorer via Windows Tools in the Start menu, you will always use legacy context menu.

Kenji Mouri

modz2014 commented 1 year ago

ok i added in checks for this it should work now I will update it later

modz2014 commented 1 year ago
Untitled

also works for browse under run as well

modz2014 commented 1 year ago

@MouriNaruto hope this helps


IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
        {

            bool isWindows11OrLater = IsWindows11OrLater();

            if (isWindows11OrLater)
            {
                if (selection && okToBeSlow)
                {
                    *cmdState = ECS_ENABLED;
                    return S_OK;
                }
                *cmdState = ECS_HIDDEN;
            }
            if (IsActiveWindowDialog())
            {
                *cmdState = ECS_ENABLED;
            }
            else
            {
                *cmdState = ECS_HIDDEN; // Hides the classic context menu on Windows 11 for non-Save dialog scenarios
            }

            return S_OK;
        }

        bool IsDialog(const WCHAR* className)
        {
            return wcscmp(className, L"#32770") == 0;
        }`
MouriNaruto commented 1 year ago

Sorry, it's not helpful for out-of-process shell extensions.

Kenji Mouri

modz2014 commented 1 year ago

@MouriNaruto Please explain

MouriNaruto commented 1 year ago

@MouriNaruto Please explain

Due to the out-of-process shell extension is hosted by comhost.exe, you cannot get the proper Window which is using the shell extension properly.

Also, your new code snippet is not complete. The cases which need legacy context menu not only the common file open and save dialog. You need to adapt for lots of third-party applications. I don't think it's good for adding lots of check for that.

Oh, I forgot something about some users may need to use right click with shift key to show the legacy context menu in File Explorer. So, this proposal is not suitable to implement.

Kenji Mouri

MouriNaruto commented 1 year ago

Also, following Microsoft's current behavior of built-in shell extensions which support Windows 11's modern style context menu (show the item in both modern one and legacy one), this is another reason of your proposal is not suitable to implement.

Kenji Mouri

modz2014 commented 1 year ago

Ok I don't see many users doing that anyway in open and save diag log because anyway i have one more approach that could fix this isuess completely but would take some time with it i wont be able to for a couple of weeks

Also what do you recon how giving the user the option of open the folder after extarction did you take a look at that

I have half finished of creating iso is something you would be interested in?

On Mon, 2 Oct 2023, 1:56 am Kenji Mouri, @.***> wrote:

Also, following the Microsoft's current behavior, this is another reason of your proposal is not suitable to implement.

Kenji Mouri

— Reply to this email directly, view it on GitHub https://github.com/M2Team/NanaZip/issues/328#issuecomment-1742153142, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCKZY3IY7AOCZMTVGO5WD3X5GVEBANCNFSM6AAAAAA34PZC74 . You are receiving this because you were mentioned.Message ID: @.***>

modz2014 commented 1 year ago

@MouriNaruto i would have to rewrite the context menu and add 2 checks in source code

modz2014 commented 1 year ago

Hey @MouriNaruto, I've embarked on enhancing the shell extension by transitioning it into a COM Shell Extension. Currently, this transformation is pivotal in overcoming various limitations, such as the recurrent appearance of duplicated context menus in both the new and old interfaces upon right-clicking. Additionally, I've identified and addressed the constraints on subcommands, eliminating any predefined limits and enhancing overall flexibility.

Admittedly, I encountered some complexity in deciphering certain portions of the code shared earlier, but I'm committed to resolving that in the upcoming days. If this development aligns with your interests, I would greatly appreciate your input and support. Let me know, and I'll continue the comprehensive rewrite of the entire codebase.

MouriNaruto commented 1 year ago

@modz2014

I've embarked on enhancing the shell extension by transitioning it into a COM Shell Extension. Currently, this transformation is pivotal in overcoming various limitations,

The current implementation is already COM-based. Also, the modern context menu in Windows 11 doesn't support old shell extension interfaces.

this development aligns with your interests

At least, the "the recurrent appearance of duplicated context menus in both the new and old interfaces upon right-clicking" does not align my interests. The reasons I have already noted before. (keep the same behavior from Microsoft and other third-party implementations, demand from users which needs the legacy menu experience and third-party application interoperability support, reduce check logics in the implementation)

Kenji Mouri

MouriNaruto commented 1 year ago

Also, I don't think it's OK for me to merge your other implementations unless you split them to separate PRs. (I hope each PR has only one feature in the most cases.)

Kenji Mouri

modz2014 commented 1 year ago

so did you want me to create another pull request for an open extraction folder after extraction is completed?

MouriNaruto commented 1 year ago

so did you want me to create another pull request for an open extraction folder after extraction is completed?

Yes, this is what I hope. Also, I think the modification should be done in NanaZipWindows project or NanaZipG.exe because the GUI extraction implementation is in that module.

Kenji Mouri

MouriNaruto commented 1 year ago

About the context menu implementation, I think I will reduce the check logics and menu items for improving the performance.

Kenji Mouri

modz2014 commented 1 year ago

OK i will cancel the pull request and reupload them again and i was looking and Notepad++ duplicate of the context menu and they have resolved the issue so I might take a look at this

MouriNaruto commented 1 year ago

OK i will cancel the pull request and reupload them again and i was looking and Notepad++ duplicate of the context menu and they have resolved the issue so I might take a look at this

They use separate COM interfaces for context menus shown in the modern one and the classic one. I don't think it's a good solution because I want to reduce the complexity. I think I will continue to research for the suggestion you requested. And I think I will set co-author-by with you if I commit this feature.

Kenji Mouri

modz2014 commented 1 year ago

ok no worries i making a commit for Enable Destination Option after extraction under the settings tab will do a pull request soon for it

modz2014 commented 1 year ago

@MouriNaruto can you link to the extraction part please sorry just trying to work from my phone

MouriNaruto commented 1 year ago

@MouriNaruto can you link to the extraction part please sorry just trying to work from my phone

Maybe you can find something from https://github.com/M2Team/NanaZip/tree/main/SevenZip/CPP/7zip/UI/GUI.

Kenji Mouri

modz2014 commented 1 year ago

hey what has changed lately I'm back from my holiday today and just trying to figure out where I was @MouriNaruto

modz2014 commented 1 year ago

@MouriNaruto i cant see to find the context menu when you right click in NanaZip gui one a file

modz2014 commented 1 year ago

@MouriNaruto i havent not update NanaZip yet or anything

toshiya14 commented 6 months ago

I appreciate you have support the new context menu for Windows 11. But actually most of the people hate the new context menu such as me. I have patched my explorer to roll back classic context menu as default option. In this case, I could not use nanazip function anymore. As I right click in the explorer, the context menu popped up is classic context menu, and no nanazip options inside. I guess they might be added into the new context menu, but that menu already be skipped. So, may I ask you to add an option to switch use classic context menu or new context menu for Windows 11.

Thanks so much.

modz2014 commented 6 months ago

its still has the old option as well