Add windows support#20
Conversation
Restore webview2_host.cpp from upstream stub and add full Win32 implementation with dialog and tray support: - Restore window management, message pump, clipboard (core host) - Add show_open_dialog via IFileDialog/GetResults (struct return) - Add show_save_dialog via IFileDialog/GetResult - Add show_message_dialog via MessageBoxW - Add tray support: create_tray, update_tray_menu, remove_tray, set_tray_callback - Add COM initialization (CoInitializeEx) for file dialog support - Use WM_TRAY_CALLBACK (WM_APP+1) to avoid WM_COMMAND conflicts - Add WM_NCDESTROY cleanup for GWLP_USERDATA - Update root.zig: WindowsOpenDialogResult struct, tray/dialog FFI - Wire tray callback in run() via zero_native_windows_set_tray_callback - Update 6 example app.zon files to add windows platform
…gfault - Add webview2_host_types.h with WindowsOpenDialogOpts, WindowsOpenDialogResult, WindowsSaveDialogOpts, WindowsMessageDialogOpts struct definitions matching Zig FFI layout (prevents ABI mismatch / segfault) - Fix show_open_dialog: GetResults() returns IShellItemArray**, not IShellItem** (calling EnumItems on wrong vtable was the segfault cause) - Add shobjidl.h include for IShellItemArray type
…lity Zig 0.17 rejects binary operator '*' with inconsistent whitespace. Fix three instances in upstream files to allow compilation.
|
@PrathamGhaywat is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
| // Set options | ||
| DWORD options = 0; |
There was a problem hiding this comment.
| // Set options | |
| DWORD options = 0; | |
| // Set options (preserve defaults like FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, etc.) | |
| DWORD options = 0; | |
| pfd->GetOptions(&options); |
IFileOpenDialog::SetOptions overwrites all default dialog options (FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, FOS_FORCEFILESYSTEM, etc.) because the code starts from options = 0 instead of reading existing defaults first.
| // Set title | ||
| if (opts->title && opts->title_len > 0) { | ||
| wchar_t *wtitle = new wchar_t[opts->title_len + 1]; | ||
| MultiByteToWideChar(CP_UTF8, 0, opts->title, (int)opts->title_len, wtitle, (int)opts->title_len + 1); |
| delete[] wicon; | ||
| } | ||
|
|
||
| if (tooltip && tooltip_len > 0) { |
| // Set options | ||
| DWORD options = 0; |
There was a problem hiding this comment.
| // Set options | |
| DWORD options = 0; | |
| // Set options (preserve defaults like FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, etc.) | |
| DWORD options = 0; | |
| pfd->GetOptions(&options); |
IFileOpenDialog::SetOptions overwrites all default dialog options (FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, FOS_FORCEFILESYSTEM, etc.) because the code starts from options = 0 instead of reading existing defaults first.
| // Set title | ||
| if (opts->title && opts->title_len > 0) { | ||
| wchar_t *wtitle = new wchar_t[opts->title_len + 1]; | ||
| MultiByteToWideChar(CP_UTF8, 0, opts->title, (int)opts->title_len, wtitle, (int)opts->title_len + 1); |
| delete[] wicon; | ||
| } | ||
|
|
||
| if (tooltip && tooltip_len > 0) { |
|
It was also quite easy to build it with CEF |
|
The CEF one looks even better then native webview. Did you already open a PR @k00lagin? |

Hey! I am happy to say that I successfully added windows as a platfom! So the setup is rather a bit time consuming, since you have to add the WebView SDK if you don't have it (see updated docs). I tested the whole thing with react, vue, next, svelte (had to patch up the svelte example to work by referring to #6)
Please let me know if any changes are required, @ctate. Here is a working app in vue:

This should actively close #7 (since it now works on windows!)
cc @ModerIRAQ