Jump to content
Sign in to follow this  
Ed_Maximized

_GUICreateWithTiledBackground

Recommended Posts

Ed_Maximized

This litte script creates a form and sets a gif image tiled in background...

I put an example gif but any works ok!!!

This is:

#include <GUIConstants.au3>
$gif=FileOpenDialog("Select a GIF file",@ScriptDir,"GIF files (*.gif)")
$tiles = _GUICreateWithTiledBackground($gif, 640, 400)
GUICtrlCreateLabel("Test Label:", 48, 72, 57, 17)
$Input1 = GUICtrlCreateInput("", 112, 72, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("Test Button", 432, 312, 105, 33)
GUISetState(@SW_SHOW,$tiles)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _GUICreateWithTiledBackground($sPic, $guiW, $guiH) ;$sPic MUST be Gif
    $GuiWH=GUICreate("Tiles Example", $guiW, $guiH)
    Local $tileW,$tileH
    _GetGifPixWidth_Height($sPic, $tileW, $tileH)
    Local $iTilesX = Round($guiW / $tileW)
    Local $iTilesY = Round($guiH / $tileH)
    ConsoleWrite($iTilesX&","&$iTilesY)
    Local $x = 0, $y = 0
    For $i = 0 To $iTilesX
        For $ii = 0 To $iTilesY
            GUICtrlCreatePic($sPic, $i*$tileW, $ii*$tileH, $tileW, $tileH)
            GUICtrlSetState(-1, $GUI_DISABLE)
        Next
    Next
    Return $GuiWH
EndFunc   ;==>_GUICreateWithTiledBackground

Func _GetGifPixWidth_Height($s_gif, ByRef $pwidth, ByRef $pheight) ;Thanks to gafrost
    If FileGetSize($s_gif) > 9 Then
        Local $sizes = FileRead($s_gif, 10)
        ConsoleWrite("Gif version: " & StringMid($sizes,1,6) & @LF)
        $pwidth = Asc(StringMid($sizes, 8, 1)) * 256 + Asc(StringMid($sizes, 7, 1))
        $pheight = Asc(StringMid($sizes, 10, 1)) * 256 + Asc(StringMid($sizes, 9, 1))
        ConsoleWrite($pwidth & " x " & $pheight & @LF)
    EndIf
EndFunc   ;==>_GetGifPixWidth_Height

post-12557-1161969056_thumb.gif

Hasta la vista!

Some code is from others... I just take the pieces together... :whistle:

Special thanks to jpam and razerm

Ed

Edited by Ed_Maximized

Share this post


Link to post
Share on other sites
_Kurt

Lovin' your work, Ed. This could make programs look more professional and create better effects. Another great script by Ed :whistle:

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites
Ed_Maximized

Usually a good idea to put the Header with the function from other peoples scripts

@gafrost: Sorry!!! :"> I've used your function so many times... this is the first time I don´t give you the credits!!! Corrected

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  

×