Jump to content

Icon on top of background Image


Homes32
 Share

Recommended Posts

Posted Image

as you can see above the transparent portion of the icon shows through the bitmap image and onto the form background on the other side of the background image. is it possible to have the transparent portion of the icon show the background image instead of the form behind it?

thanks.

Homes32

#AutoIt3Wrapper_Res_Icon_Add=Resources\Ico\Run.ico

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3> ; defines $IMAGE_ICON
#include <WinAPI.au3>
Global Const $sFont = "Tahoma"
Global Const $sFontColor = 0xFFFFFF

    ; load icon resources
    $hRunIcon = _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0), 201, $IMAGE_ICON, 48, 48, 0)

    $TaskForm = GUICreate("Running Custom Commands", 300, 65, -1, -1, BitOR($WS_DLGFRAME,$WS_POPUP,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

    $BackgroundImage = GUICtrlCreatePic("TaskBackground.bmp", 0, 0, 300, 65)
    GUICtrlSetState(-1,$GUI_DISABLE)

    $Icon1 = GUICtrlCreateIcon("", -1, 8, 8, 48, 48)
    GUICtrlSendMsg($Icon1, 0x0172, 1, $hRunIcon) ; STM_SETIMAGE = 0x0172 1 = IMAGE_ICON

    $Label1 = GUICtrlCreateLabel("Please wait. some actions are being performed..", 64, 16, 228, 41)
    GUICtrlSetFont(-1, 8.5, 800, 0, $sFont)
    GUICtrlSetColor(-1, $sFontColor)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUISetState(@SW_SHOW)

    Sleep(8000)

    ; cleanup
    GUIDelete($TaskForm)
    If $hRunIcon Then _WinAPI_DestroyIcon($hRunIcon)

ImageAndIcon.zip

Edited by Homes32
Link to comment
Share on other sites

Is this what you wanted?

thank you for the reply!

the concept is what I wanted. the icon is displayed on top of the background image as it should be but I intend to dynamically change the icon and the text to coincide with each task being performed and destroying and rebuilding the image/window all the time is a bit clunky compared to simply using GUICtrlSendMsg().

it seems odd to me that the default behavior of autoit's icon control is to show the back of the window instead of the object directly behind it. is there currently any way to change the icon control's properties so this doesn't happen?

P.S.

by the way. I like your launcher. nice work!

Link to comment
Share on other sites

In that case take a look at this topic, it might be what you want: http://www.autoitscript.com/forum/index.php?showtopic=92675

thank you! that will work for what I need to do.

here is the working code if anybody is interested.

#AutoIt3Wrapper_Res_Icon_Add=Resources\Ico\Run.ico

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3> ; defines $IMAGE_ICON
#include <WinAPI.au3>
#Include <Icons.au3>

Global Const $sFont = "Tahoma"
Global Const $sFontColor = 0xFFFFFF

    ; load icon resources
    $hRunIcon = _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0), 201, $IMAGE_ICON, 48, 48, 0)

    $TaskForm = GUICreate("Running Custom Commands", 300, 65, -1, -1, BitOR($WS_DLGFRAME,$WS_POPUP,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

    $BackgroundImage = GUICtrlCreatePic("TaskBackground.bmp", 0, 0, 300, 65)
    GUICtrlSetState(-1,$GUI_DISABLE)

    ; old icon code
    ;$Icon1 = GUICtrlCreateIcon("", -1, 8, 8, 48, 48)
    ;GUICtrlSendMsg($Icon1, 0x0172, 1, $hRunIcon) ; STM_SETIMAGE = 0x0172 1 = IMAGE_ICON

    ; new working icon code
    $StatusImage = GUICtrlCreatePic("", 8, 8, 48, 48)
    $hBitmap = _Icons_Bitmap_CreateFromIcon($hRunIcon)
    _SetHImage($StatusImage, $hBitmap)


    $Label1 = GUICtrlCreateLabel("Please wait. some actions are being performed..", 64, 16, 228, 41)
    GUICtrlSetFont(-1, 8.5, 800, 0, $sFont)
    GUICtrlSetColor(-1, $sFontColor)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUISetState(@SW_SHOW)

    Sleep(8000)

    ; cleanup
    GUIDelete($TaskForm)
    If $hBitmap Then _WinAPI_DeleteObject($hBitmap)
    If $hRunIcon Then _WinAPI_DestroyIcon($hRunIcon)
Edited by Homes32
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...