Jump to content

PNG on Label


Recommended Posts

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

Link to comment
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 )

Link to comment
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

Link to comment
Share on other sites

Yes, perfectly valid and it's also very nice that you have the Icons.au3 UDF.

#include <Icons.au3>

Dim $hGUI = GUICreate('', 200, 200)
Dim $Label = GUICtrlCreateLabel('', 0, 0, 200, 200) ; Try once when $SS_CENTER is specified and watch the difference.

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

GUISetState()
Do
Until GUIGetMsg() = -3
GUIDelete()
Exit
Link to comment
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

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...