funkey Posted April 28, 2012 Share Posted April 28, 2012 I don't know if there is some need, but I made a simple function to use only english button names in MsgBox. expandcollapse popup#include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $hHookMsgBox _MsgBoxEnglish(0, "Title", "Text") _MsgBoxEnglish(1, "Title", "Text") _MsgBoxEnglish(2, "Title", "Text") _MsgBoxEnglish(3, "Title", "Text") _MsgBoxEnglish(4, "Title", "Text") _MsgBoxEnglish(5, "Title", "Text") _MsgBoxEnglish(6, "Title", "Text") _MsgBoxEnglish(7, "Title", "Text") #region English Button text for MsgBox!! ;########################################################## Func _MsgBoxEnglish($flag, $title, $text, $timeout = 0, $hwnd = 0) Local $hProcMsgBox = DllCallbackRegister("CbtHookProcMsgBox", "int", "int;int;int") Local $TIDMsgBox = _WinAPI_GetCurrentThreadId() $hHookMsgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcMsgBox), 0, $TIDMsgBox) Local $iRet = MsgBox($flag, $title, $text, $timeout, $hwnd) _WinAPI_UnhookWindowsHookEx($hHookMsgBox) DllCallbackFree($hProcMsgBox) Return $iRet EndFunc ;==>_MsgBoxEnglish Func CbtHookProcMsgBox($nCode, $wParam, $lParam, $hHookMsgBox) Local $RET = 0, $hBitmap = 0, $xWnd = 0 Local $sButtonText If $nCode < 0 Then $RET = _WinAPI_CallNextHookEx($hHookMsgBox, $nCode, $wParam, $lParam) Return $RET EndIf Switch $nCode Case 5 ;5=HCBT_ACTIVATE _WinAPI_SetDlgItemText($wParam, 1, "OK") _WinAPI_SetDlgItemText($wParam, 2, "Cancel") _WinAPI_SetDlgItemText($wParam, 3, "&Abort") _WinAPI_SetDlgItemText($wParam, 4, "&Retry") _WinAPI_SetDlgItemText($wParam, 5, "&Ignore") _WinAPI_SetDlgItemText($wParam, 6, "&Yes") _WinAPI_SetDlgItemText($wParam, 7, "&No") _WinAPI_SetDlgItemText($wParam, 8, "Help") _WinAPI_SetDlgItemText($wParam, 10, "&Try Again") _WinAPI_SetDlgItemText($wParam, 11, "&Continue") EndSwitch Return EndFunc ;==>CbtHookProcMsgBox Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText ;########################################################## #endregion English Button text for MsgBox!! Musashi 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
KaFu Posted April 28, 2012 Share Posted April 28, 2012 (edited) Really nice, thanks for this example ! Edit: The same approach works fine to replace the button texts of an InputBox with a custom language. expandcollapse popup#include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $hHookInputBox InputBox("Test", "Eingabe") _InputBox("Test", "Eingabe") Func _InputBox($title, $prompt, $default = Default, $passwordchar = Default, $width = Default, $height = Default, $left = Default, $top = Default, $timeout = Default, $hwnd = Default) Local $hProcInputBox = DllCallbackRegister("CbtHookProcInputBox", "int", "int;int;int") Local $TIDInputBox = _WinAPI_GetCurrentThreadId() $hHookInputBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcInputBox), 0, $TIDInputBox) Local $iRet = InputBox($title, $prompt, $default, $passwordchar, $width, $height, $left, $top, $timeout, $hwnd) Local $ierror = @error _WinAPI_UnhookWindowsHookEx($hHookInputBox) DllCallbackFree($hProcInputBox) Return SetError($ierror, "", $iRet) EndFunc ;==>_InputBox Func CbtHookProcInputBox($nCode, $wParam, $lParam, $hHookInputBox) Local $RET = 0, $hBitmap = 0, $xWnd = 0 Local $sButtonText If $nCode < 0 Then $RET = _WinAPI_CallNextHookEx($hHookInputBox, $nCode, $wParam, $lParam) Return $RET EndIf Switch $nCode Case 5 ;5=HCBT_ACTIVATE _WinAPI_SetDlgItemText($wParam, 1, "OK") _WinAPI_SetDlgItemText($wParam, 2, "Abbrechen") EndSwitch Return EndFunc ;==>CbtHookProcInputBox Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText Edited April 28, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted April 28, 2012 Share Posted April 28, 2012 Nice stuff Thanks you both! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now