Sign in to follow this  
Followers 0
rliiack

Transparency on Bitmap

6 posts in this topic

I've search the forum and saw the transparency on png file and know that I can use _WinAPI_SetLayeredWindowAttributes to make it partially transparent. I am wondering if I can do the same thing to bitmap images.


My Projects:Smart Icons

Share this post


Link to post
Share on other sites



Oh... That works too, thanks. The first example I saw uses _WinAPI_SetLayeredWindowAttributes. So my problem now becomes, how to treat a bitmap image as a window?


My Projects:Smart Icons

Share this post


Link to post
Share on other sites

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>

$hForm = GUICreate('', 600, 400, -1, -1, $WS_POPUP)
$Pic = GUICtrlCreatePic('', -400, -250, 1024, 768, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState()

InetGet('http://dota.ru/3d/big/p324_42.jpg', @TempDir & '\~test.jpg')
GUICtrlSetImage($Pic, @TempDir & '\~test.jpg')
FileDelete(@TempDir & '\~test.jpg')

WinSetTrans($hForm, '', 200)

Do
Until GUIGetMsg() = -3

Share this post


Link to post
Share on other sites

Thanks! I was also wondering about only transparenting part of an image. Is it possible to do it with WinSetTrans() too?


My Projects:Smart Icons

Share this post


Link to post
Share on other sites

No, there is no simple way. Here's one way.

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>

GUIRegisterMsg($WM_MOVE, 'WM_MOVE')

$Form1 = GUICreate('', 600, 400, 200, 200, $WS_POPUP)
$Pic1 = GUICtrlCreatePic('', -400, -250, 1024, 768, -1, $GUI_WS_EX_PARENTDRAG)
$Form2 = GUICreate('', 300, 400, 500, 200, $WS_POPUP)
$Pic2 = GUICtrlCreatePic('', -700, -250, 1024, 768, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $Form2)

InetGet('http://dota.ru/3d/big/p324_42.jpg', @TempDir & '\~test.jpg')
GUICtrlSetImage($Pic1, @TempDir & '\~test.jpg')
GUICtrlSetImage($Pic2, @TempDir & '\~test.jpg')
FileDelete(@TempDir & '\~test.jpg')

WinSetTrans($Form1, '', 140)

Do
Until GUIGetMsg() = -3

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $Form1
            WinMove($Form2, '', BitAND($lParam, 0xFFFF), BitShift($lParam, 16))
        Case $Form2
            WinMove($Form1, '', BitAND($lParam, 0xFFFF) - 300, BitShift($lParam, 16))
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE

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