Results 1 to 7 of 7

Thread: Transparent Controls?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Fayetteville, AR
    Posts
    3

    Angry

    I'm using VB6.
    I have a form with a gradient background that fades from blue to white, going from the top of the form to the bottom of the form.

    I also have some frames on the form that contain some controls. Is there a way I can make the frames transparent so with the border of the frame still visible so that the user see's the controls grouped together? If not, what container control should I use to accomplish the same functionality that the frames are currently providing for me?

    I want to do this so that my form's gradient background is visible and the frames won't throw a big chunk of solid color into the middle of the form.

    Thanks in advance,
    Mike T.

    Mike Threlkeld

  2. #2
    Guest
    use the shape control, and use a square.. make sure the backstyle is transparent and not opaque

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Fayetteville, AR
    Posts
    3
    I tried that but couldn't put controls inside the shape control.....was I doing something wrong? Can the shape control be used as container control?

    Mike Threlkeld

  4. #4
    Guest
    Oh, I didnt know you needed a container..
    I use the shape as a grouping tool...
    I cannot find a container that can have a transparent background...
    sorry.....

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Fayetteville, AR
    Posts
    3
    OK, Thanks Dennis.
    Anybody else?

    Mike Threlkeld

  6. #6
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    It's possible to create a transparent control.

    However, due to Microsoft's bumbling, there's one big restriction: you can't move it around.

    This means making transparent areas on anything that the user can move around is impossible.

    This applies to transparent areas that are part of the window; i.e. the window can blit over them and it will affect the image below it (example: a "highlighter" window that would highlight anything below it).

    The other type of transparency is created by using SetWindowRegion. That type of transparency is created by changing the visible part ("region") of the window from its usual rectangle to a complex area. This has a 'cookie cutter' effect on the window; any part of the window that lies outside the cookie cutter shape is not drawn, and if the user clicks in those areas, it goes right through to the window under it.


    I believe you wish to have the first type of transparency, since the cookie-cutter method cuts out any contained controls.


    I recommend this algorithm:
    1. Give each frame the WS_EX_TRANSPARENT extended style.
    2. Subclass the frames and intercept WM_ERASEBKGND and WM_PAINT, to do your own painting.


    These API functions will be extraordinarily helpful to you (all may be found on MSDN):

    GetWindowLong - Window style and subclassing
    SetWindowLong - Window style and subclassing

    CallWindowProc - Subclassing
    SetProp - Subclassing
    GetProp - Subclassing
    RemoveProp - Subclassing

    BeginPaint - Painting
    DrawText - Painting
    DrawEdge - Painting (automatically draws a frame border)
    EndPaint - Painting

    And this undocumented VB function:
    ObjPtr - Subclassing
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

  7. #7
    Guest
    A PictureBox is a container. Just create a BMP file of how you want the frame to look like, convert it to GIF (so it has a transparent background) and then load it up into a PictureBox.

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