Цитата snoitaleR:
Мой пример сначала не подходил, а теперь подходит »
|
Не совсем, т.к нужно каждый раз следить за событиями дочернего окна, и что если нужно несколько сообщений выводить?
Если делать по этому методу, тогда лучше так:
Код:

Global $aMsgBox_Data[2][2] = [[0, -1], [0, -1]]
$hGUI = GUICreate("", 300, 300)
$nEDIT = GUICtrlCreateEdit("", 0, 0, 300, 200, 0x1000)
$nBUTTON1 = GUICtrlCreateButton("MsgBox", 0, 200, 300, 50)
$nBUTTON2 = GUICtrlCreateButton("GUI2", 0, 250, 300, 50)
GUISetState(@SW_SHOW, $hGUI)
AdlibEnable("_SetEditData_Proc", 50)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $nBUTTON1
MsgBox(48, "Внимание!", "Приложение заблокировано" & @CRLF & "Нажмите OK, чтобы закрыть окно", 0, $hGUI)
Case $nBUTTON2
_GUI_MsgBox("Внимание!", "Приложение продолжает работу" & @CRLF & "Нажмите OK, чтобы закрыть окно", $hGUI)
Case 0
;None
Case Else ;Any event except 0, it's can be only the new created elements of child GUIs
Local $aTmp_Arr[1][2]
For $i = 1 To $aMsgBox_Data[0][0]
If $aMsgBox_Data[$i][1] <> $nMsg Then
$aTmp_Arr[0][0] += 1
ReDim $aTmp_Arr[$aTmp_Arr[0][0]+1][2]
$aTmp_Arr[$aTmp_Arr[0][0]][0] = $aMsgBox_Data[$i][0]
$aTmp_Arr[$aTmp_Arr[0][0]][1] = $aMsgBox_Data[$i][1]
Else
GUISetState(@SW_HIDE, $aMsgBox_Data[$i][0])
GUIDelete($aMsgBox_Data[$i][0])
If Not WinActive($hGUI) Then WinActivate($hGUI)
EndIf
Next
$aMsgBox_Data = $aTmp_Arr
EndSwitch
WEnd
Func _SetEditData_Proc()
GUICtrlSetData($nEDIT, Chr(Random(32, 127, 1)), 1)
EndFunc
Func _GUI_MsgBox($sTitle, $sMsg, $hWnd)
Local $hGUI, $nButton, $iIndex
$hGUI = GUICreate("GUI #" & $aMsgBox_Data[0][0] + 1 & " - " & $sTitle, 200, 100, -1, -1, 0x00400000, -1, $hWnd)
GUICtrlCreateLabel($sMsg, 10, 10)
$nButton = GUICtrlCreateButton("Ok", -1, 45, 50, 25)
GUISetState(@SW_SHOW, $hGUI)
$iIndex = -1
For $i = 1 To $aMsgBox_Data[0][0]
If $aMsgBox_Data[$i][0] = $hGUI Then
$iIndex = $i
ExitLoop
EndIf
Next
If $iIndex = -1 Then
$aMsgBox_Data[0][0] += 1
$iIndex = $aMsgBox_Data[0][0]
ReDim $aMsgBox_Data[$iIndex+1][2]
EndIf
$aMsgBox_Data[$iIndex][0] = $hGUI
$aMsgBox_Data[$iIndex][1] = $nButton
EndFunc