Jump to content



Photo

_GUIFrame UDF


  • Please log in to reply
21 replies to this topic

#1 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 07 September 2008 - 03:11 PM

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:
Plain Text         
#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 ;)

Attached Files


Edited by Kip, 14 July 2009 - 02:57 PM.

There's a big chance this post has been edited.Posted Image





#2 James

James

    jbrooksuk

  • MVPs
  • 9,470 posts

Posted 07 September 2008 - 03:16 PM

I have wanted to know how to do this for ages!

#3 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 07 September 2008 - 05:34 PM

@Kip

Nice but not quite perfect yet.

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

#4 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 07 September 2008 - 05:42 PM

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)

There's a big chance this post has been edited.Posted Image

#5 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 07 September 2008 - 06:29 PM

Registering WM_SIZING, and calling _GUIFrame_Move($iFrame_Horz, 0, 0, $iWidth, $iHeight) does the job to keep it the right size.
There's a big chance this post has been edited.Posted Image

#6 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 07 September 2008 - 07:17 PM

@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

#7 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 07 September 2008 - 07:23 PM

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

My examples already has controls in the frames ;)
There's a big chance this post has been edited.Posted Image

#8 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 07 September 2008 - 07:59 PM

@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

#9 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 07 September 2008 - 08:04 PM

But indead it works well. It was my mistake.
Didn't read through the UDF well enough. sad.gif

;)

(joke :D )
There's a big chance this post has been edited.Posted Image

#10 vaughner

vaughner

    Seeker

  • Active Members
  • 13 posts

Posted 01 June 2009 - 01:36 PM

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

Thanks!
Posted Image Posted Image Posted ImagePlease click me if you have a minute! Thanks!

#11 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 01 June 2009 - 04:49 PM

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.

#12 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 01 June 2009 - 07:09 PM

Nice UDF.

#13 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 392 posts

Posted 08 February 2010 - 09:13 PM

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)!

#14 Kip

Kip

    When done learning: die

  • Active Members
  • PipPipPipPipPipPip
  • 1,685 posts

Posted 10 February 2010 - 03:52 PM

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, 10 February 2010 - 03:54 PM.

There's a big chance this post has been edited.Posted Image

#15 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,164 posts

Posted 10 February 2010 - 05:40 PM

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, 10 February 2010 - 05:45 PM.


#16 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 392 posts

Posted 11 February 2010 - 09:55 PM

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)!

#17 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,164 posts

Posted 11 February 2010 - 10:31 PM

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

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


#18 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 392 posts

Posted 12 February 2010 - 04:55 PM

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)!

#19 RoyS

RoyS

    Seeker

  • Active Members
  • 10 posts

Posted 04 September 2010 - 08:00 PM

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

#20 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,353 posts

Posted 08 September 2010 - 04:47 PM

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
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users