Jump to content
Sign in to follow this  
Floppy

Resize a control

Recommended Posts

Floppy

Hi,

With this script I can move a control:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MenuConstants.au3>

$hGUI = GUICreate("Test", 300, 200)

GUICtrlCreateLabel("Move me", 100, 50, 60, 20)
GUICtrlSetBkColor(-1, 0x00FF00)

GUICtrlCreateButton("hi",40,100,80,23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $cInfo = GUIGetCursorInfo($hGUI)
            $iControl = $cInfo[4]
            
            
            If $iControl Then
                
                $aPos = ControlGetPos($hGUI,"",$iControl)
                
                $iSubtractX = $cInfo[0]-$aPos[0]
                $iSubtractY = $cInfo[1]-$aPos[1]
                
                Do
                    
                    $cInfo = GUIGetCursorInfo($hGUI)
                    
                    ControlMove($hGUI, "", $iControl, $cInfo[0]-$iSubtractX, $cInfo[1]-$iSubtractY)
                    
                Until Not $cInfo[2]
                
            EndIf
            
    EndSwitch
WEnd

How can i resize and move a control with the mouse?

Thanks and bye

Note: Sorry for my bad english...

Share this post


Link to post
Share on other sites
Floppy

See here

It works fine...but if I want to resize all controls?

Isn't there a way to make resizable all controls with one line without write the same line for each control?

Share this post


Link to post
Share on other sites
martin

It works fine...but if I want to resize all controls?

Isn't there a way to make resizable all controls with one line without write the same line for each control?

You would need to loop through each control and size them one at a time.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
Global $btn[4]
Global $lastv=0, $lasth = 0, $nowv, $nowh
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 323, 302, 303, 219)
For $n = 0 to 3
$Btn[$n] = GUICtrlCreateButton("Button1", 80, 78 + $n * 57, 75, 25, 0)
next

$Slider1 = GUICtrlCreateSlider(48, 8, 238, 45)
$Slider2 = GUICtrlCreateSlider(8, 48, 38, 237, BitOR($TBS_VERT,$TBS_AUTOTICKS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

EndSwitch

$nowv = GUICtrlRead($Slider1)
$nowh = GUICtrlRead($Slider2)
if $nowv <> $lastv or $nowh <> $lasth Then
    ConsoleWrite($nowh & @CRLF)
    resizeall($nowv,$nowh)
    $lastv = $nowv
    $lasth = $nowh
EndIf


WEnd


Func resizeall($h,$v)
    for $n = 0 to 3
        controlmove($Form3,"",$btn[$n],80,78 +$n*57,75 + $h,25+$v/3)
    Next
EndFunc
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
rasim

@FSoft

GUICtrlSetResizing?

:)

Share this post


Link to post
Share on other sites
SmOke_N

@FSoft

GUICtrlSetResizing?

:o

And if they're UDF controls he's trying to resize?

:D:)

Edit:

Yes I know his example doesn't show it, but you know when he uses an owner drawn control, it's going to be the next question.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Floppy

@FSoft

GUICtrlSetResizing?

:)

Maybe you don't understand me...

I want a program that allow me to resize with the mouse EACH control in the main window.

If there is a button in the main GUI, I want to resize it directly with the mouse...without change anything in the script.

I hope I make myself clear...sorry for my bad english!

Share this post


Link to post
Share on other sites
SmOke_N

Maybe you don't understand me...

I want a program that allow me to resize with the mouse EACH control in the main window.

If there is a button in the main GUI, I want to resize it directly with the mouse...without change anything in the script.

I hope I make myself clear...sorry for my bad english!

#include <WindowsConstants.au3>

Global $h_gui = GUICreate("I am a gui")
Global $i_button = GUICtrlCreateButton("I am a button", 100, 50, 100, 25, $WS_SIZEBOX)

GUISetState()

While GUIGetMsg() <> -3
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Xand3r

i don't think you can remove that...

p.s. i have found something weird when experimenting with smoke_n's example

#include <WindowsConstants.au3>
#include <GuiConstants.au3>
Global $h_gui = GUICreate("I am a gui",-1,-1,-1,-1,BitOR($WS_OVERLAPPEDWINDOW,$WS_CLIPCHILDREN))
GUISetState()
Global $edit1 = GUICtrlCreateEdit("editable"  ,   0, 150, 100, 125, BitOR($WS_CLIPSIBLINGS,$WS_THICKFRAME,$WS_CHILD,$WS_SYSMENU),$WS_EX_TOOLWINDOW)
Global $edit2 = GUICtrlCreateEdit("uneditable", 100, 150, 100, 125, BitOR($WS_CLIPSIBLINGS,$WS_THICKFRAME,$WS_CHILD,$WS_SYSMENU,$WS_CAPTION),$WS_EX_TOOLWINDOW)
Global $but1 = GUICtrlCreateButton("Focus" , 0,0,100,30)
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $but1
            GUICtrlSetState($edit2,$GUI_FOCUS)
    EndSwitch
    Sleep(1)
WEnd

adding ws_caption to the edit (to add a title) makes the $edit2 permanently inactive... (you can not activate it by clicking it)

any thoughts?


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
martin

There's a white border around the button...How can i remove it?

You could have an option somewhere to remove or add the $WS_SIZEBOX from the controls.

Can you say what you don't like about MrCreator's udf apart from the fact that it only resizes one control at a a time?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Xand3r

You could have an option somewhere to remove or add the $WS_SIZEBOX from the controls.

Can you say what you don't like about MrCreator's udf apart from the fact that it only resizes one control at a a time?

$WS_SIZEBOX includes $WS_THICKFRAME so it dosen't remove that border


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
martin

$WS_SIZEBOX includes $WS_THICKFRAME so it dosen't remove that border

I don't understand you, perhaps because you are wrong.

#include <WindowsConstants.au3>
$border = True
Global $h_gui = GUICreate("I am a gui")
Global $i_button = GUICtrlCreateButton("I am a button", 100, 50, 100, 25, $WS_SIZEBOX)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = -3 Then ExitLoop
    If $Msg = $i_button Then
        If $border Then
            GUICtrlSetStyle($i_button, 0)
        Else
            GUICtrlSetStyle($i_button, $WS_SIZEBOX)
        EndIf
        $border = Not $border
    EndIf
    
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Xand3r

I don't understand you, perhaps because you are wrong.

#include <WindowsConstants.au3>
$border = True
Global $h_gui = GUICreate("I am a gui")
Global $i_button = GUICtrlCreateButton("I am a button", 100, 50, 100, 25, $WS_SIZEBOX)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = -3 Then ExitLoop
    If $Msg = $i_button Then
        If $border Then
            GUICtrlSetStyle($i_button, 0)
        Else
            GUICtrlSetStyle($i_button, $WS_SIZEBOX)
        EndIf
        $border = Not $border
    EndIf
    
WEnd
i'm almoast certain that he wants to be able to resize the button but without having the border

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
SmOke_N

Could always use the BN_HILITE and BN_UNHILITE + WM_COMMAND with Martins SetStyle routine.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Floppy

You could have an option somewhere to remove or add the $WS_SIZEBOX from the controls.

Can you say what you don't like about MrCreator's udf apart from the fact that it only resizes one control at a a time?

It resizes one control at a time and it doesn't show the guide points.

For example:

I have a window with 2 buttons, 4 labels and other controls all resizable. I can resize these controls clicking on the appropriate guide point.

i'm almoast certain that he wants to be able to resize the button but without having the border

Yes, but I want also the guide points around the controls

Sorry for my bad english

Share this post


Link to post
Share on other sites
SmOke_N

It resizes one control at a time and it doesn't show the guide points.

For example:

I have a window with 2 buttons, 4 labels and other controls all resizable. I can resize these controls clicking on the appropriate guide point.

Yes, but I want also the guide points around the controls

Sorry for my bad english

Want some fries with that as well?

Sorry for my bad ...

Edit:

I told you what you could do here :)

http://www.autoitscript.com/forum/index.ph...st&p=628061

That could solve most of your issue.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Floppy

Could always use the BN_HILITE and BN_UNHILITE + WM_COMMAND with Martins SetStyle routine.

:):o:D:D

What are BN_HILITE and BN_UNHILITE + WM_COMMAND with Martins SetStyle routine?

Share this post


Link to post
Share on other sites
SmOke_N

http://msdn.microsoft.com/en-us/library/bb761833(VS.85).aspx

And with WM_COMMAND, if you open your help file, go to Search, type in WM_COMMAND you'll see a few examples.

Edit:

Their constant values (in case they don't exist int he includes) are:

Global Const $BN_HILITE = 2

Global Const $BN_UNHILITE = 3

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
rasim

(TheMadman @ Jan 11 2009, 04:01 PM)

$WS_SIZEBOX includes $WS_THICKFRAME so it dosen't remove that border

I don't understand you, perhaps because you are wrong.

He's right:

#include <WindowsConstants.au3>
MsgBox(0, "WS_THICKFRAME check", BitAND($WS_SIZEBOX, $WS_THICKFRAME) = $WS_THICKFRAME)

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  

×