Jump to content
Sign in to follow this  
Kip

_GUIFrame UDF

Recommended Posts

Kip

On request by Ptrex, I made this UDF.

It splits GUIs into different pieces, which can be resized.

Just like frames in HTML.

Screenshot of a splitted GUI: (In case you have no idea what i'm talking about)

Posted Image

If you still have no idea, just check it out.

Example:

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <WinAPI.au3>
 #include <GUIFrame.au3>
 
 $FR_CALLBACK = "FrameSizing"; Gets called when a frame is being resized
 
 $GUI = GUICreate("Splitted GUI",600,500)
    
    $iFrame_Vert = _GUIFrame_Create($GUI, $FR_VERT)
    
    _GUIFrame_SetMin($iFrame_Vert, 200, 250); The left frame can't be smaller than 200px, and the right frame can't be smaller than 250px
    
    _GUIFrame_First($iFrame_Vert); Switch to first frame
    GUICtrlCreateLabel("Left frame of the vertical frame control",10,10,200,32)
    
    
    $hSecondFrame = _GUIFrame_GetInfo($iFrame_Vert, $FR_SECOND); Get the handle of the second frame
    
    $iFrame_Horz = _GUIFrame_Create($hSecondFrame, $FR_HORZ); Create another frame control in a frame
    _GUIFrame_SetMin($iFrame_Horz, 100, 100)
    _GUIFrame_First($iFrame_Horz)
    GUICtrlCreateLabel("Upper frame of the horizontal frame control",10,10,200,32)
    
    _GUIFrame_Second($iFrame_Horz)
    GUISetBkColor(0x65d956)
    $Button = GUICtrlCreateButton("A regular button",10,10,120,23)
    
 GUISetState(@SW_SHOW, $GUI)
 
 
 While 1
    
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button
            MsgBox(0,"Test","See, just a regular button")
    EndSwitch
 WEnd
 
 Func FrameSizing($iFrame, $iFirstSize, $iSecondSize)
    
    If $iFrame = $iFrame_Vert Then
        
        _GUIFrame_Move($iFrame_Horz, 0, 0, $iSecondSize)
        
    EndIf
    
 EndFunc

More functions are coming.

Happy Framing ;)

GUIFrame.au3

Edited by Kip

Share this post


Link to post
Share on other sites
ptrex

@Kip

Nice but not quite perfect yet.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIFrame.au3>

$FR_CALLBACK = "FrameSizing"; Gets called when a frame is being resized

$GUI = GuiCreate("Splitted GUI" , 600, 500,(@DesktopWidth-600)/2, (@DesktopHeight-500)/2 , _ 
$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    
    $iFrame_Vert = _GUIFrame_Create($GUI, $FR_VERT)
    
    _GUIFrame_SetMin($iFrame_Vert, 200, 250); The left frame can't be smaller than 200px, and the right frame can't be smaller than 250px
    
    _GUIFrame_First($iFrame_Vert); Switch to first frame
    GUICtrlCreateLabel("Left frame of the vertical frame control",10,10,200,32)
    
    
    $hSecondFrame = _GUIFrame_GetInfo($iFrame_Vert, $FR_SECOND); Get the handle of the second frame
    
    $iFrame_Horz = _GUIFrame_Create($hSecondFrame, $FR_HORZ); Create another frame control in a frame
    _GUIFrame_SetMin($iFrame_Horz, 100, 100)
    _GUIFrame_First($iFrame_Horz)
    GUICtrlCreateLabel("Upper frame of the horizontal frame control",10,10,200,32)
    
    _GUIFrame_Second($iFrame_Horz)
    GUISetBkColor(0x65d956)
    $Button = GUICtrlCreateButton("A regular button",10,10,120,23)
    
GUISetState(@SW_SHOW, $GUI)


While 1
    
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button
            MsgBox(0,"Test","See, just a regular button")
    EndSwitch
WEnd

Func FrameSizing($iFrame, $iFirstSize, $iSecondSize)
    
    If $iFrame = $iFrame_Vert Then
        
        _GUIFrame_Move($iFrame_Horz, 0, 0, $iSecondSize)
        
    EndIf
    
EndFunc

When resizing the Frame don't resize.

Regards,

ptrex

Share this post


Link to post
Share on other sites
Kip

Thats because, the frame control is a control. It isn't fullscreen, just a control that fills up the whole window.

example:

$GUI = GuiCreate("Splitted GUI" , 600, 500,(@DesktopWidth-600)/2, (@DesktopHeight-500)/2 , _
$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
   
    $iFrame_Vert = _GUIFrame_Create($GUI, $FR_VERT, 100, 100, 400, 300, 0, $WS_EX_CLIENTEDGE)

Share this post


Link to post
Share on other sites
ptrex

@Kip

Thats because, the frame control is a control. It isn't fullscreen, just a control that fills up the whole window

This might not be the best desing, because it are the Controls in the frames thet need to be resized.

A frame should best not be a control. Because the frame need store then control themselves. Like Edit, Treeview, listview Control, etc.

Or am I looking at this the wrong way ?

Best to post an example that contains control in the frames. This will show wether it works all together.

Thanks.

regards,

ptrex

Share this post


Link to post
Share on other sites
ptrex

@Kip

I overlooked againg the UDF, and it lookes like you create the frames as seperate child GUI's, using "GUICreate".

Which hold then the controls.

Rather then the control resize relative to each other, in the main GUI.

But indead it works well. It was my mistake.

Didn't read through the UDF well enough. ;)

regards,

ptrex

Share this post


Link to post
Share on other sites
vaughner

Is there always the flickering with this UDF? Seems like the thread has died but I will ask anyways.

Thanks!


Please click me if you have a minute! Thanks!

Share this post


Link to post
Share on other sites
Authenticity

You can move the WinMove() calls after the _IsPressed() loop and you won't see this flickering or anything at all until you release the mouse button. The problem is that WS_EX_COMPSITED can't be used with a window with either CS_OWNDC or CS_CLASSDC as stated here. I've tried to remove these class styles and was not happy when I saw the infamous BSOD, hehe.

Share this post


Link to post
Share on other sites
lsakizada

I know this is old thread but I am facing problem to close the main GUI

of the example script normaly.

The gui is freezing when clicking on the X button.

Whats wrong. Does only me see the freeze?


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites
Kip

I know this is old thread but I am facing problem to close the main GUI

of the example script normaly.

The gui is freezing when clicking on the X button.

Whats wrong. Does only me see the freeze?

You're not the only one :D

I made this a while ago, this didn't appear back then. I guess AutoIt has changed something over the past few years...

Edited by Kip

Share this post


Link to post
Share on other sites
KaFu

The callbacks need to be unset on exit...

Add

OnAutoItExitRegister("_Clean_Callbacks")
at the top and

Func _Clean_Callbacks()
    For $i = 1 To UBound($FR_FrameControls) - 1
        _RegMsg_Register($FR_FrameControls[$i][1], "")
    Next
EndFunc
somewhere down below in your functions section. Edited by KaFu

Share this post


Link to post
Share on other sites
lsakizada

The callbacks need to be unset on exit...

Add

OnAutoItExitRegister("_Clean_Callbacks")
at the top and

Func _Clean_Callbacks()
    For $i = 1 To UBound($FR_FrameControls) - 1
        _RegMsg_Register($FR_FrameControls[$i][1], "")
    Next
EndFunc
somewhere down below in your functions section.

Hi KaFu,

This still has hard crash on exit.

I could not find the solution yet.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites
KaFu

Really? Example in post 1 crashes for me too... this one doesn't...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIFrame.au3>

OnAutoItExitRegister("_Clean_Callbacks")

$FR_CALLBACK = "FrameSizing"; Gets called when a frame is being resized

$GUI = GUICreate("Splitted GUI", 600, 500)

$iFrame_Vert = _GUIFrame_Create($GUI, $FR_VERT)

_GUIFrame_SetMin($iFrame_Vert, 200, 250); The left frame can't be smaller than 200px, and the right frame can't be smaller than 250px

_GUIFrame_First($iFrame_Vert); Switch to first frame
GUICtrlCreateLabel("Left frame of the vertical frame control", 10, 10, 200, 32)

$hSecondFrame = _GUIFrame_GetInfo($iFrame_Vert, $FR_SECOND); Get the handle of the second frame

$iFrame_Horz = _GUIFrame_Create($hSecondFrame, $FR_HORZ); Create another frame control in a frame
_GUIFrame_SetMin($iFrame_Horz, 100, 100)
_GUIFrame_First($iFrame_Horz)
GUICtrlCreateLabel("Upper frame of the horizontal frame control", 10, 10, 200, 32)
_GUIFrame_Second($iFrame_Horz)
GUISetBkColor(0x65d956)
$Button = GUICtrlCreateButton("A regular button", 10, 10, 120, 23)
GUISetState(@SW_SHOW, $GUI)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            MsgBox(0, "Test", "See, just a regular button")
    EndSwitch
WEnd

Func FrameSizing($iFrame, $iFirstSize, $iSecondSize)
    If $iFrame = $iFrame_Vert Then
        _GUIFrame_Move($iFrame_Horz, 0, 0, $iSecondSize)
    EndIf
EndFunc   ;==>FrameSizing

Func _Clean_Callbacks()
    For $i = 1 To UBound($FR_FrameControls) - 1
        _RegMsg_Register($FR_FrameControls[$i][1], "")
    Next
EndFunc

Share this post


Link to post
Share on other sites
lsakizada

Really? Example in post 1 crashes for me too... this one doesn't...

Kafu,

I have seen the crash with yor fix again but then I decided to updat to current beta . (mine was 2 or three older..)

I do not see the crash anymore.

Thank you very very very much for your help! :mellow:

Now I can adopt the _GUIFrame UDF into my project. Rgards, K.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites
RoyS

very useful UDF, Thank you!

Have a problem though, resizing main window and the frames reduce in size but do not increase in size..

Any help available?

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <WinAPI.au3>

#include <GUIFrame.au3>

OnAutoItExitRegister("_Clean_Callbacks")

$FR_CALLBACK = "FrameSizing"; Gets called when a frame is being resized

$GUI = GUICreate("Splitted GUI", 600, 500, -1, -1, BitOR($WS_SizeBox, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

;_GUIFrame_Create($hWnd, $iFrameStyle, $iX=0, $iY=0, $iWidth=0, $iHeight=0, $iStyle=0, $iExStyle=0)

$iFrame_Vert = _GUIFrame_Create($GUI, $FR_VERT, $FR_FRAMESTYLE)

_GUIFrame_SetMin($iFrame_Vert, 200, 250); The left frame can't be smaller than 200px, and the right frame can't be smaller than 250px

_GUIFrame_First($iFrame_Vert); Switch to first frame

GUICtrlCreateLabel("Left frame of the vertical frame control", 10, 10, 200, 32)

$hSecondFrame = _GUIFrame_GetInfo($iFrame_Vert, $FR_SECOND); Get the handle of the second frame

$iFrame_Horz = _GUIFrame_Create($hSecondFrame, $FR_HORZ); Create another frame control in a frame

_GUIFrame_SetMin($iFrame_Horz, 100, 100)

_GUIFrame_First($iFrame_Horz)

GUICtrlCreateLabel("Upper frame of the horizontal frame control", 10, 10, 200, 32)

_GUIFrame_Second($iFrame_Horz)

GUISetBkColor(0x65d956)

$Button = GUICtrlCreateButton("A regular button", 10, 10, 120, 23)

GUISetState(@SW_SHOW, $GUI)

While 1

Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE

Exit

Case $Button

MsgBox(0, "Test", "See, just a regular button")

EndSwitch

WEnd

Func FrameSizing($iFrame, $iFirstSize, $iSecondSize)

If $iFrame = $iFrame_Vert Then

_GUIFrame_Move($iFrame_Horz, 0, 0, $iSecondSize)

EndIf

EndFunc ;==>FrameSizing

Func _Clean_Callbacks()

For $i = 1 To UBound($FR_FrameControls) - 1

_RegMsg_Register($FR_FrameControls[$i][1], "")

Next

EndFunc ;==>_Clean_Callbacks

Share this post


Link to post
Share on other sites
Melba23

RoyS and others,

With Kip's kind permission, I am in the process of completely rewriting this UDF. The new version will include support for resizing the frames as the GUI resizes as well as few other new things. :)

Keep your eyes open! ;)

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

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.