behdadsoft Posted June 7, 2018 Share Posted June 7, 2018 (edited) Hi. I want change tab image and for do this, i found this example that work very well but it don't work on .png files. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiTab.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Tab Control Set Item Image", 400, 300) Local $idTab = GUICtrlCreateTab(2, 2, 396, 296) Local $hImageList = _GUIImageList_Create(50, 20) Local $aImages[4] For $i = 0 To 3 ; Load the GDI+ bitmap Local $hBitmapTmp = _GDIPlus_BitmapCreateFromFile("Tab" & $i & ".jpg") ; Conver the GDI+ bitmap to a HBitmap $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapTmp) ; Get rid of the GDI+ bitmap _GDIPlus_BitmapDispose($hBitmapTmp) ; Add the HBitmap to the image list _GUIImageList_Add($hImageList, $aImages[$i]) Next _GUICtrlTab_SetImageList($idTab, $hImageList) For $i = 0 To 3 _GUICtrlTab_InsertItem($idTab, $i, "") _GUICtrlTab_SetItemImage($idTab, $i, $i) Next GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ; Dispose of the HBitmap objects properly For $i = 0 To 3 _WinAPI_DeleteObject($aImages[$i]) Next EndFunc ;==>Example https://www.autoitscript.com/forum/topic/185596-adding-images-to-tab/ I have seen some expamle for add png image to GUI and Button, but them won't work for TabItem. dose anyone know how can use .png file? Edited June 10, 2018 by behdadsoft Link to comment Share on other sites More sharing options...
behdadsoft Posted June 8, 2018 Author Share Posted June 8, 2018 any idea? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 8, 2018 Moderators Share Posted June 8, 2018 behdadsoft, Please do not bump your own threads within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AutoBert Posted June 8, 2018 Share Posted June 8, 2018 (edited) 4 hours ago, behdadsoft said: any idea? Yes just change a little and your linked example works: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiTab.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Tab Control Set Item Image", 400, 300) Local $idTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296, BitOR($TCS_FORCEICONLEFT, $TCS_FIXEDWIDTH)) Local $hImageList = _GUIImageList_Create(20, 20) ;don't change size of images Local $aImages[4] Local $sAutoItPath = StringReplace(StringReplace(@AutoItExe, '_x64', ''), 'autoit3.exe', '') For $i = 0 To 2 ; Load the GDI+ bitmap $sPNG_Path = $sAutoItPath & "Include\autoit-winhttp-1.6.3.8\Images\fwd" & $i & ".png" Local $hBitmapTmp = _GDIPlus_BitmapCreateFromFile($sPNG_Path) ConsoleWrite($sPNG_Path & ':' & @TAB & $hBitmapTmp & @TAB & @error & @CRLF) ; Conver the GDI+ bitmap to a HBitmap $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapTmp) ; Get rid of the GDI+ bitmap _GDIPlus_BitmapDispose($hBitmapTmp) ; Add the HBitmap to the image list _GUIImageList_Add($hImageList, $aImages[$i]) Next _GUICtrlTab_SetImageList($idTab, $hImageList) For $i = 0 To 2 _GUICtrlTab_InsertItem($idTab, $i, $i) _GUICtrlTab_SetItemImage($idTab, $i, $i) Next GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ; Dispose of the HBitmap objects properly For $i = 0 To 3 _WinAPI_DeleteObject($aImages[$i]) Next EndFunc ;==>Example Edited June 8, 2018 by AutoBert Link to comment Share on other sites More sharing options...
behdadsoft Posted June 8, 2018 Author Share Posted June 8, 2018 @AutoBert This code have same result with my linked example. Mean it make a white background under png text and i need remove it. Link to comment Share on other sites More sharing options...
AutoBert Posted June 8, 2018 Share Posted June 8, 2018 My script works: Original is #2 in your link, that the images have a white background is a behaviour of the control. Important: all sizes of the images*.png and the size in the Imagelist must the same. Also the Style attributes: BitOR($TCS_FORCEICONLEFT, $TCS_FIXEDWIDTH) by creating the Tabcontrol are helpfull, maybe there's a better combination. Link to comment Share on other sites More sharing options...
behdadsoft Posted June 8, 2018 Author Share Posted June 8, 2018 (edited) Quote Important: all sizes of the images*.png and the size in the Imagelist must the same Yes, They are. This code don't work correctly because In your image, you have white background under square arrows. png image should be completely transparent. Edited June 8, 2018 by behdadsoft Link to comment Share on other sites More sharing options...
AutoBert Posted June 9, 2018 Share Posted June 9, 2018 17 hours ago, behdadsoft said: This code don't work correctly because In your image, you have white background under square arrows. png image should be completely transparent. My used images are transparent but as already sayed: 17 hours ago, AutoBert said: that the images have a white background is a behaviour of the control. Sorry for miss understanding On 7.6.2018 at 11:22 PM, behdadsoft said: I have seen some expamle for add png image to GUI and Button, but them won't work for TabItem. But you can test: in OwnTab.au3 (the UDF) you must change #19: from: Opt("OnExitFunc", "_OwnTab_OnExit") to OnAutoItExitRegister("_OwnTab_OnExit") and in #483 $ghGDIPDll must no named $__g_hGDIPDll. Link to comment Share on other sites More sharing options...
behdadsoft Posted June 9, 2018 Author Share Posted June 9, 2018 I have seen OwnTab.au3 before, but thanks for fix errors. Unfortunately, it only work with icon and not image. Link to comment Share on other sites More sharing options...
AutoBert Posted June 9, 2018 Share Posted June 9, 2018 5 hours ago, behdadsoft said: I have seen OwnTab.au3 before, but thanks for fix errors. The errors are the result of script breaking changes. In 2009, as @funkey has createted the script, the script runs. 5 hours ago, behdadsoft said: Unfortunately, it only work with icon and not image. I haven't tried but i think when you uses a tool which creates a DLL and pack there your png-files (renamed to .ico?) owntab will work. behdadsoft 1 Link to comment Share on other sites More sharing options...
behdadsoft Posted June 10, 2018 Author Share Posted June 10, 2018 Quote I haven't tried but i think when you uses a tool which creates a DLL and pack there your png-files (renamed to .ico?) owntab will work. Incidentally, I also thought that I would put my files in an dll file. But, I have to test this. And thanks for tried to help me. Link to comment Share on other sites More sharing options...
InnI Posted June 10, 2018 Share Posted June 10, 2018 @behdadsoft Try to create ImageList with 32 bit color depth (third parameter = 5) Local $hImageList = _GUIImageList_Create(50, 20, 5) behdadsoft and AutoBert 1 1 Link to comment Share on other sites More sharing options...
behdadsoft Posted June 10, 2018 Author Share Posted June 10, 2018 32 minutes ago, InnI said: @behdadsoft Try to create ImageList with 32 bit color depth (third parameter = 5) Local $hImageList = _GUIImageList_Create(50, 20, 5) Thanks InnI. work very well. 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