Results 1 to 9 of 9

Thread: Transparent menus

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506

    Transparent menus

    ..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

    -Cheers, adehh.

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    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.
    Attached Files Attached Files
    Please rate my post.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    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:
    1. If strBuffer = "#32768" Then                  
    2.                   Debug.Print CWP.hwnd 'The hWnd of the menu is printed in the immediate window.
    3.                   Debug.Print GetWindowLong(CWP.hwnd, GWL_EXSTYLE) 'So are the current window longs...
    4.                   Call SetWindowLong(CWP.hwnd, GWL_EXSTYLE, GetWindowLong(CWP.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
    5.                   Debug.Print SetLayeredWindowAttributes(CWP.hwnd, 0, 20, LWA_ALPHA) '1 is printed in the immediate
    6.                    'window and allapi states a nonzero return value is a success
    7.                 End If
    I'm just feeling confused now, rather than feeling defeated..

    Cheers for any help, adehh!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    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.

    Help appreciated, cheers.

  5. #5
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Would you mind posting the modified project?
    Please rate my post.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    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.

    Cheers, adehh.
    Attached Files Attached Files

  7. #7
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    This works perfectly for me - what's the problem?
    Please rate my post.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    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.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    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.

    5 'size
    3 'move
    482
    70 'windowposchanging
    131 'NCCALCSIZE
    71 'windowposchanged
    5 'size
    70 'windowposchanging
    791 'print
    20 'erasebkgnd
    792 'windowposchanging
    71 'windowposchanged
    3 'move
    70 'windowposchanging
    71 'windowposchanged
    2 'destroy

    So, I skipped it out with an Exit Function and it prevents the menu from appearing, very strange. Suppose it's not causing my problem though.

    -adehh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width