Bonjour,
Voici quelques fonctions qui créent une MsgBox avec une checkbox pour "ne plus afficher ce message".
Il y a également une fonction qui efface ce paramètre.
En prime, j'ai mis un générateur de GUID : utilisez-en un différent pour chaque msgbox de chacun de vos programmes, sinon le paramètre s'appliquera partout !
Dans le code qui suit, décommentez la 8ème ligne (
;_RestoreDefaultSettings()) pour réinitialiser les paramètres.
► Afficher le texteMsgBox
$hGui=GUICreate("GUI principale", 300, 300)
GUISetState()
Local $sIdentifier = "{315Ef1E9-1078-4E74-8AB4-171BE0D793E71}"
Local $iDefault = 1
;_RestoreDefaultSettings()
$msgNr=_MessageBoxCheck(33, 'TITRE', 'Bonjour,'&@CRLF&'Qui es-tu, toi qui joue avec le registre ?', $sIdentifier, $iDefault, $hGui)
ConsoleWrite('MsgBox returned : '&$msgNr)
; #FUNCTION# =================================================================================================
; Name...........: _MessageBoxCheck
; Description ...: Creates a MessageBox with a "Do not show me this message again" checkbox.
; Syntax.........: _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault, $hWnd, $iTimeout = 0)
; Parameters....: $iFlag - MsgBox flag
; $sTitle - MsgBox title
; $sText - MsgBox text
; $sIdentifier - Unique GUID, that identifies the MsgBox in the registry (for the "Do not show..." setting)
; $iDefault - Default button
; $hWnd - MsgBox's parent
; $iTimeout - Timeout value
; Return values .: Success - The index of the button
; Author ........: Perceval FARAMAZ (perfaram)
; Remarks .......: This function will create an classic MsgBox in case the MessageBoxCheckW interface is not available
; =================================================================================================
Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault, $hWnd, $iTimeout = 0)
Local $msgN_Call = DllCall("shlwapi.dll", "int", "SHMessageBoxCheckW", _
"hwnd", $hWnd, _
"wstr", $sText, _
"wstr", $sTitle, _
"dword", $iFlag, _
"int", $iDefault, _
"wstr", $sIdentifier)
If @error Or $msgN_Call[0] = -1 Then
Return SetError(1, 0, MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd)) ;fallback
EndIf
Return SetError(0, 0, $msgN_Call[0])
EndFunc
; #FUNCTION# =================================================================================================
; Name...........: _RestoreDefaultSettings
; Description ...: Clear user's setting for "Do not show me this message again" checkbox.
; Author ........: Perceval FARAMAZ (perfaram)
; Remarks .......: You must change the GUID (in the registry path below), to match the one you used to call the MsgBoxCheck
; =================================================================================================
Func _RestoreDefaultSettings()
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", "{315Ef1E9-1078-4E74-8AB4-171BE0D793E71}")
EndFunc
Func uuid()
Return StringFormat('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', _
Random(0, 0xffff), Random(0, 0xffff), _
Random(0, 0xffff), _
BitOR(Random(0, 0x0fff), 0x4000), _
BitOR(Random(0, 0x3fff), 0x8000), _
Random(0, 0xffff), Random(0, 0xffff), Random(0, 0xffff) _
)
EndFunc
Voili voilou, c'est tout !
PS : la fonction uuid() n'est pas de moi, elle vient de
là