Lokdal Posted February 8, 2011 Share Posted February 8, 2011 hello, I was wondering if there was a way to code a simple msgbox with "ok" button where the button *is not* selected by default. the purpose of this is you can't accidentally hit "ok" with the enter key when the box pops up... I've found 3 options so far : 0 First button is default button 0x0 256 Second button is default button 0x100 512 Third button is default button 0x200 but does the possibility for "no default button" exist ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2011 Moderators Share Posted February 8, 2011 Lokdal,Welcome to the AutoIt forum. I am not sure that there is a simple way to do this with the standard API MsgBox. But if you look at the ExtMsgBox UDF in my sig, you can do this (and a lot more) easily with virtually the same syntax as the standard MsgBox. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
reb Posted February 9, 2011 Share Posted February 9, 2011 hello, I was wondering if there was a way to code a simple msgbox with "ok" button where the button *is not* selected by default. the purpose of this is you can't accidentally hit "ok" with the enter key when the box pops up... I've found 3 options so far : 0 First button is default button 0x0 256 Second button is default button 0x100 512 Third button is default button 0x200 but does the possibility for "no default button" exist ? Here is a GUI without Buttons. Just enter your data and press enter. The enter key will not work until some data is present. Maybe you can use this. Regards REBblank.au3 MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
funkey Posted February 11, 2011 Share Posted February 11, 2011 This is my solution for this problem expandcollapse popup#include <WinAPI.au3> Global $hHookMsgBox Local $Ret = _MsgBoxNoDefault(3, "Test", "Is this OK?") ConsoleWrite($Ret & @CRLF) Func _MsgBoxNoDefault($flag, $title, $text) Local $hProcMsgBox = DllCallbackRegister("_CbtHookProcMsgBox", "int", "int;int;int") Local $TIDMsgBox = _WinAPI_GetCurrentThreadId() $hHookMsgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcMsgBox), 0, $TIDMsgBox) HotKeySet("{Enter}", "_MsgBoxNoDefault_BlockEnter") HotKeySet("{Tab}", "_MsgBoxNoDefault_BlockEnter") HotKeySet("{LEFT}", "_MsgBoxNoDefault_BlockEnter") HotKeySet("{RIGHT}", "_MsgBoxNoDefault_BlockEnter") HotKeySet("{UP}", "_MsgBoxNoDefault_BlockEnter") HotKeySet("{DOWN}", "_MsgBoxNoDefault_BlockEnter") Local $iRet = MsgBox($flag, $title, $text) _WinAPI_UnhookWindowsHookEx($hHookMsgBox) DllCallbackFree($hProcMsgBox) HotKeySet("{Enter}") HotKeySet("{TAB}") HotKeySet("{LEFT}") HotKeySet("{RIGHT}") HotKeySet("{UP}") HotKeySet("{DOWN}") Return $iRet EndFunc ;==>_MsgBoxNoDefault Func _CbtHookProcMsgBox($nCode, $wParam, $lParam) Local $Ret = 0, $Style, $hCtrl If $nCode < 0 Then $Ret = _WinAPI_CallNextHookEx($hHookMsgBox, $nCode, $wParam, $lParam) Return $Ret EndIf Switch $nCode Case 5 ;5=HCBT_ACTIVATE $hCtrl = _WinAPI_GetDlgItem($wParam, 65535) ;Text label _WinAPI_SetFocus($hCtrl) EndSwitch Return EndFunc ;==>_CbtHookProcMsgBox Func _MsgBoxNoDefault_BlockEnter() ConsoleWrite(@HotKeyPressed & @CRLF) If @HotKeyPressed <> "{ENTER}" Then HotKeySet("{Enter}") HotKeySet("{TAB}") HotKeySet("{LEFT}") HotKeySet("{RIGHT}") HotKeySet("{UP}") HotKeySet("{DOWN}") Send("{TAB}") EndIf EndFunc ;==>_MsgBoxNoDefault_BlockEnter 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...
Lokdal Posted February 14, 2011 Author Share Posted February 14, 2011 Thanks a lot for all your answers 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