..Are they at all possible in VB? I've found one example in C but I can't implement it in VB because it's not possible to sublcass the WM_CREATE message. I'm not aware of any APIs for returning the hWnd of a menu either.
If anyone has had any joy with this, give us a shout! Oh the C example is here
I did some searching and found it is possible to subclass WM_CREATE in VB. I tried translating the project but couldn't get it to work properly. I've attached everything I got so far. Maybe tomorrow I can keep going at it.
I've downloaded the code and tinkered somewhat, found out the the WM_CREATE message is sent to the window each time the menu is clicked. Therefore instead of disabling the hook at form load I've kept it up until form unload. Strange thing is, when I subclassed a form without using a window hook the WM_CREATE message was never called a upon clicking the menu.
I read in the comments for that C article that the procedures for setting the transparency would work in the form hook so I've modified the code reflecting this, still to no avail.
VB Code:
If strBuffer = "#32768" Then
Debug.Print CWP.hwnd 'The hWnd of the menu is printed in the immediate window.
Debug.Print GetWindowLong(CWP.hwnd, GWL_EXSTYLE) 'So are the current window longs...
Call SetWindowLong(CWP.hwnd, GWL_EXSTYLE, GetWindowLong(CWP.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Debug.Print SetLayeredWindowAttributes(CWP.hwnd, 0, 20, LWA_ALPHA) '1 is printed in the immediate
'window and allapi states a nonzero return value is a success
End If
I'm just feeling confused now, rather than feeling defeated..
I've made a discovery on the transparent menus, try adding another menu, selecting one menu and then switching to the other one, now the transparency kicks in and it stays on until you deselect the menu but I don't understand why or how this happens.
If anyone has any ideas, please drop em by, maybe even download Shawns code and have a play about.
I reverted back to the old method of subclassing the menu, but I don't think it's actually required. Ignore the combobox as well, I'm also interested in making the list popup from a combo transparent as well, stil clueless on this though.
When I initially click on either of the menus they appear opaque but change transparent upon switching to another menu. What system are you running? - I'm on Win2k.
Cheers, adehh.
Edit: I've also sent a copy to a mate who's on XP an he mentioned the same problem.
I slammed a 'debug.print Msg' before the select case for the menu subclass and I'm getting a window message which I don't know, cant find anything about it on the web either.