Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Show All 22 Lines | |||||
| #include "GHOST_SystemWin32.h" | #include "GHOST_SystemWin32.h" | ||||
| #include "GHOST_EventDragnDrop.h" | #include "GHOST_EventDragnDrop.h" | ||||
| #ifndef _WIN32_IE | #ifndef _WIN32_IE | ||||
| # define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */ | # define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */ | ||||
| #endif | #endif | ||||
| #include <commctrl.h> | |||||
| #include <shlobj.h> | #include <shlobj.h> | ||||
| #include <tlhelp32.h> | #include <tlhelp32.h> | ||||
| #include <psapi.h> | #include <psapi.h> | ||||
| #include <shellapi.h> | #include <shellapi.h> | ||||
| #include <windowsx.h> | #include <windowsx.h> | ||||
| #include "utfconv.h" | #include "utfconv.h" | ||||
| #include "utf_winfunc.h" | |||||
| #include "GHOST_DisplayManagerWin32.h" | #include "GHOST_DisplayManagerWin32.h" | ||||
| #include "GHOST_EventButton.h" | #include "GHOST_EventButton.h" | ||||
| #include "GHOST_EventCursor.h" | #include "GHOST_EventCursor.h" | ||||
| #include "GHOST_EventKey.h" | #include "GHOST_EventKey.h" | ||||
| #include "GHOST_EventWheel.h" | #include "GHOST_EventWheel.h" | ||||
| #include "GHOST_TimerTask.h" | #include "GHOST_TimerTask.h" | ||||
| #include "GHOST_TimerManager.h" | #include "GHOST_TimerManager.h" | ||||
| ▲ Show 20 Lines • Show All 1,722 Lines • ▼ Show 20 Lines | void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const | ||||
| } | } | ||||
| else { | else { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| /** \name Message Box | /** \name Message Box | ||||
| * \{ */ | * \{ */ | ||||
| static const char *MESSAGE_BOX_HELP_LINK_PTR = NULL; | |||||
| VOID CALLBACK showMessageBoxCallBack(LPHELPINFO lpHelpInfo) | |||||
| { | |||||
| if (MESSAGE_BOX_HELP_LINK_PTR) { | |||||
| ShellExecute(NULL, "open", MESSAGE_BOX_HELP_LINK_PTR, NULL, NULL, SW_SHOWNORMAL); | |||||
| } | |||||
| } | |||||
| GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title, | GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title, | ||||
| const char *message, | const char *message, | ||||
| const char *help_label, | |||||
| const char *continue_label, | |||||
| const char *link, | const char *link, | ||||
| GHOST_DialogOptions dialog_options) const | GHOST_DialogOptions dialog_options) const | ||||
| { | { | ||||
| uint style = MB_OK | | const wchar_t *title_16 = alloc_utf16_from_8(title, 0); | ||||
| (dialog_options & GHOST_DialogError ? | const wchar_t *message_16 = alloc_utf16_from_8(message, 0); | ||||
| MB_ICONERROR : | const wchar_t *help_label_16 = alloc_utf16_from_8(help_label, 0); | ||||
| dialog_options & GHOST_DialogWarning ? MB_ICONWARNING : MB_ICONINFORMATION); | const wchar_t *continue_label_16 = alloc_utf16_from_8(continue_label, 0); | ||||
| bool show_help = link && strlen(link); | |||||
| if (show_help) { | int nButtonPressed = 0; | ||||
| GHOST_ASSERT(MESSAGE_BOX_HELP_LINK_PTR == NULL, | TASKDIALOGCONFIG config = {0}; | ||||
| "showMessageBox: MESSAGE_BOX_HELP_LINK_PTR is in use"); | const TASKDIALOG_BUTTON buttons[] = {{IDOK, help_label_16}, {IDCONTINUE, continue_label_16}}; | ||||
| style |= MB_HELP; | |||||
| MESSAGE_BOX_HELP_LINK_PTR = link; | config.cbSize = sizeof(config); | ||||
| } | config.hInstance = 0; | ||||
| config.dwCommonButtons = 0; | |||||
| MSGBOXPARAMSA message_box_params = {0}; | config.pszMainIcon = (dialog_options & GHOST_DialogError ? | ||||
| message_box_params.cbSize = sizeof(MSGBOXCALLBACK); | TD_ERROR_ICON : | ||||
| message_box_params.lpszText = message; | dialog_options & GHOST_DialogWarning ? TD_WARNING_ICON : | ||||
| message_box_params.lpszCaption = title; | TD_INFORMATION_ICON); | ||||
| message_box_params.dwStyle = style; | config.pszWindowTitle = L"Blender"; | ||||
| message_box_params.lpszText = message; | config.pszMainInstruction = title_16; | ||||
| message_box_params.lpfnMsgBoxCallback = showMessageBoxCallBack; | config.pszContent = message_16; | ||||
| config.pButtons = (link) ? buttons : buttons + 1; | |||||
| config.cButtons = (link) ? 2 : 1; | |||||
| TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL); | |||||
| switch (nButtonPressed) { | |||||
| case IDOK: | |||||
| ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL); | |||||
| break; | |||||
| case IDCONTINUE: | |||||
| break; | |||||
| default: | |||||
| break; // should never happen | |||||
| } | |||||
| free(title_16); | |||||
| free(message_16); | |||||
| free(help_label_16); | |||||
| free(continue_label_16); | |||||
| MessageBoxIndirectA(&message_box_params); | |||||
| MESSAGE_BOX_HELP_LINK_PTR = NULL; | |||||
| return GHOST_kSuccess; | return GHOST_kSuccess; | ||||
| } | } | ||||
| /* \} */ | /* \} */ | ||||
| static DWORD GetParentProcessID(void) | static DWORD GetParentProcessID(void) | ||||
| { | { | ||||
| HANDLE snapshot; | HANDLE snapshot; | ||||
| PROCESSENTRY32 pe32 = {0}; | PROCESSENTRY32 pe32 = {0}; | ||||
| ▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines | |||||