Sign in to follow this  
Followers 0
CodyBarrett

PNG on Label

14 posts in this topic

well i have a grid of labels 64 infact XD and i would like PNG pictures to be set on them... when i try its not working...

does $BS_BITMAP matter for .png?

is there another fileformat that is supported with a transparent background?

GUICtrlsetimage($Control, 'PNG.png') doesn't work at all... simply makes the square blank...

my Labels are Transparent is thats what is making it blank?

do i HAVE to use GDI+ (i would prefer it if i didn't have to even touch that area) to get the Width and Height?

does any one know what i should do? XD

Share this post


Link to post
Share on other sites



You can use Yashied's Icons.au3 library to set the control's image/icon either by a handle to image or by a string representing the path to the file. Make sure that the label control doesn't contain $SS_CENTER style.

Share this post


Link to post
Share on other sites

:| $SS_CENTER is taht screwing it up?

cause my labels style is this

$LStyle = BitOR ($SS_CENTER, $SS_CENTERIMAGE,$BS_BITMAP )

Share this post


Link to post
Share on other sites

..and the fact that GUICtrlSetImage() is not for label controls and that png files are not supported.

Share this post


Link to post
Share on other sites

well... is it possible for a picture to be on a Label?.... or do i have to place a Pics on top of everything cause that would complicate things greatly

Share this post


Link to post
Share on other sites

okay LOL thanks man :) also is there a way to remove the style before setting the image?

Guictrlsetstyle ($Control, '') ? i dunno

Share this post


Link to post
Share on other sites

didn't know about Bitnot!

can't i just go Guictrlsetstate ($Control, Bitor (Bitnot ($SS_CENTER), Bitnot ($SS_CENTERIMAGE))) ?? that would be simpler

BTW i can't test any of this i'm at my cousins house

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

The problem is because I'm lacking enough knowledge of how to get the control style without using the _WinAPI_GetWindowLong() method and it doesn't exposes functionality like:

Func _WinAPI_GetWindowLong($hWnd, $iIndex)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

; ...

You have to get the handle of the control to use this function. Another thing is that I think that AutoIt does the same but ORing the value of the current control style and thus ORing NOT 1 which is 0xFFFFFFFE is useless (sort of controlled assignment..) still not what you need. You can do it using a predefined style variable or something that is ORed with $SS_CENTER where needed.

Edited by Authenticity

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

OMG!!! thank you this is perfect! i actually just had enough time to test it out and WOW thank you lol

EDIT

well it works...

but also.. how do i remove the image so i can guictrlsetdata properly? cause when i remove the image the control won't accept text anymore

Edited by CodyBarrett

Share this post


Link to post
Share on other sites

anyone know how i can remove the image and set some text on it?

Share this post


Link to post
Share on other sites

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Icons.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate('Title', 200, 200)
Global $Label = GUICtrlCreateLabel('', 0, 0, 200, 150)
Global $hLabel = GUICtrlGetHandle($Label)
GUICtrlSetBkColor($Label, 0x602040)
Global $Button = GUICtrlCreateButton('Test', 65, 160, 70, 23)

_SetImage($Label, @ScriptDir & '\circle.png')

AdlibEnable('_Test', 1500)

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $Button
            _WinAPI_SetWindowLong($hLabel, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($hLabel, $GWL_STYLE), BitNOT($SS_BITMAP)))
            GUICtrlSetState($Button, $GUI_DISABLE)
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
AdlibDisable()
GUIDelete()
Exit

Func _Test()
    GUICtrlSetBkColor($Label, Random(0x600000, 0x700000, 1))
EndFunc

After you'll click the button, in the next invocation of the adlib function you won't see the image. Passing anything other that an image handle in the _SetHIMage() function or just sending $STM_SETIMAGE with a value which is not resolves to a bitmap handle will remove the control completely.

Share this post


Link to post
Share on other sites

well what i need is to get rid of the png... then be able to place Text into the now unused Label

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