Jump to content

JPG not fitting GUI window - (Moved)


Recommended Posts

Hi there, I'm trying to figure out where I went wrong with my script, surely I'm missing something simple, thought I better ask the geniuses.

I have a gui box the same size as the jpg, but it keeps putting the jpg very tiny in the top left corner. I've tried changing -1,-1,0,0, to all sorts of numbers without success.

Would anyone be so kind to provide any guidance?

FileInstall('Auto-It\screenpop\Workday\workday1.JPG', @ScriptDir & "\test.jpg",1);Prompt Graphic

If WinExists("Notification") Then
    Exit
EndIf

#Region ### START GUI section and File Install###


$gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP))
GUISetState (@SW_LOCK)
GUISetBkColor(0xffffff)

;Main Logo Picture

$gMainLogo = GUICtrlCreatePic(@ScriptDir & "\test.jpg",-1,-1,0,0)
GUICtrlSetState(-1, $GUI_DISABLE)


Thank you for your time,

VJA

TopLeft.JPG

Link to post
Share on other sites
Posted (edited)
8 hours ago, VJA said:

thought I better ask the geniuses.

I am far from being a genius :lol:, but perhaps this will help you:

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

; Example : path of an image that is by default provided with AutoIt :
Local $sPicture = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Examples\GUI\merlin.gif"
Local $hGUI, $aPos, $idMainLogo
If WinExists("Notification") Then MsgBox(0, "Exit :", "Notification Windows exists")

$hGUI = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP))
GUISetBkColor(0xFFFFFF)
$aPos = WinGetPos($hGUI)
$idMainLogo = GUICtrlCreatePic($sPicture, 0, 0, $aPos[2], $aPos[3])
GUISetState (@SW_SHOW)
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
GUIDelete($hGUI)

 

Note : It would be helpful, if you could provide a complete script (and the graphic as well). Your current version does not even contain the required #Include 's or the "Acknowledge" button, etc.

For posting code use :

IPB4_Editor_AddCode_Button.png.82396b83ccb443fa98ee5c4b578b1c07.png

 

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum.

Moderation Team

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

 

Link to post
Share on other sites

Thank you so much for your reply, tried your code and the gui window opened, but with no image. Replaced "Examples\GUI\merlin.gif" with "C:\Temp\test_556x625.jpg".

Current code used below and with my test image, it remains in the top left corner. I'll use the add code this time, thank you 😊

; Script Function:
;   Display for GUI


#include <Date.au3>
#include <File.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <ColorConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

; Global Variables **************************************************************************************************************************************

Global $font = "Arial"
Global $gui
Global $aButton
Global $day
Global $progname = "Test"
Global $agree = 0

; Global Variables **************************************************************************************************************************************

FileInstall('C:\Temp\test_556x625.jpg', @ScriptDir & "\test_556x625.jpg",1);Prompt Graphic

If WinExists("Notification") Then
    Exit
EndIf

#Region ### START GUI section and File Install###

$gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP))
GUISetState (@SW_LOCK)
GUISetBkColor(0xffffff)

;Main Logo Picture

$gMainLogo = GUICtrlCreatePic(@ScriptDir & "\test_556x625.jpg",-1,-1,0,0)
GUICtrlSetState(-1, $GUI_DISABLE)

;Agree Button
$ClientSize = WinGetClientSize($gui)
$agree = GUICtrlCreateButton("Acknowledge",180, 580, 185, 35)
GUICtrlSetFont ($agree,10,1000,"",$font)


#EndRegion ### END GUI section ###

GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)
WinActivate($gui)

While 1
        $msg = GUIGetMsg()
    Select
        Case $msg = $agree
            Sleep(1000)
            GUIDelete()
            Sleep(1000)
            $agree=1
            MsgBox (0,"Notification","Thank You! Your response has been recorded.",5)
            Exit (5000)
        EndSelect
WEnd

 

Test.PNG

Link to post
Share on other sites
Posted (edited)
On 5/14/2021 at 10:42 PM, VJA said:

I have a gui box the same size as the jpg, but it keeps putting the jpg very tiny in the top left corner.

I am still not quite aware of what you want to achieve :think: . If the jpg. file has the size 556 x 625 (as the filename "test_556x625.jpg" suggests), then the GUI looks like this on my system :

GUI01.jpg.30b97a2c4d1721b1ad07020ee39b7abb.jpg

From the help for GUICtrlCreatePic : To set the picture control to the same size as the file content set width and height to 0.

For testing add the following include :

#include <GDIPlus.au3>

and directly after the line "FileInstall ..." insert the following code :

_GDIPlus_Startup ()
Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test_556x625.jpg")
If @error Then
    MsgBox(16, "Error", "Does the file exist?")
    Exit 1
EndIf
MsgBox(0, "Size", "Width  = " & _GDIPlus_ImageGetWidth($hImage) & @CRLF & _
                  "Height = " & _GDIPlus_ImageGetHeight($hImage) & @CRLF)
_GDIPlus_ImageDispose ($hImage)
_GDIPlus_ShutDown ()

What are the size specifications ?

EDIT : Possibly we have a so called XY-Problem here
The term "Acknowledge" indicates, that a person has to read and confirm something (maybe a text - see your first posting). To display what should be confirmed, you use the graphic.

Is my assumption correct ?

If Yes, then there are probably better ways, that you just don't know about yet ;).

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites

Maybe this helps:

; Script Function:
;   Display for GUI

#include <GDIPlus.au3>
#include <Date.au3>
#include <File.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <ColorConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

; Global Variables **************************************************************************************************************************************

Global $font = "Arial"
Global $gui
Global $aButton
Global $day
Global $progname = "Test"
Global $agree = 0

; Global Variables **************************************************************************************************************************************

$sImage = @ScriptDir & "\test_556x625.jpg"
FileInstall('C:\Temp\test_556x625.jpg', $sImage,1);Prompt Graphic

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sImage)
$aDim = _GDIPlus_ImageGetDimension($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

If WinExists("Notification") Then
    Exit
EndIf

#Region ### START GUI section and File Install###

$gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP))
GUISetState (@SW_LOCK)
GUISetBkColor(0xffffff)

;Main Logo Picture
$gMainLogo = GUICtrlCreatePic($sImage,(556-$aDim[0])/2,(625-$aDim[1])/2,$aDim[0],$aDim[1])
GUICtrlSetState(-1, $GUI_DISABLE)

;Agree Button
$ClientSize = WinGetClientSize($gui)
$agree = GUICtrlCreateButton("Acknowledge",180, 580, 185, 35)
GUICtrlSetFont ($agree,10,1000,"",$font)


#EndRegion ### END GUI section ###

GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)
WinActivate($gui)

While 1
        $msg = GUIGetMsg()
    Select
        Case $msg = $agree
            Sleep(1000)
            GUIDelete()
            Sleep(1000)
            $agree=1
            MsgBox (0,"Notification","Thank You! Your response has been recorded.",5)
            Exit (5000)
        EndSelect
WEnd

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
Share on other sites

@VJA :

One more question, before we proceed to work on a potentially less suitable solution :

Your approach reminds me of a typical 'Confirm' page, as known e.g. from Installers (Setup's). There you have to enable a checkbox on the page with the License Agreement. Before this is not done, the "Continue" Button remains grayed out (deactivated).

Is this what you are looking for?

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
7 hours ago, Musashi said:

From the help for GUICtrlCreatePic : To set the picture control to the same size as the file content set width and height to 0.

Hi Musashi
Unfortunately this sentence is wrong since AutoIt release 3.3.14.3 as illustrated in this post.

Maybe it works at your place because you're using an older AutoIt version. Sometimes I give old AutoIt versions a personalized name in my AutoIt history folder :)

...
autoit-v3.3.10.0 (invasion of Yashied WinApiEx func).zip
...
autoit-v3.3.12.0 (musashi).zip
...
autoit-v3.3.14.3 (no more big WinAPI.au3).zip
...

As Jpm sent the fix to Jon 9 months ago, then it still doesn't work in beta 3.3.15.3 which was released 1 year ago (re-tested just now) . Patience, it will work again one of these days.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...