x_bennY Posted January 24, 2018 Share Posted January 24, 2018 (edited) I'm writing a script that reads from a packed file some images and put in a control, the problem is that it dosn't fit in the control(dosn't resizes)... i'm attaching the source. press the button "Testes" to see what i'm talking about. thx! packer.rar Edited January 24, 2018 by x_bennY Link to comment Share on other sites More sharing options...
UEZ Posted January 24, 2018 Share Posted January 24, 2018 Try this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <WinAPIEx.au3> #include <array.au3> #include <Memory.au3> #include <GDIPlus.au3> #Include "Package.au3" ;~ Opt('MustDeclareVars', 1) Global Const $sPackage = @ScriptDir & '\data.pkr' Global $hPackage, $ID, $File #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 694, 420, 613, 326) $Button1 = GUICtrlCreateButton("PACK!", 16, 344, 107, 65) $Button2 = GUICtrlCreateButton("Display Packege", 129, 344, 107, 65) $Button3 = GUICtrlCreateButton("Testes", 244, 344, 107, 65) $Button4 = GUICtrlCreateButton("Button1", 360, 344, 107, 65) $Pic1 = GUICtrlCreatePic("", 8, 8, 172, 140, BitOR($SS_CENTERIMAGE, $SS_SUNKEN)) $Pic2 = GUICtrlCreatePic("", 189, 8, 172, 140, $SS_CENTERIMAGE) $Label1 = GUICtrlCreateLabel("Label1", 16, 224, 100, 17) $Label2 = GUICtrlCreateLabel("Label2", 16, 240, 100, 17) $Label3 = GUICtrlCreateLabel("Label3", 16, 256, 100, 17) $Label4 = GUICtrlCreateLabel("Label4", 168, 224, 100, 17) $Label5 = GUICtrlCreateLabel("Label5", 168, 240, 100, 17) $Label6 = GUICtrlCreateLabel("Label6", 168, 256, 100, 17) $Edit1 = GUICtrlCreateEdit("", 496, 16, 185, 161) GUICtrlSetData(-1, "Edit1") $Edit2 = GUICtrlCreateEdit("", 499, 187, 185, 161) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists($sPackage) Then $hPackage = _PK_Create($sPackage, 'Glorifica') Else $hPackage = _PK_Open($sPackage) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 local $fulldir = "" $File = FileOpenDialog('Add File', @WorkingDir, 'All Files (*.*)', $FD_FILEMUSTEXIST + $FD_PATHMUSTEXIST + $FD_MULTISELECT) $split = stringsplit($File, "|") for $i = 2 to $split[0] ;1 = dir $fulldir = $split[1]&"\"&$split[$i] $ID = _PK_AddPacketFromFile($hPackage, $fulldir, _WinAPI_PathStripPath($fulldir)) If @Error Then $ID = MsgBox(20, 'Package', 'An error occurred while adding file to the package.' & @CR & @CR & 'Error: ' & @Error & @CR & @CR & 'Do you want to add another file?') Else ;~ $ID = MsgBox(68, 'Package', 'File added successfully.' & @CR & @CR & 'ID: ' & $ID & @CR & @CR & 'Do you want to add another file?') consolewrite("adding: "&$ID&@CRLF) EndIf next case $button2 _PK_DisplayPackage($hPackage) _PK_Close($hPackage) case $button3 Local $hTimer3 = TimerInit() Local $dif3 Local $pak_ID3 = _PK_GetPacketID($hPackage, 4) Local $tData3 = DllStructCreate('byte[' & _PK_GetPacketDataLength($hPackage, $pak_ID3) & ']') _PK_ExtractPacketData($hPackage, $pak_ID3, DllStructGetPtr($tData3), DllStructGetSize($tData3)) $dif3 = timerdiff($hTimer3) ;the magic part ;-) _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromMemory(DllStructGetData($tData3, 1)) $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, 172, 140) $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Resized) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Resized) _GDIPlus_Shutdown() _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap_GDI)) _WinAPI_DeleteObject($hBitmap_GDI) guictrlsetdata($label3, timerdiff($hTimer3)) EndSwitch WEnd x_bennY 1 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...
x_bennY Posted January 24, 2018 Author Share Posted January 24, 2018 awesome as always! thx @UEZ! 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