Jump to content

Recommended Posts

Posted

Thanks ahead with for the help.

I'm trying to create an image file that will be centered at the top of a window and will not be resized from it's original dimensions. Is it something to do with the window style? I'm creating an app launcher for a kiosk style setup that I don't want users to be able to close and setting the style to $WS_POPUP removes the user's ability to close or resize the window. The reason I need the jpeg to reposition itself is that I plan to have the size of the windows change dynamically according to the current screen resolution. I'm using 1024x768 right now to test, as it's the most common and I have the image sized to be 800px wide as 800x600 is the smallest resolution I plan to support. Once this is done, I'll have a row of buttons down the center of the form to launch various apps and a timer that will close them all after a certain period if there has been no activity.

My code looks something like:

$wdoMain=GUICreate("Window",1024,768,1,1,$WS_POPUP)
GUISetBKColor(0x083368)

;I've tried various things here with no luck
$title = GUICtrlCreatePic("pic.jpeg",1,1,0,0)
GUICtrlSetResizing($title,$GUI_DOCKAUTO)
  • Moderators
Posted

wzsmith,

Welcome to the AutoIt forum. :mellow:

You need to do some basic maths to work out where to put the picture on your GUI. Like this:

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

Global $aPos

$hGUI = GUICreate("Test", 500, 500, Default, Default, $WS_POPUP)

$hPic = GUICtrlCreatePic("Your_Pic_Path_Here", 0, 0)
$aPos = ControlGetPos($hGUI, "", $hPic)
_Set_Pic(500)

GUISetState()

Sleep(5000)

WinMove($hGUI, "", Default, Default, 200, 200)
_Set_Pic(200)

Sleep(5000)

WinMove($hGUI, "", Default, Default, 300, 600)
_Set_Pic(300)

Sleep(5000)

WinMove($hGUI, "", Default, Default, 600, 200)
_Set_Pic(600)

Sleep(5000)

Exit

Func _Set_Pic($iGUI_Width)

    GUICtrlSetPos($hPic, ($iGUI_Width - $aPos[2]) / 2, 0, $aPos[2], $aPos[3])

EndFunc

I hope this helps - ask if anything is unclear. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

You need to do some basic maths to work out where to put the picture on your GUI.

I see where you're going. I should be able to use @desktopheight and @desktopwidth to size the window, then position things from there. I was hoping that I could automatically have the controls center themselves, similar to the dock functions in VB. This will work fine though. Thanks for the info.

  • Moderators
Posted

wzsmith,

Try this:

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

Global $aPos

$hGUI = GUICreate("Test", 500, 500, Default, Default, $WS_POPUP)

$hPic = GUICtrlCreatePic("M:\Program\Au3 Scripts\Images\Melba23.jpg", 0, 0)
GUICtrlSetResizing ( $hPic, $GUI_DOCKHCENTER + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT )

$aPos = ControlGetPos($hGUI, "", $hPic)
GUICtrlSetPos($hPic, (500 - $aPos[2]) / 2, 0, $aPos[2], $aPos[3])

GUISetState()

Sleep(5000)

WinMove($hGUI, "", Default, Default, 200, 200)

Sleep(5000)

WinMove($hGUI, "", Default, Default, 300, 600)

Sleep(5000)

WinMove($hGUI, "", Default, Default, 600, 200)

Sleep(5000)

Exit

I forgot that you can set resizing to the vertical and horizontal centres. :mellow:

Makes it a lot simpler! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

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
×
×
  • Create New...