Sign in to follow this  
Followers 0
phish3r

GUICtrlCreatePic width and heigh...

4 posts in this topic

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 )
    GuiCtrlSetColor(-1,0xffffff)
EndIf

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

;function to Exit
Func CLOSEClicked()
    Exit
EndFunc

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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)
    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
    Local $aDimensions[2] = [ $iWidth, $iHeight ]
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    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
BSØØ[ ÌÍØTÚ^HHÛÛÛÙ]ÜÊ   ÌÍÚÝZK  ÌÎNÉÌÎNË  ÌÍÚXÊBIÌÍØTÚ^VÌHH  ÌÍØTÚ^VÌBIÌÍØTÚ^VÌWHH ÌÍØTÚ^VÌ×BTQ[H    ÌÍØTÚ^VÌBQÕRPÝ[]J    ÌÍÚXÊBQÕRQ[]J  ÌÍÚÝZJBT]   ÌÍØTÚ^B[[
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

#4 ·  Posted (edited)

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  
Followers 0