guinness Posted December 16, 2010 Posted December 16, 2010 The example works only when the GUISetState()'s are swapped around. I am creating a program which has a Parent GUI and then a Child GUI ($WS_EX_MDICHILD) that is hidden on initial start. The example is a strip down version, because "normally speaking" with other Controls it doesn't matter where GUISetState(@SW_SHOW) is put, before the Controls or after the Controls. Yet, in this case it seems to be a problem. If someone knows of the particular Function that I am missing it would be much appreciated.Thanks.Example:#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GDIPlus.au3> _GDIPlus_Startup() _Main() Func _Main() Local $GUI $GUI = GUICreate("GDI+", 400, 300) ;~ GUISetState(@SW_SHOW) ; <<<<< Un-Comment and it will show. _CreateArrow($GUI, 10, 10) GUISetState(@SW_SHOW) ; <<<<< Comment and it will not show the Arrow. Do Until GUIGetMsg() = -3 _GDIPlus_Shutdown() EndFunc ;==>_Main Func _CreateArrow($cHandle, $cLeft, $cTop) Local $cSize = 3 Local $cGraphic = _GDIPlus_GraphicsCreateFromHWND($cHandle) Local $cPen = _GDIPlus_PenCreate(0xFF000000, 2) Local $cEndCap = _GDIPlus_ArrowCapCreate($cSize, 6) _GDIPlus_PenSetCustomEndCap($cPen, $cEndCap) _GDIPlus_GraphicsDrawLine($cGraphic, $cLeft - $cSize, $cTop, $cLeft, $cTop, $cPen) _GDIPlus_ArrowCapDispose($cEndCap) _GDIPlus_PenDispose($cPen) _GDIPlus_GraphicsDispose($cGraphic) EndFunc ;==>_CreateArrow UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
guinness Posted December 17, 2010 Author Posted December 17, 2010 (edited) No that was all the code I had for this small example (I hate to post without giving it a go first.) But thanks for pointing me towards WM_PAINT. I had heard of this Windows Message but didn't have an idea of what it was used for until now. I updated the code, it now paints on Startup and after the GUI has been minimised and restored. But after all this I think perhaps it would be easier (for what I want to do) is just embed an image in the EXE and use Zedna's Resource UDF, because I am going to want to have 5 Arrows that are constantly being deleted and re-created. I love a challenge, but I think opting for less code (which I know won't fail) is a better option. Cheers for taking the time to look at my code. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $Global_GUI, $Global_Graphic, $Global_Image _GDIPlus_Startup() _Main() Func _Main() Local $GUI $GUI = GUICreate("GDI+", 400, 300) $Global_GUI = $GUI GUIRegisterMsg(0x000F, "WM_PAINT") ; WM_PAINT GUIRegisterMsg(0x0085, "WM_PAINT") ; WM_NCPAINT _CreateArrow($GUI, 10, 10) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 _GDIPlus_Shutdown() EndFunc ;==>_Main Func _CreateArrow($cHandle, $cLeft, $cTop) Local $cSize = 3 Local $cGraphicGUI = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($cHandle)) ; Create Double Buffer Local $cBMPBuff = _GDIPlus_BitmapCreateFromGraphics(400, 300, $cGraphicGUI) Local $cGraphic = _GDIPlus_ImageGetGraphicsContext($cBMPBuff) $Global_Graphic = $cGraphicGUI ; End Double Buffer Local $cPen = _GDIPlus_PenCreate(0xFF000000, 2) $Global_Image = $cPen Local $cEndCap = _GDIPlus_ArrowCapCreate($cSize, 6) _GDIPlus_PenSetCustomEndCap($cPen, $cEndCap) _GDIPlus_GraphicsDrawLine($cGraphic, $cLeft - $cSize, $cTop, $cLeft, $cTop, $cPen) EndFunc ;==>_CreateArrow Func WM_PAINT($hWnd, $iMsg, $iwParam, $ilParam) #forceref $iMsg, $iwParam, $ilParam If $hWnd = $Global_GUI Then _GDIPlus_GraphicsDrawLine($Global_Graphic, 10 - 3, 10, 10, 10, $Global_Image) _WinAPI_RedrawWindow($Global_GUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_PAINT Edited December 17, 2010 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
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