how to make window transparent

Discussion in 'Win32' started by vidhya, Jun 4, 2007.

  1. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    hi

    i want to know how to make windows transparent . and whatever the text scrolling in that window it appear like only text scrolling.window should not appear. i tried with WS_EX_TRANSPARENT,but it is not working the way i want ,is their any other way to do.please help me out to do this.
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Just having the property will not help and you need to handle the WM_PAINT to do the transparent drawing.
     
  3. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    You can have the Dialog as OWNER_DRAW and handle the OnDraw.
     
  4. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    Oops. Just did not read your one.
     
  5. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0

    can you please explain what i have to do in WM_PAINT.
     
  6. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    I will try. You need to paint the Dialog in such a manner that it becomes transparent by using the API's like TransparentBlt
     
  7. tiger12506

    tiger12506 New Member

    Joined:
    Jun 6, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Maybe I do not know what you are talking about exactly...
    But check out the results of this snippet on Windows NT (or XP)

    Code:
    int translevel = 100;  /* 0 - 255 */
              SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(h,GWL_EXSTYLE)|WS_EX_LAYERED);
    SetLayeredWindowAttributes(hwnd,RGB(0,0,0),translevel, 0x02);
    
     
  8. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    thanks for the help,i tried the above code but it is giving error like this:
    error C2065: 'SetLayeredWindowAttributes' : undeclared identifier
    error C2065: 'WS_EX_LAYERED' : undeclared identifier.
    i included both winuser.h and windows.h.
    how to come out of this error.
     
  9. tiger12506

    tiger12506 New Member

    Joined:
    Jun 6, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    ummm.... ummm... let me think....
    When I say that it only works in windows NT or later, I mean it -- it won't work in win9x
    In the Dev-cpp developing environment, there are certain #define s that you have to put before you #include <windows.h> . For example I would have to put #define _WIN32_WINNT 0x500 before i include. It is definitely supposed to be in the winuser header... hmmm... See, I don't know much about VC so I don't know how it handles those defines like that.
    The only thing I can come up with that could possible help is to tell you this.
    Open up winuser.h
    Search for SetLayeredWindowAttributes
    If you find it, find out what #ifdef s are preventing it from being defined
    If you don't find it, add it in. The declaration should look like this

    WINUSERAPI BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWORD);

    And the same thing for WS_EX_LAYERED\
    if you can't find it -- add it in

    #define WS_EX_LAYERED 0x80000


    Hope this helps
     
  10. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0


    Thanks for help.i followed what u said,like i searched for setLayeredWindowAttributes in winuser.h that function was not their.
    just i added the code in winuser.h like this
    typedef BOOL (CALLBACK* SetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
    and executed my program.then i got the error like this error C2564: 'int (__stdcall *)(struct HWND__ *,unsigned long,unsigned char,unsigned long)' : function-style conversion to builtin type takes only one argument
    Error executing cl.exe.
    i think it is the problem with the declaration of the function in winuser.h.
    can you please tell me how to come out of this error.
     
  11. tiger12506

    tiger12506 New Member

    Joined:
    Jun 6, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Well... I really meant for you to copy the declaration letter for letter.

    So at the bottom of winuser.h COPY AND PASTE this

    Code:
    #define WS_EX_LAYERED 0x80000
    BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWORD);
    
    -------------------------------
    I'm pretty sure that this will NOT work, and the error you get is concurrent.
    "typedef BOOL (CALLBACK* SetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);"

    Sorry for any misunderstanding
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice