topten

How to organize guis?

16 posts in this topic

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!

Share this post


Link to post
Share on other sites



Try with GUISetState(@SW_LOCK) or create child GUIs, but show them after everything is loaded.

Share this post


Link to post
Share on other sites

"but show them after everything is loaded"

This is what I want to figure out, how to do that :)

Share this post


Link to post
Share on other sites

What is with GUISetState(@SW_SHOW,$hChildWindowHandle), for every child, after evertyhing is loaded

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This is just a raw example of what I mean. Here the elements are appearing at once

But 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 etc

#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 work

#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 by topten

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

ahmet , Thank you for your help and it is quite an interesting approach of using labels

Share this post


Link to post
Share on other sites

Glad I could help

Share this post


Link to post
Share on other sites

I just wonder, if there is any possibility to "preload" all guis hidden  into memory and when they all appear show them

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

"when you and they are ready" :)

That would be sweet.

But

May be I am doing something wrong

This is innitial example (still guis flashing, when created one after another)

#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 work

#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

Share this post


Link to post
Share on other sites

Where is the problem with using labels instead of some child windows as I suggested earlier?

Share this post


Link to post
Share on other sites

Ahmet

Using 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 smooth

Thank you very much- that helped me  with static part

Share this post


Link to post
Share on other sites

#14 ·  Posted (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 by ahmet

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

You are welcome

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now