topten Posted October 29, 2015 Share Posted October 29, 2015 I have a parent gui with many child guis. When they are loading, the are using various controls, using gdi, getting some info from a local db. So when the whole gui is appearing on the window the user can see the child guis appearing one after another + gdi drawing some chart - looks a little... not professional you know what I mean. The question is: Is there any method to organize guis "professional way"? May be something like a "memory bufferizing"?- what I mean is when the whole window appears it already has most needed elements and the user dont see "flashing" here and there? Great thanx in advance for your support! Link to comment Share on other sites More sharing options...
ahmet Posted October 29, 2015 Share Posted October 29, 2015 Try with GUISetState(@SW_LOCK) or create child GUIs, but show them after everything is loaded. Link to comment Share on other sites More sharing options...
topten Posted October 29, 2015 Author Share Posted October 29, 2015 "but show them after everything is loaded"This is what I want to figure out, how to do that Link to comment Share on other sites More sharing options...
ahmet Posted October 29, 2015 Share Posted October 29, 2015 What is with GUISetState(@SW_SHOW,$hChildWindowHandle), for every child, after evertyhing is loaded Link to comment Share on other sites More sharing options...
topten Posted October 29, 2015 Author Share Posted October 29, 2015 (edited) This is just a raw example of what I mean. Here the elements are appearing at onceBut the more elements I am adding on, I see flashing here and there, for example- first the gui is appearing then gdi is clearing buffer, then drawing some line etcexpandcollapse popup#AutoIt3Wrapper_Run_AU3Check=n #include <array.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> #include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> Global Const $Pi = 4 * ATan(1) Global Const $width = 700 Global Const $height = 400 Global $hGUI, $hWnd, $hGraphic, $ParticleBitmap, $ParticleBuffer, $hBrush0, $Brush, $hBrush2, $Pen $dll = DllOpen("user32.dll") $Main_GUI = GUICreate("Main", @DeskTopWidth,@DeskTopHeight,0, 0, $WS_POPUP) GUISetBkColor (0x666699, $Main_GUI ) GUISetState(@SW_SHOW) GUISetState(@SW_SHOW) GUISetState() GUISetState(@SW_SHOW, $Main_GUI) $Child1_GUI = GUICreate("Child", 1366*2, 768*2, 0, 0, $WS_CHILD, -1, $Main_GUI) GUISetBkColor (0x33334C, $Child1_GUI ) GUISetState(@SW_SHOW, $Child1_GUI) Global $Child2_GUI = GUICreate("Child2", 600, 380, 506, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_SHOW, $Child2_GUI) $location=WinGetPos("Child2") $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) Global $Child2_GUIlabels = GUICreate("Child3", 100, 380, 1100, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUIlabels), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_SHOW, $Child2_GUIlabels) _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Child2_GUIlabels) ;create graphic $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics(100, 380, $hGraphic) ;create bitmap $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer $Pen = _GDIPlus_PenCreate(0xFF8080FF, 2) $Pen2 = _GDIPlus_PenCreate(0xE3B4CDFF, 2) _GDIPlus_GraphicsDrawLine($ParticleBuffer, 20, 0, 20, 380, $Pen2) _GDIPlus_GraphicsDrawImageRect($hGraphic, $ParticleBitmap, 0, 0, 100, 380) Local $sString = "line", $aInfo $hBrush = _GDIPlus_BrushCreateSolid(0xE3B4CDFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 11, 1) $tLayout = _GDIPlus_RectFCreate(0, 10, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) MsgBox(0, "", "")But if I do as it was advised and declare GUISetState(@SW_SHOW.......) at the end when everything is loaded then GDI wont workexpandcollapse popup#AutoIt3Wrapper_Run_AU3Check=n #include <array.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> #include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> Global Const $Pi = 4 * ATan(1) Global Const $width = 700 Global Const $height = 400 Global $hGUI, $hWnd, $hGraphic, $ParticleBitmap, $ParticleBuffer, $hBrush0, $Brush, $hBrush2, $Pen $dll = DllOpen("user32.dll") $Main_GUI = GUICreate("Main", @DeskTopWidth,@DeskTopHeight,0, 0, $WS_POPUP) GUISetBkColor (0x666699, $Main_GUI ) $Child1_GUI = GUICreate("Child", 1366*2, 768*2, 0, 0, $WS_CHILD, -1, $Main_GUI) GUISetBkColor (0x33334C, $Child1_GUI ) Global $Child2_GUI = GUICreate("Child2", 600, 380, 506, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI)) ;GUISetState(@SW_SHOW, $Child2_GUI) $location=WinGetPos("Child2") $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) Global $Child2_GUIlabels = GUICreate("Child3", 100, 380, 1100, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUIlabels), "hwnd", WinGetHandle($Child1_GUI)) _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Child2_GUIlabels) ;create graphic $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics(100, 380, $hGraphic) ;create bitmap $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer $Pen = _GDIPlus_PenCreate(0xFF8080FF, 2) $Pen2 = _GDIPlus_PenCreate(0xE3B4CDFF, 2) _GDIPlus_GraphicsDrawLine($ParticleBuffer, 20, 0, 20, 380, $Pen2) _GDIPlus_GraphicsDrawImageRect($hGraphic, $ParticleBitmap, 0, 0, 100, 380) Local $sString = "line", $aInfo $hBrush = _GDIPlus_BrushCreateSolid(0xE3B4CDFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 11, 1) $tLayout = _GDIPlus_RectFCreate(0, 10, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) GUISetState(@SW_SHOW, $Main_GUI) GUISetState(@SW_SHOW, $Child2_GUIlabels) GUISetState(@SW_SHOW, $Child1_GUI) MsgBox(0, "", "") Edited October 31, 2015 by topten Link to comment Share on other sites More sharing options...
ahmet Posted October 29, 2015 Share Posted October 29, 2015 If everything drawn by gdip is not going to change after load you can use labels instead of some child windows.#include <StaticConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> _GDIPlus_Startup() $hMain=GUICreate("test") GUISetState() $label=GUICtrlCreateLabel("",10,10,100,200,$SS_BITMAP) $hBitmap=_GDIPlus_BitmapCreateFromScan0(100,200) $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsClear($hBmpCtxt, 0xFFFFFFFF) $hGDIBitmap=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) GUICtrlSendMsg($label,$STM_SETIMAGE,$IMAGE_BITMAP,$hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) While 1 Switch GUIGetMsg() Case -3 _GDIPlus_Shutdown() ExitLoop EndSwitch WEnd Link to comment Share on other sites More sharing options...
topten Posted October 30, 2015 Author Share Posted October 30, 2015 ahmet , Thank you for your help and it is quite an interesting approach of using labels Link to comment Share on other sites More sharing options...
ahmet Posted October 30, 2015 Share Posted October 30, 2015 Glad I could help Link to comment Share on other sites More sharing options...
topten Posted October 31, 2015 Author Share Posted October 31, 2015 I just wonder, if there is any possibility to "preload" all guis hidden into memory and when they all appear show them Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2015 Moderators Share Posted October 31, 2015 topten,Use the @SW_HIDE parameter when creating the GUIs and then change their state with @SW_SHOW when you and they are ready.M23 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...
topten Posted October 31, 2015 Author Share Posted October 31, 2015 "when you and they are ready" That would be sweet.ButMay be I am doing something wrongThis is innitial example (still guis flashing, when created one after another)expandcollapse popup#AutoIt3Wrapper_Run_AU3Check=n #include <array.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> #include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> Global Const $Pi = 4 * ATan(1) Global Const $width = 700 Global Const $height = 400 Global $hGUI, $hWnd, $hGraphic, $ParticleBitmap, $ParticleBuffer, $hBrush0, $Brush, $hBrush2, $Pen $dll = DllOpen("user32.dll") $Main_GUI = GUICreate("Main", @DeskTopWidth,@DeskTopHeight,0, 0, $WS_POPUP) GUISetBkColor (0x666699, $Main_GUI ) GUISetState(@SW_SHOW, $Main_GUI) $Child1_GUI = GUICreate("Child", 1366*2, 768*2, 0, 0, $WS_CHILD, -1, $Main_GUI) GUISetBkColor (0x33334C, $Child1_GUI ) GUISetState(@SW_SHOW, $Child1_GUI) Global $Child2_GUI = GUICreate("Child2", 600, 380, 506, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_SHOW, $Child2_GUI) $location=WinGetPos("Child2") $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) Global $Child2_GUIlabels = GUICreate("Child3", 100, 380, 1100, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUIlabels), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_SHOW, $Child2_GUIlabels) _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Child2_GUIlabels) ;create graphic $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics(100, 380, $hGraphic) ;create bitmap $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer $Pen = _GDIPlus_PenCreate(0xFF8080FF, 2) $Pen2 = _GDIPlus_PenCreate(0xE3B4CDFF, 2) _GDIPlus_GraphicsDrawLine($ParticleBuffer, 20, 0, 20, 380, $Pen2) _GDIPlus_GraphicsDrawImageRect($hGraphic, $ParticleBitmap, 0, 0, 100, 380) Local $sString = "line", $aInfo $hBrush = _GDIPlus_BrushCreateSolid(0xE3B4CDFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 11, 1) $tLayout = _GDIPlus_RectFCreate(0, 10, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) MsgBox(0, "", "")This is with sw_show, sw_hide - gdi wouldnt workexpandcollapse popup#AutoIt3Wrapper_Run_AU3Check=n #include <array.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> #include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> Global Const $Pi = 4 * ATan(1) Global Const $width = 700 Global Const $height = 400 Global $hGUI, $hWnd, $hGraphic, $ParticleBitmap, $ParticleBuffer, $hBrush0, $Brush, $hBrush2, $Pen $dll = DllOpen("user32.dll") $Main_GUI = GUICreate("Main", @DeskTopWidth,@DeskTopHeight,0, 0, $WS_POPUP) GUISetBkColor (0x666699, $Main_GUI ) GUISetState(@SW_HIDE, $Main_GUI) $Child1_GUI = GUICreate("Child", 1366*2, 768*2, 0, 0, $WS_CHILD, -1, $Main_GUI) GUISetBkColor (0x33334C, $Child1_GUI ) GUISetState(@SW_HIDE, $Child1_GUI) Global $Child2_GUI = GUICreate("Child2", 600, 380, 506, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_HIDE, $Child2_GUI) $location=WinGetPos("Child2") $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) Global $Child2_GUIlabels = GUICreate("Child3", 100, 380, 1100, 150, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUIlabels), "hwnd", WinGetHandle($Child1_GUI)) GUISetState(@SW_HIDE, $Child2_GUIlabels) _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Child2_GUIlabels) ;create graphic $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics(100, 380, $hGraphic) ;create bitmap $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer $Pen = _GDIPlus_PenCreate(0xFF8080FF, 2) $Pen2 = _GDIPlus_PenCreate(0xE3B4CDFF, 2) _GDIPlus_GraphicsDrawLine($ParticleBuffer, 20, 0, 20, 380, $Pen2) _GDIPlus_GraphicsDrawImageRect($hGraphic, $ParticleBitmap, 0, 0, 100, 380) Local $sString = "line", $aInfo $hBrush = _GDIPlus_BrushCreateSolid(0xE3B4CDFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 11, 1) $tLayout = _GDIPlus_RectFCreate(0, 10, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) GUISetState(@SW_SHOW, $Main_GUI) GUISetState(@SW_SHOW, $Child1_GUI) GUISetState(@SW_SHOW, $Child2_GUI) GUISetState(@SW_SHOW, $Child2_GUIlabels) MsgBox(0, "", "")And I tried it in my main code: the result is this the script is waiting longer, then I see again the guis appearing and flashing one after another, gdi- wont work Link to comment Share on other sites More sharing options...
ahmet Posted October 31, 2015 Share Posted October 31, 2015 Where is the problem with using labels instead of some child windows as I suggested earlier? Link to comment Share on other sites More sharing options...
topten Posted October 31, 2015 Author Share Posted October 31, 2015 AhmetUsing labels works great, especially "If everything drawn by gdip is not going to change after load". Now I am rebuilding my main code, changing from guis to labels- and that is fine. For me the problem is with dynamic part of gdi. I have some flow charts and I am trying to make them look smoothThank you very much- that helped me with static part Link to comment Share on other sites More sharing options...
ahmet Posted October 31, 2015 Share Posted October 31, 2015 (edited) Then look in help file for example of _WinAPI_BitBlt() Edit: I have never used it, but I think that function is what you are looking for. Edited October 31, 2015 by ahmet Link to comment Share on other sites More sharing options...
topten Posted November 2, 2015 Author Share Posted November 2, 2015 Brilliant! Thank you very much, Ahmet. I even didnt think that such function may contain real treasures. At first it looked a little difficult for my understanding, but later, when I got it step by step- it really made miracles. Thanx again! Link to comment Share on other sites More sharing options...
ahmet Posted November 2, 2015 Share Posted November 2, 2015 You are welcome 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