Что нового

Как сделать OnTop на все дочерние окна?

agikon

Знающий
Сообщения
789
Репутация
17
Вобщем сначла и не замечал а потом заметил что функция чтобы окно всегда было поверх остальных окон работает не правильно. то есть поверх остальных окон появляется только главное, а дочерние окна появляются в тени главного.

вобщем вот код, подскажите почему так происходит
Код:
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

GUICreate("PC10")  ; will create a dialog box that when displayed is centered
$nButton1 = GUICtrlCreateButton('пример 1', 20, 50, 110, 30)
$nButton2 = GUICtrlCreateButton('пример 2', 20, 80, 110, 30)
$ontop = GUICtrlCreateCheckbox(" окно всегда наверху", 35, 310, 150, 20)
GUICtrlSetState(-1, $ontop)

GUISetState()
; Run the GUI until the dialog is closed
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
		Case $GUI_EVENT_CLOSE
           	exit
		Case $nButton1
			MsgBox(64, 'Info', 'пример 1')

		Case $nButton2
			MsgBox(64, 'Info', 'пример 2')

		Case $ontop
				If BitAND(GUICtrlRead($ontop), $GUI_CHECKED) then
					WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 1 )
				Else
					WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 0 )
				EndIf
    EndSwitch
Wend
 

VladUs

Скриптер
Сообщения
621
Репутация
181
Может так

Код:
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

GUICreate("PC10")  ; will create a dialog box that when displayed is centered
$nButton1 = GUICtrlCreateButton('пример 1', 20, 50, 110, 30)
$nButton2 = GUICtrlCreateButton('пример 2', 20, 80, 110, 30)
$ontop = GUICtrlCreateCheckbox(" окно всегда наверху", 35, 310, 150, 20)
GUICtrlSetState(-1, $ontop)

GUISetState()
; Run the GUI until the dialog is closed
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            exit
        Case $nButton1
            MsgBox(64 + 4096, 'Info', 'пример 1')
        Case $nButton2
            MsgBox(64 + 4096, 'Info', 'пример 2')

        Case $ontop
                If BitAND(GUICtrlRead($ontop), $GUI_CHECKED) then
                    WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 1 )
                Else
                    WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 0 )
                EndIf
    EndSwitch
Wend
 
Автор
A

agikon

Знающий
Сообщения
789
Репутация
17
VladUs
как?

а вы разницу видите?
 

asdf8

Скриптер
Сообщения
564
Репутация
152
agikon [?]
а дочерние окна появляются в тени главного.

Когда они действительно будут дочерними, тогда будет все в порядке :

Код:
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

$hGui = GUICreate("PC10")  ; will create a dialog box that when displayed is centered
$nButton1 = GUICtrlCreateButton('пример 1', 20, 50, 110, 30)
$nButton2 = GUICtrlCreateButton('пример 2', 20, 80, 110, 30)
$ontop = GUICtrlCreateCheckbox(" окно всегда наверху", 35, 310, 150, 20)
GUICtrlSetState(-1, $ontop)

GUISetState()
; Run the GUI until the dialog is closed
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            exit
        Case $nButton1
            MsgBox(64, 'Info', 'пример 1', '', $hGui)

        Case $nButton2
            MsgBox(64, 'Info', 'пример 2', '', $hGui)

        Case $ontop
                If BitAND(GUICtrlRead($ontop), $GUI_CHECKED) then
                    WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 1 )
                Else
                    WinSetOnTop ( "[REGEXPTITLE:PC10.*]", "", 0 )
                EndIf
    EndSwitch
Wend
 
Автор
A

agikon

Знающий
Сообщения
789
Репутация
17
ааа точно.
asdf8 спасибо.

а вот опять вопросик, как сделать дочернее уже не MsgBox, а другое gui-окно $hGui2

ну то есть если с главного окна $hGui вызываем подокно $hGui2.
то как это $hGui2 сделать дочерним?
 

Zaramot

I ♥ AutoIt
Сообщения
1,160
Репутация
660
Так ?:
Код:
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

$GUI  = GUICreate("PC10")  ; will create a dialog box that when displayed is centered
$nButton1 = GUICtrlCreateButton('пример 1', 20, 50, 110, 30)
$nButton2 = GUICtrlCreateButton('пример 2', 20, 80, 110, 30)
$nButton3 = GUICtrlCreateButton('Окно', 20, 110, 110, 30)
$ontop = GUICtrlCreateCheckbox(" окно всегда наверху", 35, 310, 150, 20)
GUICtrlSetState(-1, $ontop)

GUISetState()

WinSetOnTop ($GUI, "", 1 )
; Run the GUI until the dialog is closed
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $nButton1
            MsgBox(64, 'Info', 'пример 1', 0, $GUI)

        Case $nButton2
            MsgBox(64, 'Info', 'пример 2', 0, $GUI)
		Case $nButton3
			NewWindow()

        Case $ontop
                If BitAND(GUICtrlRead($ontop), $GUI_CHECKED) then
                    WinSetOnTop ($GUI, "", 1 )
                Else
                    WinSetOnTop ($GUI, "", 0 )
                EndIf
    EndSwitch
Wend

Func NewWindow()
	$GUI2 = GUICreate('New window', 400, 300, -1, -1, -1, -1, $GUI)
	GUISetState()

	Do
	until GUIGetMsg() = -3

	GUIDelete($GUI2)
EndFunc


как это $hGui2 сделать дочерним?
Посмотри последний параметр у GuiCreate()
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
agikon
А что означает это?
Код:
;...
$ontop = GUICtrlCreateCheckbox(" окно всегда наверху", 35, 310, 150, 20)
GUICtrlSetState(-1, $ontop)
;...
 

Zaramot

I ♥ AutoIt
Сообщения
1,160
Репутация
660
Вы уверены в этом? С каких пор controlID стал аналогом $GUI_CHECKED ?
madmasles уберите эту строку и посмотрите на CheckBox, потом добавьте и посмотрите снова :smile:
 

AZJIO

Меценат
Меценат
Сообщения
2,874
Репутация
1,194
agikon
ссылка

Zaramot
Совпадение... ID это идентификатор 1, 2, 3 и далее
 
Автор
A

agikon

Знающий
Сообщения
789
Репутация
17
Zaramot,
спасибо то что и надо было мне помочь.
Спасибо Zaramot, спасибо AZJIO, вспасибо.
 
Верх