mIRC Home    About    Download    Register    News    Help

Print Thread
Transparent windows using Com DLL #182301 07/08/07 04:55 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
Hi, I'm trying to make a DLL that makes the windows in mIRC transparent.

I'm using the following code:

Code:
Option Explicit

Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private mDDEName  As String

Public Function ChangeTrans(ByVal phwnd As Long, pTransLevel As Long) As Long
    Dim lRes    As Long
    Dim Ret     As Long
    'Set the window style to 'Layered'
    Ret = GetWindowLong(phwnd, GWL_EXSTYLE)
    Ret = Ret Or WS_EX_LAYERED
    SetWindowLong phwnd, GWL_EXSTYLE, Ret
    lRes = SetLayeredWindowAttributes(phwnd, 0, pTransLevel, LWA_ALPHA)
    ChangeTrans = lRes
End Function


This code works greate on other forms/window that I make using VB, but as soon is I sent this function the hWnd of one of the windows in mIRC I get:

1) GetWindowLong(phwnd, GWL_EXSTYLE) return 320
2) lRes = SetLayeredWindowAttributes(phwnd, 0, pTransLevel, LWA_ALPHA) returns 0 (which means that it failed)

What am I missing?
(The hWnd I get using $window(@window_name).hwndv , shouldn't the code be working?)


Yeah, I know that there are already DLLs that do it, but I want to code it by myself.(if you can call it that)

Thanks


Re: Transparent windows using Com DLL [Re: Dr_Brom_sung_] #182309 07/08/07 07:00 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
What is the v in $window(@window_name).hwndv there for?

Shouldn't that be $window(@window_name).hwnd?

Re: Transparent windows using Com DLL [Re: SladeKraven] #182312 07/08/07 07:45 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
The v is just a typo when typing the command here. In real life it is without the v.

I even tried to call the DLL using an exe I have created in VB where I put the number (the window handle). When I put a number of regular VB window then it works.

When I put the number I got from the $window command then it doesn't work.

Last edited by Dr_Brom_sung_; 07/08/07 07:47 PM.
Re: Transparent windows using Com DLL [Re: Dr_Brom_sung_] #182438 09/08/07 04:31 PM
Joined: Sep 2003
Posts: 32
O
Ook Offline
Ameglian cow
Offline
Ameglian cow
O
Joined: Sep 2003
Posts: 32
WS_EX_LAYERED (& thus SetLayeredWindowAttributes()) can't be used on a child window.

From the msdn:
WS_EX_LAYERED
Windows 2000/XP: Creates a layered window. Note that this cannot be used for child windows. Also, this cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.

Re: Transparent windows using Com DLL [Re: Ook] #182448 09/08/07 05:55 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
Ok... Too bad.

10x