Make button color-transparent in Windows

222 views Asked by At

I want to create buttons with custom shapes so I decided to do it with the help of Layered Windows. I create window for button, set bitmap for it, make it layered and then try to make white color fully transparent. As soon as I write on masm, the code looks like this:

mov button, rv(CreateWindowEx, WS_EX_APPWINDOW or WS_EX_LAYERED, 
    chr$("Button"), NULL, 
    WS_CHILD or BS_BITMAP or WS_VISIBLE, 
    300, 10, 81, 98, 
    hWin, 200, hInstance, NULL)
mov bmHandle, rv(LoadImage, NULL, bitmapPath, 
    IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE or LR_DEFAULTSIZE)
invoke SendMessage, button, BM_SETIMAGE, IMAGE_BITMAP, eax
invoke SetLayeredWindowAttributes, hWnd, 00000000h, 0, LWA_COLORKEY

But white color on bitmap does not become transparent though it worked with custom window shape for me.

How can I make this work?

0

There are 0 answers