News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Menu Start transparency problem

Started by Guybrush, October 31, 2008, 05:49:43 PM

Previous topic - Next topic

Guybrush

I'm trying to do a simple APP that set a transparency level to Menu Start of XP

the code is really simple :

.data
MenuStartClass db "DV2ControlHost",0
hMenuStart     dd 0
...
invoke FindWindow, ADDR MenuStartClass, NULL
mov hMenuStart,eax
invoke GetWindowLong,hMenuStart,GWL_EXSTYLE
or eax,WS_EX_LAYERED
invoke SetWindowLong,hMenuStart,GWL_EXSTYLE,eax
invoke SetLayeredWindowAttributes,hMenuStart,0,200,LWA_ALPHA

This code works just when i run it in normal way... The problem start when I try to put the program in automatic execution. Windows start but when I try to click over Start Button the Menu Start is almost all transparency except the height border that remain black as it have not been draw... maybe someone have already found a solution for this or could give me some tip to prevent or solve this problem.

Regards and thanks for help.

Guybrush

here a little screenshot to explain my problem


six_L

Using Object Handle Inheritance
Object handle inheritance can be used only when processes have a parent-child relationship. In this scenario, one or more kernel object handles are available to the parent process, and the parent decides to spawn a child process, giving the child access to the parent's kernel objects. For this type of inheritance to work, the parent process must perform several steps.

First, when the parent process creates a kernel object, the parent must indicate to the system that it wants the object's handle to be inheritable. Sometimes I hear people use the term object inheritance. However, there is no such thing as object inheritance; Windows supports object handle inheritance. In other words, it is the handles that are inheritable, not the objects themselves.

regards

Guybrush

so, do you think the part of window that remain black is not child of DV2ControlHost Class ?  All the other object inside are regular transparency.... the strange thing is application work properly if I not put it inside automatic execution... that make me confused...

kero

> invoke GetWindowLong,hMenuStart,GWL_EXSTYLE
> or eax,WS_EX_LAYERED
> invoke SetWindowLong,hMenuStart,GWL_EXSTYLE,eax

invoke SetWindowPos,hMenuStart,0,0,0,0,0,SWP_NOZORDER OR SWP_NOMOVE OR SWP_NOSIZE OR SWP_FRAMECHANGED

> invoke SetLayeredWindowAttributes,hMenuStart,0,200,LWA_ALPHA

Guybrush

it didn't solved... but seem if I open and close menu start before my app start from automatic execution work properly...

Guybrush

I solved add invoke ShowWindow,hMenuStart,SW_RESTORE before apply alpha .... someone have a better idea ?

Guybrush

it's not good solution because now works properly in automatic execution... but open menu in normal mode... :green2

Mark Jones

Hello Guybrush, have you tried stepping through your code with a debugger such as OllyDbg?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Guybrush

thanks for this tool, I didn't know that... the code is correct.. it did what it should do... my problem is now understand what windows is doing during start and how to solve to fix the problem

if I run the application in normal way, it works
else if I run in automatic execution, there are two situations...
---- case 1) I don't open menu start before my app start and I have black line as in screenshot
---- case 2) I open menu start before my app start and it works...

so seem problem of windows that maybe have to adjust size of menu or something else... or maybe it not create all components in same time...

so the ShowWindow with SW_RESTORE... seem force Windows to do the job... and it solve the problem of automatic exectution... but it open the menu start when application is launched in normal way... (it's ugly)

So I need something that force Windows to do the job ShowWindow is doing but without activate and show the menu start....  maybe someone have some tip to suggest me that I can try :)

Anyway thanks you all, I really like this forum. (sorry for my english)

kero

As variant  (to StartUp folder):


.data
_DV2ControlHost db "DV2ControlHost",0  ; (WinXP)
.data?
.code
start:
push ebx
invoke FindWindow,offset _DV2ControlHost, 0
test eax,eax
jz @@@
mov ebx,eax
@@:
invoke Sleep,50
invoke IsWindowVisible,ebx
test eax,eax
jz @b
invoke GetWindowLong,ebx,GWL_EXSTYLE
or eax,WS_EX_LAYERED
invoke SetWindowLong,ebx,GWL_EXSTYLE,eax
invoke SetWindowPos,ebx,0,0,0,0,0,SWP_NOZORDER OR SWP_NOMOVE OR SWP_NOSIZE OR SWP_FRAMECHANGED
invoke SetLayeredWindowAttributes,ebx,0,200,LWA_ALPHA
@@@:
call ExitProcess
end start



Guybrush

Your solution seem great :clap:

Thank you very much  :U

@@:
invoke Sleep,50
invoke IsWindowVisible,ebx
test eax,eax
jz @b

That solve the problem =)