Sign in to follow this  
Followers 0
Mat

Bitmap masking

4 posts in this topic

#1 ·  Posted (edited)

First I get the icon from a window (the GUI in this test) then I add it to a menu.

#include<WinApi.au3>
#include<SendMessage.au3>
#include<WindowsConstants.au3>
#include<GUIMenu.au3>

; WinUser.h constant for GetClassLong
Global Const $GCL_HICONSM = -34

$hGUI = GUICreate("test window")

GUISetState()

$hIcon = _GetClassLong($hGUI, $GCL_HICONSM)
$avIconInfo = _WinAPI_GetIconInfo($hIcon)
$hMask = $avIconInfo[4]
$hBmp = $avIconInfo[5]

$hMenu = _GUICtrlMenu_CreatePopup()
$i = _GUICtrlMenu_AddMenuItem($hMenu, "test item")
_GUICtrlMenu_SetItemBmp($hMenu, $i, $hBmp)

DllCall("user32.dll", "int", "SetForegroundWindow", "hwnd", $hGUI)
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI, -1, -1, 1, 1, 2, 1)

_WinAPI_DeleteObject($hBmp)
_WinAPI_DeleteObject($hMask)
_GUICtrlMenu_DestroyMenu($hMenu)

Func _GetClassLong($hWnd, $i)
    Local $aRet = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hWnd, "int", $i)
    If (@error) Or (Not $aRet[0]) Then Return SetError(1, 0, 0)

    Return $aRet[0]
EndFunc   ;==>_WinAPI_GetClassLong

When I use the bitmap on its own it has a black background (no surprises there), but looking at msdn it seems there is not a simple way to combine bitmap and mask. I want to be able to use the bitmap (and mask) ideally without having to draw it myself. The only examples are all drawing it to a device cap.

Any ideas? Thanks :mellow:

Mat

Edited by Mat

Share this post


Link to post
Share on other sites



* knock against with force or violence; "My car bumped into the tree"

* find: come upon, as if by accident; meet with; "We find this idea in Plato"; "I happened upon the most wonderful bakery not very far from here"; "She chanced upon an interesting book in the bookstore the other day"

* dance erotically or dance with the pelvis thrust forward; "bump and grind"

* a lump on the body caused by a blow

* demote: assign to a lower position; reduce in rank; "She was demoted because she always speaks up"; "He was broken down to Sergeant"

* bulge: something that bulges out or is protuberant or projects from its surroundings; "the gun in his pocket made an obvious bulge"; "the hump of a camel"; "he stood on the rocky prominence"; "the occipital protuberance was well developed"; "the bony excrescence between its horns"

* dislodge: remove or force from a position of dwelling previously occupied; "The new employee dislodged her by moving into her office space"

* blow: an impact (as from a collision); "the bump threw him off the bicycle"

Share this post


Link to post
Share on other sites

I don't know what you mean but maybe _WinAPI_BitBlt() is something for you (check out $iROP parameters)!

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I don't know what you mean but maybe _WinAPI_BitBlt() is something for you (check out $iROP parameters)!

BR,

UEZ

That is what I've found. but it's the dc's I don't like the smell of.

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