FireFox Posted March 25, 2012 Share Posted March 25, 2012 (edited) Hi, I have got a square picture (ex: 100*100) which is in the background of my gui (ex: 500*500), but the image is stretched if i set the bounds to the gui size. I'm wondering if it's possible to make it repeat in order to fill the gui without resizing the picture like "repeat" style in css. Edit: I don't want to create multiple Pic ctrls to fill the gui (because my gui can be resized) Thanks in advance. Br, FireFox. Edited March 25, 2012 by FireFox Link to comment Share on other sites More sharing options...
UEZ Posted March 25, 2012 Share Posted March 25, 2012 (edited) Try this: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $w = 680 Global Const $h = 710 Global Const $hGUI = GUICreate("Test", $w, $h, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) Global Const $idPic = GUICtrlCreatePic("", 0, 0, $w, $h) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $sImage = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIMerlin.gif") TileImage($sImage, $idPic, $w, $h) Do Until GUIGetMsg() = -3 GUIDelete() _GDIPlus_Shutdown() Exit Func TileImage($sImage, $iControlID, $iWidth, $iHeight, $iWrapMode = 0) ;coded by UEZ 2012 If Not FileExists($sImage) Then Return SetError(1, 0, 0) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) If @error Then Return SetError(2, 0, 0) Local $hTextureBrush = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0) $hTextureBrush = $hTextureBrush[3] Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap = $hBitmap[6] Local $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsFillRect($hCtx, 0, 0, $iWidth, $iHeight, $hTextureBrush) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Local Const $IMAGE_BITMAP = 0 Local Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($iControlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtx) _WinAPI_DeleteObject($hHBitmap) Return 1 EndFunc Br, UEZ Edited March 25, 2012 by UEZ 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 comment Share on other sites More sharing options...
FireFox Posted March 25, 2012 Author Share Posted March 25, 2012 @UEZ Thanks! I was not expecting less from you Br, FireFox. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now