Jump to content
Sign in to follow this  
MyEarth

Array variable incorrect number...

Recommended Posts

MyEarth

Hi all guys of the forum, based on this script:

I want to make custom button name but i have a problem:

#include <WinAPI.au3>

Global $hHookMsgBox

_MsgBox(0, "Title", "Text", "Button1")
_MsgBox(1, "Title", "Text", "Button1|Button2")
;~ _MsgBox(2, "Title", "Text")
;~ _MsgBox(3, "Title", "Text")
;~ _MsgBox(4, "Title", "Text")
;~ _MsgBox(5, "Title", "Text")
;~ _MsgBox(6, "Title", "Text")
;~ _MsgBox(7, "Title", "Text")

Func _MsgBox($flag, $title, $text, $var = "", $timeout = 0, $hwnd = 0)
Global $MsgBox_Name = StringSplit($var, "|")
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)
$MsgBox_Name = ""
Return $iRet
EndFunc ;==>_MsgBox_Ex

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, $MsgBox_Name[1])
_WinAPI_SetDlgItemText($wParam, 2, $MsgBox_Name[2])
_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

If i start only one of those separately work, ifi try to start both of them not. I think the problem is "clear" the array, i have add the $MsgBox_Name = "" but not work. Some suggestion?

Thanks to all

Edited by MyEarth

Share this post


Link to post
Share on other sites
water

Change

_MsgBox(0, "Title", "Text", "Button1")
to
_MsgBox(0, "Title", "Text", "Button1|")


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MyEarth

Sure, was an easy answer. Thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×