Skip to content

Conversation

@daverayment
Copy link
Collaborator

@daverayment daverayment commented Nov 6, 2025

Summary of the Pull Request

This PR replaces the legacy Win32 GetSaveFilename() usage with a modern COM-based IFileSaveDialog implementation and consolidates screenshot and screencast recording save behaviour behind a single, consistent path.

It updates several strings related to the save dialogs which were not compliant with Windows style guidelines.

It also introduces a safer mapping between the save dialog's filters and the underlying screenshot save options.

Edit 2025-11-07: Also fixes file overwrite bug

During testing another fix, I found a file overwrite bug in the old dialog code because of the manual application of the ".png" extension (see #43376). Setting the dialog's lpstrDefExt property correctly in this PR fixes that issue.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Code updates

Added SaveDialogResult

Encapsulates the selected file path and the (1-based) filter index returned by the dialog.

Added ShowSaveDialog()

  • Uses IFileSaveDialog via WIL
  • Handles, title, default filename, default extension and known folder lookups
  • Returns a std::optional of SaveDialogResult
  • Now correctly detects user cancellation instead of relying on the caller to catch it (cancel returned as nullopt)
  • Converts errors into winrt::hresult_error

Unified dialog filters

Added a single source of truth for screenshot save filter definitions with the new ScreenshotSaveOption enum, ScreenshotFilterSpec struct and g_ScreenshotFilters list.

Logic now derives the dialog settings and interprets the results from the same place, replacing the reliance on hard-coded filter indices.

Added GetScreenshotFilterSpecs()

Provides a cached std::vector<COMDLG_FILTERSPEC> for use by the screenshot save routine. Uses a lazy-initialised static for efficiency.

Updated save handlers

The IDC_SAVE/IDC_SAVE_CROP path in the main WndProc now uses ShowSaveDialog instead of the legacy Win32 OPENFILENAME-based method which was previously inline.

The filter index is now mapped safely to ScreenshotSaveOption, which allows for a more readable switch between ScreenshotSaveOption::Zoomed and ScreenshotSaveOption::ActualSize instead of a brittle comparison with 1.

This allows us to more easily add more options, reorder the entries, and/or to localise the strings.

Updated recording save workflow

Now uses the same ShowSaveDialgo helper, simplifying the flow.

Miscellaneous

SavePng has been updated to accept a std::filesystem::path& instead of a PTCHAR. This better indicates the intent of the routine and reflects the change to use the new consistent save path.

Some const pedantry to more clearly indicate intention, e.g. path and filter index returns from the show dialog routine.

Minor reorg in StartRecordingAsync so the full-screen initialisation work isn't done if a window is being captured.

Strings

Several dialog strings have been updated to align with Windows style guidelines and provide clearer, more descriptive wording:

Screenshot Save Dialog

Element Previous Updated
Title Save zoomed screen... Save Zoomed Screen
Filter 1 Zoomed PNG Zoomed image (*.png)
Filter 2 Actual size PNG Actual size image (*.png)

Recording Save Dialog

Element Previous Updated
Title Save As Save Recording
Filter MP4 Video ZoomIt recording (*.mp4)

Error Strings

Description Previous Updated
Init recording issue Recording cancelled before started Recording cancelled before it could start.
Recording error Error starting recording An error occurred during recording or saving.

Validation Steps Performed

(Manual testing on Windows 11. Standalone ZoomIt.)

  • Verified screenshot saving in both modes (Zoomed / Actual Size)
  • Verified recording saving and clipboard path save
  • Checked cancellation flow and overwrite prompts

@daverayment daverayment added the Product-ZoomIt Refers to the ZoomIt tool label Nov 6, 2025
@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors, Warnings, and Notices Count
ℹ️ candidate-pattern 1
❌ forbidden-pattern 1
⚠️ ignored-expect-variant 4

See ❌ Event descriptions for more information.

These words are not needed and should be removed cabstr CIBUILD djwsxzxb HIDEREADONLY icf installscopeperuser ksa Olllama rap registryroot regroot rtm suntimes TARGETDIR utm

Pattern suggestions ✂️ (1)

You could add these patterns to .github/actions/spell-check/patterns.txt:

# Automatically suggested patterns

# hit-count: 1 file-count: 1
# Amazon
\bamazon\.com/[-\w]+/(?:dp/[0-9A-Z]+|)

Alternatively, if a pattern suggestion doesn't make sense for this project, add a #
to the beginning of the line in the candidates file with the pattern to stop suggesting it.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@vanzue
Copy link
Contributor

vanzue commented Nov 13, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@lei9444
Copy link
Contributor

lei9444 commented Nov 13, 2025

Hi @daverayment Could you resolve the conflicts when you get a chance so we can include it in the 96 release.

@daverayment
Copy link
Collaborator Author

Hi @lei9444. Yes, I can have a look. It's quite a complex set of conflicts because there are at least 3 PRs on top of each other here, but I'll try my best to resolve everything.

I love ZoomIt being basically one massive file 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In for .96 Product-ZoomIt Refers to the ZoomIt tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ZoomIt] Save Screenshot can overwrite existing files without prompting

4 participants