//---------------------------------------------------------------------------- bool KeyframeAnimation::OnChar (char cCharCode, long) { switch ( cCharCode ) { case 'k': case 'K': // toggle drawing of key frames m_bDrawKeys = !m_bDrawKeys; InvalidateRect(GetWindowHandle(),NULL,TRUE); break; case 'b': case 'B': // single step backwards through animation m_fTime -= m_fDt; if ( m_fTime < m_fTMin ) m_fTime = m_fTMax; InvalidateRect(GetWindowHandle(),NULL,TRUE); break; case 'f': case 'F': // single step forwards through animation m_fTime += m_fDt; if ( m_fTime > m_fTMax ) m_fTime = m_fTMin; InvalidateRect(GetWindowHandle(),NULL,TRUE); break; case 'q': case 'Q': case VK_ESCAPE: PostMessage(GetWindowHandle(),WM_DESTROY,0,0); return true; } return false; }
LRESULT CSkinnedLabel::OnPaint(HDC hdc) { TRY_CATCH PAINTSTRUCT m_ps; HDC hDC(hdc ? hdc : (::BeginPaint(GetWindowHandle(), &m_ps))); RECT rc={0}; GetWindowRect( &rc ); ScreenToClient( &rc ); SetBkMode(hDC, TRANSPARENT); HFONT hFontOld; if (m_hFont) hFontOld = (HFONT)SelectObject(hDC,m_hFont); SetTextColor(hDC,TRUE==IsWindowEnabled()?FontColor1:FontColor2); DrawText( hDC , Text.c_str() , Text.length() , &rc , TextAlign ); if (m_hFont) SelectObject(hDC,hFontOld); if (!hdc) ::EndPaint(GetWindowHandle(), &m_ps); CATCH_THROW() return FALSE; }
HRESULT CGraphics::Reset(void) { m_NeedReset = FALSE; // If the device can be restored, the application prepares the // device by destroying all video-memory resources and any // swap chains if(FAILED(Invalidate())) { TRACE(TEXT("Error: Failed to invalidate device.\n")); return E_FAIL; } // Try to reset the device HRESULT hr = m_Device->Reset(&m_PresentParameters); if(FAILED(hr)) { // Check if error other than device lost if(hr != D3DERR_DEVICELOST) { HWND hWnd = GetWindowHandle(); UINT width = GetWidth(); UINT height = GetHeight(); BOOL blur = GetBlur(); UninitializeRenderer(); UninitializeDisplay(); InitializeDisplay(hWnd,width,height,blur); InitializeRenderer(); TRACE(TEXT("Warning: Failed to reset the display device, reinitialized graphics.\n")); return S_FALSE; } // The device was lost again, so continue waiting until it can be reset TRACE(TEXT("Error: Failed to reset the display device.\n")); return S_FALSE; } // Finally, a lost device must re-create resources (including // video memory resources) after it has been reset if(FAILED(Restore())) { HWND hWnd = GetWindowHandle(); UINT width = GetWidth(); UINT height = GetHeight(); BOOL blur = GetBlur(); UninitializeRenderer(); UninitializeDisplay(); InitializeDisplay(hWnd,width,height,blur); InitializeRenderer(); TRACE(TEXT("Warning: Failed to restore device, reinitialized graphics.\n")); return false; } return S_OK; }
int Window::SetWindowIcon( char *smalliconname, char *bigiconname ) { if ( wd.wcx.hIcon == NULL ) { wd.wcx.hIcon = LoadIcon( NULL, bigiconname ); wd.wcx.hIconSm = LoadIcon( NULL, smalliconname ); } else { wd.wcx.hIcon = LoadIcon( GetInstanceHandle(), bigiconname ); wd.wcx.hIconSm = LoadIcon( GetInstanceHandle(), smalliconname ); SendMessage( GetWindowHandle(), WM_SETICON, ICON_BIG, (WPARAM)( wd.wcx.hIcon ) ); SendMessage( GetWindowHandle(), WM_SETICON, ICON_SMALL, (WPARAM)( wd.wcx.hIconSm ) ); } return 0; }
int Window::SetWindowIcon( int smalliconnum, int bigiconnum ) { if ( wd.wcx.hIcon == NULL ) { wd.wcx.hIcon = LoadIcon( NULL, MAKEINTRESOURCE( bigiconnum ) ); wd.wcx.hIconSm = LoadIcon( NULL, MAKEINTRESOURCE( smalliconnum ) ); } else { wd.wcx.hIcon = LoadIcon( GetInstanceHandle(), MAKEINTRESOURCE( bigiconnum ) ); wd.wcx.hIconSm = LoadIcon( GetInstanceHandle(), MAKEINTRESOURCE( smalliconnum ) ); SendMessage( GetWindowHandle(), WM_SETICON, ICON_BIG, (WPARAM)( wd.wcx.hIcon ) ); SendMessage( GetWindowHandle(), WM_SETICON, ICON_SMALL, (WPARAM)( wd.wcx.hIconSm ) ); } return 0; }
char * WIN_GetClipboardText(_THIS) { char *text; text = NULL; if (IsClipboardFormatAvailable(TEXT_FORMAT) && OpenClipboard(GetWindowHandle(_this))) { HANDLE hMem; LPTSTR tstr; hMem = GetClipboardData(TEXT_FORMAT); if (hMem) { tstr = (LPTSTR)GlobalLock(hMem); text = WIN_StringToUTF8(tstr); GlobalUnlock(hMem); } else { WIN_SetError("Couldn't get clipboard data"); } CloseClipboard(); } if (!text) { text = SDL_strdup(""); } return text; }
BOOL FormatDialog::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { // Add button case IDHELP: { std::wstring answer = ui::Menus.Show(GetWindowHandle(), 0, 0, L"ScriptAdd"); if (!answer.empty()) { std::wstring str; rich_edit_.GetText(str); CHARRANGE cr = {0}; rich_edit_.GetSel(&cr); str.replace(cr.cpMin, cr.cpMax - cr.cpMin, answer); rich_edit_.SetText(str.c_str()); int pos = cr.cpMin + answer.size(); rich_edit_.SetSel(pos, pos); rich_edit_.SetFocus(); } return TRUE; } } if (LOWORD(wParam) == IDC_RICHEDIT_FORMAT && HIWORD(wParam) == EN_CHANGE) { // Set preview text RefreshPreviewText(); // Highlight ColorizeText(); return TRUE; } return FALSE; }
/* * Arguments: [text (string)] * Returns: [boolean] */ static int plsql_SetClipboardText (lua_State *L) { size_t len; const char *s = lua_tolstring(L, 1, &len); HGLOBAL hmem; char *pmem; int res = 0; if (!OpenClipboard(GetWindowHandle())) return 0; if (EmptyClipboard() && s != NULL) { ++len; /* include '\0' */ hmem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len); if (!hmem) goto err; pmem = GlobalLock(hmem); memcpy(pmem, s, len); GlobalUnlock(hmem); res = SetClipboardData(CF_TEXT, hmem) != NULL; if (!res) GlobalFree(hmem); } err: CloseClipboard(); lua_pushboolean(L, res); return 1; }
void DrawBitmapButton (HWND hWnd, LPRECT r) { HDC hDC, hMemoryDC ; HBITMAP hBitmap, hTempBitmap ; int OldStretchMode ; BITMAP Bitmap ; WORD State; State = (WORD) GetWindowWord(hWnd, CBWNDEXTRA_STATE); hBitmap = (HBITMAP) GetWindowHandle(hWnd, GetBitmapIndex(State)); hDC = GetDC (hWnd) ; Dbg(hMemoryDC = CreateCompatibleDC (hDC)); Dbg(GetObject (hBitmap, sizeof(BITMAP), (LPSTR) &Bitmap)); // save the current bitmap handle. Dbg(hTempBitmap = (HBITMAP) SelectObject (hMemoryDC, hBitmap)); OldStretchMode = SetStretchBltMode (hDC, COLORONCOLOR); StretchBlt (hDC, r->left, r->top, r->right, r->bottom, hMemoryDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, SRCCOPY); SetStretchBltMode(hDC, OldStretchMode); // restore the old bitmap back into DC SelectObject(hMemoryDC, hTempBitmap); Dbg(DeleteDC(hMemoryDC)); Dbg(ReleaseDC(hWnd, hDC)); return; } /* DrawBitmapButton() */
void App::FrameMove() { if(GetInput()->KeyDown(DIK_ESCAPE)) {::PostQuitMessage(0);} if(GetInput()->ButtonDown(0)) { static C3DFLOAT32 fRotX = 0.0f, fRotY = 0.0f; C3DINT32 iDeltaX, iDeltaY; GetInput()->GetMovement(&iDeltaX, &iDeltaY); fRotX += -2.0f * (C3DFLOAT32)iDeltaX * GetInvFPS(); fRotY += 2.0f * (C3DFLOAT32)iDeltaY * GetInvFPS(); const C3DFLOAT32 fCamPosX = -2.0f * sinf(Core3D::DegToRad(fRotX)); const C3DFLOAT32 fCamPosY = -2.0f * sinf(Core3D::DegToRad(fRotY)); const C3DFLOAT32 fCamPosZ = -2.0f * cosf(Core3D::DegToRad(fRotX)); m_pkCamera->SetPosition(C3DVECTOR3(fCamPosX, fCamPosY, fCamPosZ)); m_pkCamera->SetLookAt(C3DVECTOR3(0.0f, 0.0f, 0.0f), C3DVECTOR3(0.0f, 1.0f, 0.0f)); m_pkCamera->CalculateView(); } if(0 == GetFrameIdent() % 5) { tchar szCaption[256] = _T(""); _stprintf_s(szCaption, _T("DisplacedSphere, FPS: %3.1f"), GetFPS()); ::SetWindowText(GetWindowHandle(), szCaption); } }
void PresetWindow::Create() { if (GetWindowHandle() != NULL) return; static const auto configureWindowClass = [&](WNDCLASSEX & wcex) { wcex.lpszClassName = L"DwmWindowMonitorPresets"; wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = CreateSolidBrush(RGB(240, 240, 240)); wcex.hIcon = WindowHelper::GetIcon(WindowHelper::GetCurrentModuleHandle(), IDW_MAIN); wcex.hIconSm = WindowHelper::GetIcon(WindowHelper::GetCurrentModuleHandle(), IDW_MAIN, false); }; static const auto configureWindowStruct = [&](CREATESTRUCT & cs) { RECT monitorRect; WindowHelper::GetMonitorRect(FindWindow(L"DwmWindowMonitorApp", NULL), monitorRect); cs.lpszClass = L"DwmWindowMonitorPresets"; cs.style = WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; cs.cx = 400; cs.cy = 220; cs.x = (monitorRect.right + monitorRect.left - cs.cx) / 2; cs.y = (monitorRect.bottom + monitorRect.top - cs.cy) / 2; }; Window::Create(configureWindowClass, configureWindowStruct); }
/*! @brief ウィンドウの名前の設定 @par 関数説明 ウィンドウの名前を設定する。反設定映はSetWindow()関数を使う。 @param name TCHAR型文字配列のウィンドウクラス名 @return 0=成功。 @return 1=与えた文字列へのポインタがNULL。 */ int Window::SetWindowName( char * name ) { int length; if ( name ) { length = strlen( name ); if ( length < WBUFLEN ) { strcpy_s( wd.WindowName, WBUFLEN, name ); if ( GetWindowHandle() ) { SetWindowText( GetWindowHandle(), wd.WindowName ); } return 0; } } return 1; }
//////////////////// // Remove the subclassing void UnSubclassWindow() { if (!Subclassed) return; SetWindowLong((HWND)GetWindowHandle(),GWL_WNDPROC, wpOriginal); Subclassed = false; }
int WIN_SetClipboardText(_THIS, const char *text) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; int result = 0; if (OpenClipboard(GetWindowHandle(_this))) { HANDLE hMem; LPTSTR tstr; SIZE_T i, size; /* Convert the text from UTF-8 to Windows Unicode */ tstr = WIN_UTF8ToString(text); if (!tstr) { return -1; } /* Find out the size of the data */ for (size = 0, i = 0; tstr[i]; ++i, ++size) { if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { /* We're going to insert a carriage return */ ++size; } } size = (size+1)*sizeof(*tstr); /* Save the data to the clipboard */ hMem = GlobalAlloc(GMEM_MOVEABLE, size); if (hMem) { LPTSTR dst = (LPTSTR)GlobalLock(hMem); if (dst) { /* Copy the text over, adding carriage returns as necessary */ for (i = 0; tstr[i]; ++i) { if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { *dst++ = '\r'; } *dst++ = tstr[i]; } *dst = 0; GlobalUnlock(hMem); } EmptyClipboard(); if (!SetClipboardData(TEXT_FORMAT, hMem)) { result = WIN_SetError("Couldn't set clipboard data"); } data->clipboard_count = GetClipboardSequenceNumber(); } SDL_free(tstr); CloseClipboard(); } else { result = WIN_SetError("Couldn't open clipboard"); } return result; }
// ウィンドウ設定の復帰。 int Window::RepairWindow() { wd = backup; return SetWindowPos( GetWindowHandle(), wd.winpos, GetPositionX(), GetPositionY(), GetWindowWidth(), GetWindowHeight(), wd.flags ); }
//////////////////// // Subclass the window (control the incoming Windows messages) void SubclassWindow() { if (Subclassed) return; #pragma warning(disable:4311) // Temporarily disable, the typecast is OK here wpOriginal = SetWindowLong((HWND)GetWindowHandle(),GWL_WNDPROC,(LONG)(&WindowProc)); #pragma warning(default:4311) // Enable the warning Subclassed = true; }
void NewUpdateDialog::OnPaint(HDC hdc, LPPAINTSTRUCT lpps) { win::Dc dc = hdc; // Paint application icon win::Rect rect; win::Window label = GetDlgItem(IDC_STATIC_APP_ICON); label.GetWindowRect(GetWindowHandle(), &rect); label.SetWindowHandle(nullptr); DrawIconResource(IDI_MAIN, dc.Get(), rect, true, false); }
/*! @brief ウィンドウの高さを取得 @par 関数説明 ウィンドウの高さを取得する。 @param int type 初期値=0。0で設定値を返し、1で現在値を調べて返す。 @return ウィンドウの高さ */ unsigned int Window::GetWindowHeight( int type ) { //type=0:設定値,1=現在値 RECT myrect;//RECT構造体 if ( type ) { GetClientRect( GetWindowHandle(), &myrect ); return myrect.bottom - myrect.top; } return wd.Height; }
void WindowBase::Create(HWND hParentWnd, int width, int height, const char* title) { const char* kWndClassName = "EditorWindow"; static bool s_bRegisteredClass = false; if (!s_bRegisteredClass) { RegisterWindowClass(kWndClassName, WindowBase::WinProc); s_bRegisteredClass = true; } CreateRootWidgetWindow(hParentWnd, kWndClassName, 0, 0, width, height); ::ShowWindow(GetWindowHandle(), 1); }
/*! @brief ウィンドウの横幅を取得 @par 関数説明 ウィンドウの横幅を取得する。 @param int type 初期値=0。0で設定値を返し、1で現在値を調べて返す。 @return ウィンドウの横幅。 */ unsigned int Window::GetWindowWidth( int type ) { //type=0:設定値,1=現在値 RECT myrect;//RECT構造体 if ( type ) { GetClientRect( GetWindowHandle(), &myrect ); return myrect.right - myrect.left; } return wd.Width; }
/*! @brief 現在のウィンドウのY座標を取得 @par 関数説明 ウィンドウのY座標を取得する。 @param int type 初期値=0。0で設定値を返し、1で現在値を調べて返す。 @return 上からの位置。 */ int Window::GetPositionY( int type ) { //type=0:設定値,1=現在値 RECT myrect;//RECT構造体 if ( type ) { GetClientRect( GetWindowHandle(), &myrect ); return myrect.top; } return wd.PositionY; }
void NEAR FreeBitmaps(HWND hwndToolbar, int CtrlId) { HWND hwndCtrl; WORD State; HBITMAP hBitmap; hwndCtrl = GetDlgItem(hwndToolbar, CtrlId); for (State = STATE_NORMAL; State <= STATE_GRAYED; State++) { hBitmap = (HBITMAP)GetWindowHandle(hwndCtrl, GetBitmapIndex(State)); Dbg(DeleteObject(hBitmap)); } } /* FreeBitmaps() */
bool DiD3D9WindowTarget::CheckSizeChanged() { RECT kRect; GetClientRect(GetWindowHandle(), &kRect); int wd = kRect.right - kRect.left; int he = kRect.bottom - kRect.top; if (wd != (int)mWidth || he != (int)mHeight) return true; return false; }
void PresetWindow::OnCreate() { // Set window options WindowHelper::SetTitle(GetWindowHandle(), WindowHelper::GetCurrentModuleHandle(), IDS_PRESETS); SetWindowPos(GetWindowHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // Create controls presetListbox = CreateWindowEx(WS_EX_CLIENTEDGE, L"Listbox", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT, 12, 12, 165, 121, GetWindowHandle(), reinterpret_cast<HMENU>(PresetCommand::ListboxSelect), WindowHelper::GetCurrentModuleHandle(), NULL); removeButton = CreateWindow(L"Button", L"Remove", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 12, 146, 75, 23, GetWindowHandle(), reinterpret_cast<HMENU>(PresetCommand::RemovePreset), WindowHelper::GetCurrentModuleHandle(), NULL); titleLabel = CreateWindow(L"Static", L"Name:", WS_CHILD | WS_VISIBLE | SS_LEFT, 192, 12, 30, 13, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); sizeLabel = CreateWindow(L"Static", L"Size:", WS_CHILD | WS_VISIBLE | SS_LEFT, 192, 60, 30, 13, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); posxText = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", L"", WS_CHILD | WS_VISIBLE | SS_LEFT | ES_READONLY, 202, 90, 50, 20, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); posyText = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", L"", WS_CHILD | WS_VISIBLE | SS_LEFT | ES_READONLY, 258, 78, 50, 20, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); heightText = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", L"", WS_CHILD | WS_VISIBLE | SS_LEFT | ES_READONLY, 258, 104, 50, 20, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); widthText = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", L"", WS_CHILD | WS_VISIBLE | SS_LEFT | ES_READONLY, 314, 90, 50, 20, GetWindowHandle(), NULL, WindowHelper::GetCurrentModuleHandle(), NULL); saveButton = CreateWindow(L"Button", L"Save", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 297, 146, 75, 23, GetWindowHandle(), reinterpret_cast<HMENU>(PresetCommand::SavePreset), WindowHelper::GetCurrentModuleHandle(), NULL); titleText.SetCoords(195, 28, 175, 20); titleText.Create(); // Set fonts defaultFont = WindowHelper::CreateFont(GetWindowHandle(), L"Microsoft Sans Serif", 8.25, FW_NORMAL, false, false, false); SendMessage(presetListbox, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(removeButton, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(titleLabel, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(titleText.GetWindowHandle(), WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(sizeLabel, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(posxText, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(posyText, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(widthText, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(heightText, WM_SETFONT, WPARAM(defaultFont), TRUE); SendMessage(saveButton, WM_SETFONT, WPARAM(defaultFont), TRUE); windowMonitor->RegisterObserver(this); UpdatePresetList(); UpdateListSelection(); UpdateDimensions(); }
SnippingWindow::SnippingWindow(HWND _parent) :WindowBase() { auto up = std::make_unique<Yupei::CreateParam>(L"YupeiWindow"); up->ParentWindow = _parent; SetCreateParam(std::move(up)); auto rect = Yupei::DeviceHelper::GetResolution(GetWindowHandle()); resolutionX = Yupei::GetRECTWidth<UINT>(rect); resolutionY = Yupei::GetRECTHeight<UINT>(rect); auto rt = GetRenderTarget(); rt->CreateLayer(&topLayer); rt->CreateLayer(&shownLayer); rt->CreateSolidColorBrush( D2D1::ColorF(D2D1::ColorF::White, 0.5f), &whiteBrush); }
void SearchDialog::ParseResults(const std::vector<int>& ids) { if (!IsWindow()) return; if (ids.empty()) { std::wstring msg = L"No results found for \"" + search_text + L"\"."; win::TaskDialog dlg(L"Search Anime", TD_INFORMATION_ICON); dlg.SetMainInstruction(msg.c_str()); dlg.AddButton(L"OK", IDOK); dlg.Show(GetWindowHandle()); return; } anime_ids_ = ids; RefreshList(); }
void ShowDialog(Dialog dialog) { InitializeDialogProperties(); auto it = dialog_properties.find(dialog); if (it != dialog_properties.end()) { if (it->second.dialog) { if (!it->second.dialog->IsWindow()) { it->second.dialog->Create(it->second.resource_id, GetWindowHandle(it->second.parent), it->second.modal); } else { ActivateWindow(it->second.dialog->GetWindowHandle()); } } } }
LRESULT MainDialog::StatusBar::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SETCURSOR: { POINT pt; GetCursorPos(&pt); ScreenToClient(GetWindowHandle(), &pt); win::Rect rect; GetRect(1, &rect); if (rect.PtIn(pt)) { SetSharedCursor(IDC_HAND); return TRUE; } break; } } return WindowProcDefault(hwnd, uMsg, wParam, lParam); }
/* * Returns: [string] */ static int plsql_GetClipboardText (lua_State *L) { HGLOBAL hmem; char *pmem; if (!OpenClipboard(GetWindowHandle())) return 0; hmem = GetClipboardData(CF_TEXT); if (!hmem) lua_pushnil(L); else { pmem = GlobalLock(hmem); lua_pushstring(L, pmem); GlobalUnlock(hmem); } CloseClipboard(); return 1; }
/* * Arguments: message (string), [title (string), * buttons (string), icon (string: "Warn", "Info", "Question", "Error")] * Returns: [string] */ static int plsql_MessageBox (lua_State *L) { static const int btn_flags[] = { MB_ABORTRETRYIGNORE, MB_OK, MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL }; static const char *const btn_names[] = { "AbortRetryIgnore", "Ok", "OkCancel", "RetryCancel", "YesNo", "YesNoCancel", NULL }; const char *msg = luaL_checkstring(L, 1); const char *title = lua_tostring(L, 2); const char *btn = lua_tostring(L, 3); const char *icon = lua_tostring(L, 4); const char *s; int flags = 0; if (btn) flags |= btn_flags[luaL_checkoption(L, 3, NULL, btn_names)]; if (icon) switch (*icon) { case 'W': flags |= MB_ICONWARNING; break; case 'I': flags |= MB_ICONINFORMATION; break; case 'Q': flags |= MB_ICONQUESTION; break; case 'E': flags |= MB_ICONERROR; break; } switch (MessageBox(GetWindowHandle(), msg, title, flags)) { case IDABORT: s = "Abort"; break; case IDCANCEL: s = "Cancel"; break; case IDIGNORE: s = "Ignore"; break; case IDNO: s = "No"; break; case IDOK: s = "Ok"; break; case IDRETRY: s = "Retry"; break; case IDYES: s = "Yes"; break; default: s = NULL; } lua_pushstring(L, s); return 1; }