Works only under Win2K.



; ########################################
.386
.model flat, stdcall
option casemap :none

; ########################################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

; ########################################

.data
szClassName db "Notepad", 0
szApiName db "SetLayeredWindowAttributes", 0
szDllName db "user32.dll", 0

hwnd dd 0

; ########################################

.code

start:
; open notepad and run this example to make notepad transparent
invoke FindWindow, addr szClassName, 0

mov hwnd, eax

push -20
push eax
invoke GetWindowLong, eax, -20 ; GWL_EXSTYLE

mov edi, eax
mov eax, 80000h ; WS_EX_LAYERED
or eax, edi

invoke SetWindowLong, hwnd, -20, eax

invoke LoadLibrary, addr szDllName

push eax ; for FreeLibrary

invoke GetProcAddress, eax, addr szApiName

push 2h ; LWA_ALPHA
push 0C8h ; transparent level (0-255). 0 = invisible, 255 = visible
push 0
push hwnd
call eax

call FreeLibrary

invoke ExitProcess, 0
end start

; ########################################
Posted on 2001-08-05 04:09:05 by bazik
Since you're already importing things from user32, why not use GetModuleHandle
instead of LoadLibrary/FreeLibrary? And why are you using direct
values (-20, 80000h) instead of their symbolic names?

I'm looking forward to test your code, seems interesting :)
Posted on 2001-08-05 13:15:25 by f0dder
Thank you, Notepad will never be the same. :alright:
It's the little things that mean so much.
Posted on 2001-08-05 15:51:34 by bitRAKE
there's also an detailed transparent window example on Icz's site (under tutorials) by ultraschall:

http://win32asm.rxsp.com/files/laywin.zip
Posted on 2001-08-05 16:11:05 by savage
Here is a funny way to code it:
; ########################################

.386
.model flat, stdcall
option casemap:none
; ########################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
; ########################################

.DATA
szClassName db "Notepad", 0
szApiName db "SetLayeredWindowAttributes", 0
szDllName db "user32.dll", 0

ProStack dd OFFSET szClassName, 0, -20, 0, -20, 80000h
dd OFFSET szDllName, OFFSET szApiName, 0, 0, 196, 2, 0, 0

ProStackSize = ($ - ProStack)/4
; ########################################
.CODE
start:
; open notepad and run this example to make notepad transparent

mov cl, ProStackSize
@@: mov eax, [OFFSET ProStack + ecx*4 - 4]
dec cl
push eax
jne @B

call FindWindow
mov 4[esp],eax
mov 24[esp],eax
push eax
call GetWindowLong
or 8[esp], eax
call SetWindowLong
call LoadLibrary
mov 20[esp], eax
push eax
call GetProcAddress
call eax
call FreeLibrary
call ExitProcess
END start
; ########################################
Posted on 2001-08-05 17:32:17 by bitRAKE
You're mad, bitrake ;)
Posted on 2001-08-05 17:34:56 by f0dder
The only benefit is that programs wrote this way usually compress better, but there is usually more of them to compress. :)
Posted on 2001-08-05 17:42:45 by bitRAKE