martin Posted March 5, 2011 Share Posted March 5, 2011 (edited) If there is no component in a gui then setting it as the parent for another gui stops it handling messages properly and It can't be activated. The caption bar icons no longer work but it can be maximized or restrored by double clicking on the title bar. [autoit] #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> $hGUI = GUICreate("Test", 500, 500) ;must have at least one component- see below ;components must have clipsiblings style or complete mess can result ;GUICtrlCreateButton("gg", 10, 30, 120, 21,$WS_CLIPSIBLINGS);replace this button and problem is removed GUISetState() $hTT = GUICreate("tooltip", 200,200,0,0) GUISetState() ;if there are no components in the main window then things go wrong - I think this is a bug DllCall("user32.dll", "int", "SetParent", "hwnd", $hTT, "hwnd", $hGUI) GUISwitch($hGUI) winactivate($hGUI);no effect While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd [autoit] Does anyone agree that this is a bug? Edited March 5, 2011 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 (edited) martin,I posted about a similar thing a while ago and no-one had an explanation then:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hMain, $ahChild[1][2] = [[0, 0]], $SC_MOVE = 0xF010 $hMain = GUICreate("Parent Window", 633, 447, 192, 200) GUICtrlCreateLabel("", 0, 0, 0, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $mMain = GUICtrlCreateMenu("New") $mChild = GUICtrlCreateMenuItem("Child", $mMain) GUISetState(@SW_SHOW) ; Prevent maximised children being moved GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") While 1 ; Use advanced GUIGetMsg to distinguish between windows $aMsg = GUIGetMsg(1) Switch $aMsg[1] ; It is the parent Case $hMain ; Now check the message Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $mChild CreateChild() EndSwitch ; Must be a child Case Else ; But which one? For $i = 1 To $ahChild[0][0] If $aMsg[1] = $ahChild[$i][0] Then ; Check the message Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($ahChild[$i][0]) Case $GUI_EVENT_MAXIMIZE ; Set the Maximised flag $ahChild[$i][1] = True Case $GUI_EVENT_MINIMIZE ; Clear the Maximised flag $ahChild[$i][1] = False Case $GUI_EVENT_RESTORE ; Clear the Maximised flag $ahChild[$i][1] = False EndSwitch EndIf Next EndSwitch WEnd Func CreateChild() $hNew_Child = GUICreate("Child " & $ahChild[0][0] + 1, 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX)) _WinAPI_SetParent($hNew_Child, $hMain) Add($ahChild, $hNew_Child) GUISetState() EndFunc ;==>CreateChild Func Add(ByRef $aArray, $hHandle) ; Increase the number of children $aArray[0][0] += 1 ; Resize the array ReDim $aArray[$aArray[0][0] + 1][2] ; Add the child details $aArray[$aArray[0][0]][0] = $hHandle $aArray[$aArray[0][1]][1] = False EndFunc ;==>Add Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) For $i = 1 To $ahChild[0][0] ; Does the message come from a child? If $hWnd = $ahChild[$i][0] Then ; Is the child maximised? If $ahChild[$i][1] Then ;Is it a MOVE mesage? If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False ExitLoop EndIf EndIf Next Return $GUI_RUNDEFMSG EndFunc ;==>On_WM_SYSCOMMANDIf you comment out the <<<<<<<<<<<<<<<< label you get the same effect.So I agree that it is a bug. M23Edit: Added correct link! Edited March 5, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
salim Posted July 31, 2012 Share Posted July 31, 2012 For long time.. I found example script load PNG file from this forum.. and modif with setparent but not work..??? expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> _GDIPlus_Startup() _GUICreate_Alpha("butter.png", -1, 0, 50,50) _GDIPlus_Shutdown() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func _GUICreate_Alpha($ImaGe, $iX, $iY, $Step, $Time) Local $ParenT, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $ChilD, $PosHeight, $Sleep, $Slide $hImage = _GDIPlus_ImageLoadFromFile($ImaGe) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $ParenT = GUICreate("ParenT", $width, $height, $iX, $iY , $WS_POPUP ,$WS_EX_LAYERED) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($ParenT , 0xABCDEF, 255) GUISetState() $ChilD = GUICreate("Child", $width, $height, $width, $height , $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST),$ParenT) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", 255) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($ChilD, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) ;DllCall("user32.dll", "int", "SetParent", "hwnd", $ChilD, "hwnd", $ParenT) _WinAPI_SetParent($ChilD, $ParenT) GUISetState() $PPos = WinGetPos($ParenT) $PosWidth= -$width /$Step $PosHeight= -$height /$Step $Sleep = $Time / $Step For $dr = 1 To $Step $dx = ($PosWidth * $dr)+ ($PPos[0]+$width) $dy = ($PosHeight * $dr)+ ($PPos[1]+$height) WinMove($ChilD, "", $dx, $dy) Sleep($Sleep) Next EndFunc This script work in windows xp.. For Melba23 / Martin Or for All Master Autoit. How to make script work in windows 7. Thank's Sory for my english.. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now