Jump to content
Sign in to follow this  

GUICtrlCreatePic width and heigh...

Recommended Posts

I'm trying to recreate something akin to the Windows XP picture browser for an old windows 98 laptop. I'm going to be giving the laptop to an older relative along with some CDs with lots of pictures. I'll have this program auto run when said relative puts in the CD. I thought this would just be a really simple way for the person to view pictures with as few options as possible.

The problem i'm having is, how can i base the picture control's width and height on the actual width and height of the pictures being displayed?

Below is the code so that you can get some idea of what i'm trying to do. At the moment all i care about is functionality so you'll have to excuse the crudeness.

#include <GUIConstants.au3>
#Include <File.au3>
#Include <Array.au3>
$FileList = _FileListToArray ( @ScriptDir , "*.jpg" , 1 )
$width = @DesktopWidth * .9
$height = @DesktopHeight * .85
$picIndex = 1;
$TotalPics = $FileList[0];

Opt("GUIOnEventMode", 1)
$mainWindow = GUICreate("Auto-Screenshot GUI", $width, $height)

;GUI Components
$btnPrev = GUICtrlCreateButton("Previous", ($width/2)+95, $height-30, 75)
$btnNext = GUICtrlCreateButton("Next", ($width/2)-170, $height-30, 75)
$btnSetBG = GUICtrlCreateButton("Set as Background", ($width/2)-75, $height-30, 150)
$btnExit = GUICtrlCreateButton("Exit", $width-75, $height-30, 50)
if $TotalPics > 0 Then
    $picImageBox = GUICtrlCreatePic ( $FileList[1], 30, 30 ,$width*.85 ,$height*.85,$SS_CENTERIMAGE )

GUICtrlSetOnEvent($btnExit, "CLOSEClicked")
GUICtrlSetOnEvent($btnNext, "NextClicked")
;infinite loop to keep the GUI active. (without this the program will just close.)
While 1
    Sleep(1000)  ; Idle around

;function to Exit
Func CLOSEClicked()

;function to go to the next picture in the array
Func NextClicked()
    if($picIndex<$TotalPics) Then
        $picIndex = $picIndex + 1;
        GUICtrlSetImage ($picImageBox, $FileList[$picIndex])
        MsgBox(1,"End of Pictures", "you have reached the end of the pictures")

Share this post

Link to post
Share on other sites

You just want to be able to retrieve the image's width/height, correct?

Check out this little function:

#Include <GDIPlus.au3>

Func _GetImageDimensions($sFileName)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
    Local $aDimensions[2] = [ $iWidth, $iHeight ]
    Return $aDimensions
EndFuncoÝ÷ ØéåÊÜ(¦ºé¬Â+a¶¬Ôýz-²êÞñ ùn²+¢jZ¶&å{­h§÷Ê+Êkzǧµ¼yö®Ü¨ºf²ç¶§²Ö¥+G¢ºYr²¢w¦¢·¤%yØnW°YlµêbÚÆZ{ajÝ*.zwn¦ë"§Êíê-êÆeºÇîËb¢{2¢íýÛh¦ée¶µªíºÒë]£   åw¬¢ëh~Øb±û§rب©Ý¦VzØ^)梷¦è¦¸µêeiǬ6^";¬¶·vØb²)íá ùn±+Z®Û©v*º^2>­ê®·¬j·Ëk»­i¹^~Ú¦bq«b¢{-«kºz'¶Êè²íZ)Ý£
O?¥¢Ú0³m4ѵ¢Ú0³ß?m©ÝZ)Ý£z^­«b2²×¦³ú®¢×Ø­ý²n²Ü!^vØb²êb·ljz-êߺw-í«]¡ë'ßÛn±á";¬¶Ø^n襶)ÆP-¹÷áë'ßÛp¢¹¢·âër¥ë'¢ÙÚ¶+Þ+.¦+µç[ÊØ^ëh"Ñ"ØhºZºÚ"µÍ[ÈÑÙ][XYÙQ[Y[Ú[ÛÊ  ÌÍÜÑ[S[YJBSØØ[    ÌÍÚÝZHHÕRPÜX]J    ÌÎNÉÌÎNÊBSØØ[   ÌÍÚXÈHÕRPÝÜX]TXÊ    ÌÍÜÑ[S[YK
Edited by Saunders

Share this post

Link to post
Share on other sites

I believe it was Lazycat that wrote up some functions to diff. types of file width/height.

I did one for gif's, don't remember if I did any for other formats.

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


Share this post

Link to post
Share on other sites

Only two problems with this:

1) I'm not sure if GDI Plus is compatible with Win98, or is present by default, you may need to install it. Hopefully someone more knowledgable will step in to explain that..

On WIN98 you must install Platform SDK Redistributable GDI+ --> gdiplus_dnld.exe (1MB).

Here is Microsoft link

I use it on my WIN98 with no problems.

Edited by Zedna

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  

  • Create New...