The MASM Forum

General => The Campus => Topic started by: hfheatherfox07 on May 29, 2012, 05:37:16 AM

Title: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on May 29, 2012, 05:37:16 AM
Hi I have found this thread
http://www.asmcommunity.net/board/index.php?topic=5215.0
and It says:

Code: [Select]
(a) WS_EX_TRANSPARENT
Quote

    Specifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted



Combined with (b): CS_PARENTDC
Quote

    Sets the clipping rectangle of the child window to that of the parent window so that the child can draw on the parent. A window with the CS_PARENTDC style bit receives a regular device context from the system's cache of device contexts. It does not give the child the parent's device context or device context settings. Specifying CS_PARENTDC enhances an application's performance



Were do I put the CS_PARENTDC and also do I have to use WM_PAINT ?
see attachment
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on May 29, 2012, 07:08:18 AM
CS_ is the prefix for class styles
when you register the window class, it goes in the WNDCLASSEX.style member

if you want to have some fun, set the WNDCLASSEX.hbrBackground member to 0   :P
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on May 31, 2012, 08:31:43 AM
weird I did not get email notification for this replay ...how do I change that .....?
I have my notification on .....it says that I do get them ....but I don't  :(

@dedndave I will try this tonight
Title: Re: A window with a TRANSPARENT client area
Post by: qWord on May 31, 2012, 09:14:34 AM
For windows Vista and newer, DwmEnableBlurBehindWindow() is an easy way to add an alpha cannel to a window (see attachment).
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 11:21:33 AM
For windows Vista and newer, DwmEnableBlurBehindWindow() is an easy way to add an alpha cannel to a window (see attachment).

Windows XP here LOL  ::)
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 11:22:39 AM
I don't think I am doing this right


Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 02, 2012, 11:33:28 AM
you certainly are not - lol

you do not want to create a window inside the WM_PAINT handler   :icon_eek:

also - when you set the class backgorund to a system color, use XXXXX+1
Code: [Select]
mov   wc.hbrBackground,COLOR_BTNFACE+0  ; COLOR_WINDOW + 9i.e., if you want it to be COLOR_BTNFACE, use COLOR_BTNFACE+1
that method is only valid for the first 19 system colors
Code: [Select]
;COLOR_SCROLLBAR               EQU 0
;COLOR_BACKGROUND              EQU 1
;COLOR_ACTIVECAPTION           EQU 2
;COLOR_INACTIVECAPTION         EQU 3
;COLOR_MENU                    EQU 4
;COLOR_WINDOW                  EQU 5
;COLOR_WINDOWFRAME             EQU 6
;COLOR_MENUTEXT                EQU 7
;COLOR_WINDOWTEXT              EQU 8
;COLOR_CAPTIONTEXT             EQU 9
;COLOR_ACTIVEBORDER            EQU 10
;COLOR_INACTIVEBORDER          EQU 11
;COLOR_APPWORKSPACE            EQU 12
;COLOR_HIGHLIGHT               EQU 13
;COLOR_HIGHLIGHTTEXT           EQU 14
;COLOR_BTNFACE                 EQU 15
;COLOR_BTNSHADOW               EQU 16
;COLOR_GRAYTEXT                EQU 17
;COLOR_BTNTEXT                 EQU 18

if you set it to 0 or NULL, then you are responsible for handling WM_ERASEBKGND
if you want to use some other system color, use GetSysColor and CreateSolidBrush
if you use the later method, DeleteObject is required when done
Code: [Select]
;COLOR_INACTIVECAPTIONTEXT     EQU 19
;COLOR_BTNHIGHLIGHT            EQU 20
;COLOR_3DDKSHADOW              EQU 21
;COLOR_3DLIGHT                 EQU 22
;COLOR_INFOTEXT                EQU 23
;COLOR_INFOBK                  EQU 24
;                                                     ;wonder what happened to 25 ;)
;COLOR_HOTLIGHT                EQU 26
;COLOR_GRADIENTACTIVECAPTION   EQU 27
;COLOR_GRADIENTINACTIVECAPTION EQU 28
;COLOR_MENUHILIGHT             EQU 29                 ;not supported under Win 2000
;COLOR_MENUBAR                 EQU 30                 ;not supported under Win 2000
;
;Additional System Color Aliases
;
;COLOR_3DHIGHLIGHT             EQU COLOR_BTNHIGHLIGHT ;20
;COLOR_3DHILIGHT               EQU COLOR_BTNHIGHLIGHT ;20
;COLOR_BTNHILIGHT              EQU COLOR_BTNHIGHLIGHT ;20
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 12:07:02 PM
Well OK .... I am more concerned with creating a transparent client area :(
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 02, 2012, 12:10:36 PM
well - i tried what that guy suggested - and it didn't work out too well, for me - lol

the whole window is transparent - i can see it come up, minimize, etc
but, once it gets where it's going, it is like watching the invisible man

msdn gives some code, too
http://msdn.microsoft.com/en-us/library/ms997507.aspx (http://msdn.microsoft.com/en-us/library/ms997507.aspx)
i had about as much luck, there
but - i didn't really spend a lot of time on it
i am sure i could make it work if i fiddled with it a bit
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 12:13:47 PM
I ran into the same problem ......
I have seen it done with masm so I know it is possible ....

by the way still no email notifications of reply
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 02, 2012, 12:16:49 PM
check the profile setting - check your forum e-mail addy
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 02, 2012, 12:35:39 PM
here we go...

(http://img715.imageshack.us/img715/8638/trany.png)

notice where the WS_EX style flag goes   :biggrin:
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 12:49:28 PM
I am confused by that .... I don't want to make the whole window transparent just the client area or a static ....there is so much easier ways to do just that .... don't need
Code: [Select]
.ELSEIF uMsg == WM_PAINT
invoke BeginPaint,hWnd,addr ps




invoke EndPaint,hWnd,addr ps
xor eax,eax

.ELSEIF uMsg==WM_ERASEBKGND
mov eax,TRUE

I was only using that to try to do only the client area or a static transparent
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 02, 2012, 12:51:29 PM
check the profile setting - check your forum e-mail addy

that is ...but still no notifications  :(
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 02, 2012, 01:21:23 PM
Code: [Select]
.ELSEIF uMsg == WM_PAINT
invoke BeginPaint,hWnd,addr ps




invoke EndPaint,hWnd,addr ps
xor eax,eax

.ELSEIF uMsg==WM_ERASEBKGND
mov eax,TRUE

yah - i was messing around, there
if you erase the background, you are supposed to return TRUE
as for paint - BeginPaint/EndPaint validates the rectangle
if you answer WM_PAINT, you have to validate one way or another

as for the transparency - you have to play with the rectangles
read that document i linked at msdn
they had some info
you can set the opacity of the non-client area to "showing"
then set a rectangle for the client area to transparent
it might work   :P
Title: Re: A window with a TRANSPARENT client area
Post by: MichaelW on June 02, 2012, 04:24:58 PM
There is some related information here:

http://www.mvps.org/user32/gditutorial.html

But in the short time I had to experiment with it, I could not make it work.


Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 04, 2012, 08:26:22 AM
There is some related information here:

http://www.mvps.org/user32/gditutorial.html

But in the short time I had to experiment with it, I could not make it work.

the last example there might work but it is in C too bad that was not in ASM

Originally I wanted this for the window 7 skin that I posted in the old masm form

http://masm32.com/forum_archive/index3df6.html?topic=18823.0

here is an example  that might do it that I got from ragdog
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 04, 2012, 11:34:19 AM
converting C to ASM usually isn't that bad   :P

in C...
Code: [Select]
    hSysMenu = GetSystemMenu( hWnd, FALSE );
    AppendMenu( hSysMenu, MF_SEPARATOR, 0, 0 );

in ASM...
Code: [Select]
        INVOKE  GetSystemMenu,hWnd,FALSE
        mov     hSysMenu,eax
        INVOKE  AppendMenu,hSysMenu,MF_SEPARATOR, 0, 0
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 04, 2012, 12:49:28 PM
This is really starting to make me mad ...no email notifications  :(
Title: Re: A window with a TRANSPARENT client area
Post by: dedndave on June 04, 2012, 12:55:55 PM
take a deep breath, Heather   :biggrin:
Title: Re: A window with a TRANSPARENT client area
Post by: hfheatherfox07 on June 04, 2012, 01:15:31 PM
maybe hutch can log in to my account and see what is wrong ...
till than I will try those png examples