Jump to content

Bitmap masking


Recommended Posts

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

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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...