Using Windows Message Boxes In DLL Code (GUI_HWND)

The 2025.06.26 QSpice update included this entry:

06/26/2025 If you add "extern "C" __declspec(dllexport) void *GUI_HWND = 0;" to a .DLL C++ file, it will point the GUI hWnd.

GUI_HWND is a Windows handle to the QSpice schematic window if the simulation was launched from the GUI. If the simulation was launched from a command line (i.e., with QSpice64.exe or QSpice80.exe), this is a null value.

We can use GUI_HWND to display a Windows message box and get a user response from within a DLL. For an example, see the WinMsgBox schematic and code in the Miscellany section of my GitHub QSpice repository.

–robert

1 Like