#Include <GuiConstantsEx.au3> #Include <ButtonConstants.au3> #Include <WindowsConstants.au3> $Title = "My Custom MsgBox" $Prompt = "Are you sure?" $CheckBoxText = "Don't show again" $hWnd = WinGetHandle("") $Ask = _GuiMsgBox(256+32, 2, $Title, $Prompt, 330, 120, $CheckBoxText, 10, $hWnd, "OK", "Cancel") $CheckBitAnd = BitAND($Ask, 8) $Var = "Pressed " Select Case $Ask - $CheckBitAnd = 1 $Var &= "'OK'" Case $Ask - $CheckBitAnd = 6 $Var &= "'Yes' or 'OK'" Case $Ask - $CheckBitAnd = 7 $Var &= "'No' or 'Cancel'" EndSelect If $CheckBitAnd = 8 Then $Var &= @LF & "And CheckBox <" & $CheckBoxText & "> was Checked" MsgBox(64, "Message", "Returned values:" & @LF & @LF & $Var) Func _GuiMsgBox($iIcoType,$iButt_Num,$sTitle,$sText,$iWidth,$iHeight,$sCB_Text=-1,$iTimer=-1,$hWnd=0,$sB1Text=-1,$sB2Text=-1,$nExStyle=-1) Local $nYes_Button, $nNo_Button, $nOK_Button, $nCheckBox=-1, $hMsgBox_GUI, $iGuiHeight = $iHeight Local $nStyle = BitOR($WS_CAPTION, $WS_POPUP) Local $nMsg, $iReturnVal = 0 Local $nDefButton, $sDefButtonText = $sB1Text, $iCounter Local $iMessageBeep = -1, $iIcon_Id = 102 Local $iOld_Opt_GOEM = Opt('GuiOnEventMode', 0) Local $iOld_Opt_GCOE = Opt('GUICloseOnESC', 0) If $iButt_Num = 1 Then $nStyle = BitOR($nStyle, $WS_SYSMENU) If BitAND($iIcoType, 262144) Then If $nExStyle = -1 Or $nExStyle = Default Then $nExStyle = 0 $nExStyle = BitOR($nExStyle, $WS_EX_TOPMOST) EndIf If $sCB_Text <> -1 Then $iGuiHeight += 25 If $sB1Text = -1 Then $sB1Text = 'OK' If $sB2Text = -1 Then $sB2Text = 'Cancel' If IsHWnd($hWnd) Then WinSetState($hWnd, "", @SW_DISABLE) $hMsgBox_GUI = GUICreate($sTitle, $iWidth, $iGuiHeight, -1, -1, $nStyle, $nExStyle, $hWnd) Select Case $iIcoType = 16 Or $iIcoType = 16 + 256 $iIcon_Id = 103 $iMessageBeep = 0x00000010 Case $iIcoType = 32 Or $iIcoType = 32 + 256 $iIcon_Id = 102 $iMessageBeep = 0x00000020 Case $iIcoType = 48 Or $iIcoType = 48 + 256 $iIcon_Id = 101 $iMessageBeep = 0x00000030 Case $iIcoType = 64 Or $iIcoType = 64 + 256 $iIcon_Id = 104 $iMessageBeep = 0x00000040 EndSelect GUICtrlCreateIcon('user32.dll', $iIcon_Id, 10, 10) GUICtrlCreateLabel($sText, 70, 15, $iWidth-80, $iHeight-50) Select Case $iButt_Num = 2 $nYes_Button = GUICtrlCreateButton($sB1Text, ($iWidth/2)-90, $iHeight-35, 70, 20, $BS_DEFPUSHBUTTON) $nDefButton = $nYes_Button Local $iSecButtDeffStyle = 0 If BitAND($iIcoType, 256) Then $iSecButtDeffStyle = $BS_DEFPUSHBUTTON $nNo_Button = GUICtrlCreateButton($sB2Text, ($iWidth/2)+20, $iHeight-35, 70, 20, $iSecButtDeffStyle) If BitAND($iIcoType, 256) Then $nDefButton = $nNo_Button Case Else $nOK_Button = GUICtrlCreateButton($sB1Text, ($iWidth-70)/2, $iHeight-35, 70, 20) GUICtrlSetState($nOK_Button, $GUI_ONTOP) $nDefButton = $nOK_Button EndSelect If $sCB_Text <> -1 Then $nCheckBox = GUICtrlCreateCheckbox($sCB_Text, 15, $iHeight-10) GUISetState(@SW_SHOW, $hMsgBox_GUI) DllCall("user32.dll", "int", "MessageBeep", "int", $iMessageBeep) If $iTimer > 0 Then $iCounter = $iTimer $iTimer = TimerInit() $sDefButtonText = GUICtrlRead($nDefButton) GUICtrlSetData($nDefButton, $sDefButtonText & ' (' & $iCounter & ')') EndIf While 1 $nMsg = GUIGetMsg() If $iTimer > 0 And TimerDiff($iTimer) >= 1000 Then $iTimer = TimerInit() $iCounter -= 1 GUICtrlSetData($nDefButton, $sDefButtonText & ' (' & $iCounter & ')') If $iCounter < 0 Then $nMsg = $nDefButton EndIf Select Case $iButt_Num = 2 And $nMsg = $nYes_Button $iReturnVal = 6 ExitLoop Case $iButt_Num = 2 And $nMsg = $nNo_Button $iReturnVal = 7 ExitLoop Case $nMsg = -3 Or ($nMsg = $nOK_Button And $iButt_Num <> 2) $iReturnVal = 1 ExitLoop EndSelect Wend If GUICtrlRead($nCheckBox) = 1 Then $iReturnVal += 8 If IsHWnd($hWnd) Then WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($hMsgBox_GUI) If IsHWnd($hWnd) Then GUISwitch($hWnd) Opt('GuiOnEventMode', $iOld_Opt_GOEM) Opt('GUICloseOnESC', $iOld_Opt_GCOE) Return $iReturnVal EndFunc |