Results 1 to 27 of 27

Thread: Transparencys

  1. #1

    Thread Starter
    Member inthecrossfire's Avatar
    Join Date
    Aug 2001
    Posts
    52

    Transparencys

    Is there anyway where I can have the form as partly transparent but have some of the controls on that form as completely solid. Thanks in advance.

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    The form has an opacity property.The might want to start there.

  3. #3

    Thread Starter
    Member inthecrossfire's Avatar
    Join Date
    Aug 2001
    Posts
    52
    I understand that, however that makes all the controls transparent as well. I would like to have the form as see-through but various icons on it completely opaque.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    That shouldn't happen , can you show me your code ?

  5. #5
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    Originally posted by Pirate
    That shouldn't happen , can you show me your code ?

    Really? That happens to me too! I thought it was normal. It has nothing to do with code, just paste controls on the form, and set the form's opacity.

    Hmm, I did manage to achieve something like this before though, by drawing a transparent color onto the form. I'd completely forgotten how, I'll see if I can figure it out again.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this now :
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         For i As Integer = 1 To 100
    3.             Me.Opacity = i / 100
    4.             Application.DoEvents()
    5.         Next
    6.     End Sub
    7.  
    8.     Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    9.         Dim bs As Brush
    10.         Dim ft As Font
    11.         Dim grf As Graphics = e.Graphics
    12.  
    13.         bs = New TextureBrush(New Bitmap("C:\WINDOWS\Prairie Wind.bmp"))
    14.         ft = New Font("Impact", 50, Drawing.FontStyle.Bold)
    15.         grf.DrawString("Pirate", ft, bs, 100, 100)
    16.         Me.TransparencyKey = Me.BackColor
    17.     End Sub

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could use a second form with the transparencykey set to the backcolor of the form to make it inside. Then just place whatever controls you want to show up on the form and place it over the other one. Its kind of a pain in the ass because then you have to sync sizing and movement but it shouldn't be too bad if you can't find another way. I think this is what Hu Flung Dung is talking about.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or just use Color enums in place of the form's backcolor .

  9. #9
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What i did in one of my projects for this was adding a panel to the form and make that and whatever control inside it (ex. a picturebox) transparent and the rest of the form was solid.

    Edits: I thoguht it was needless to say that to make a control, lets say that panel, transparent you have to set its BackColor to the TransparencyKey of your form.
    However this kind of transparency is somehow flawed. If you have a video program running, for example Windows media player showing a video then the transparency is lost. Some graphic card drivers don't show the form transparent, even those certified by MS.
    Last edited by Lunatic3; Oct 5th, 2003 at 05:00 PM.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well this is an example of what I was talking about but it seems like there have been some better suggestions since then.

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    However this kind of transparency is somehow flawed. If you have a video program running, for example Windows media player showing a video then the transparency is lost. Some graphic card drivers don't show the form transparent, even those certified by MS.
    I imagine , this wouldn't happen when using these massive Transparency API Calls . .NET GDI+ still for trivial tasks I guess .

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Edneeis
    Well this is an example of what I was talking about but it seems like there have been some better suggestions since then.
    Nice code but with some flickering at startup .

  13. #13
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    obviously transparency does not work on my machine with S3 integrated graphic card and latest drivers approved by MS.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  14. #14

    Thread Starter
    Member inthecrossfire's Avatar
    Join Date
    Aug 2001
    Posts
    52
    Thanks very much to all the replies. They're all good but I've not got any time to try them today. I'll message back tomorrow. Thanks a lot all.

  15. #15
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    It seems that some graphic cards (like mine, S3 ProSavageDDR) does not properly support transparency at 32 bit color quality,and it should be 16 bit to work. But there rises another problem when you set it to 16 bit, and that is in this case(16 bit) transparent control does not receive mouse events, but it should.
    I have sent a sample and will be glad if you check and see if on your machine the transparent button receives mouse events in 16 bit or not.
    Thanks
    Attached Files Attached Files
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    It seems that some graphic cards (like mine, S3 ProSavageDDR) does not properly support transparency at 32 bit color quality,and it should be 16 bit to work. But there rises another problem when you set it to 16 bit, and that is in this case(16 bit) transparent control does not receive mouse events, but it should.
    I have sent a sample and will be glad if you check and see if on your machine the transparent button receives mouse events in 16 bit or not.
    Thanks
    It works on the form's title and on the button . Is that what you mean ?

  17. #17
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I want you to check two things. If you set color quality to 16 bit,
    1- Is the button transparent? 99.99999...% it sohuld be.
    2- if transparent, can you click on it?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    I want you to check two things. If you set color quality to 16 bit,
    1- Is the button transparent? 99.99999...% it sohuld be.
    2- if transparent, can you click on it?
    1-Yes, it's .
    2-Exactly , no event raised .

    OK , easy one , don't develop for 16bit computers . If a user's GC doesn't support 32bit , let him go to hell .

  19. #19
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What about in 32 bit?
    I am sure in 32 bit, it should recieve mouse click. But it's strange, is there anyone who can describe it for us?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  20. #20
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Originally posted by Pirate
    OK , easy one , don't develop for 16bit computers . If a user's GC doesn't support 32bit , let him go to hell .
    It should be 'if user's GC does not support transparency in 32 bit, let him go to hell. ' just like the GC I have now
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  21. #21
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    What about in 32 bit?
    I am sure in 32 bit, it should receive mouse click. But it's strange, is there anyone who can describe it for us?
    What happens in 32Bit , is the opposite of 16Bit mode . not transparent but handle events .

  22. #22
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    , you mean on your computer its not transparent in 32 bit??? So you should go to hell too What is your GC? and driver?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  23. #23
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    It should be 'if user's GC does not support transparency in 32 bit, let him go to hell. ' just like the GC I have now
    no comment .

  24. #24
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    , you mean on your computer its not transparent in 32 bit??? So you should go to hell too What is your GC? and driver?
    No it's not . Nvidia GForce MX 440 , AGP 4X , 64Mb DDR(not sure tho.) . Driver : Nvidia GForce MX 440 , not digitaly signed .

    Is it really transparent under 32bit ?

  25. #25
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Yes, it should be transparent. I did a project for one of my friends and it largely depended on this kind of transparency. We wanted a transparent but still clickable part on the form and I did it in this way. But i am getting confused by statments from MSDN.
    Property Value
    A Color that represents the color to display transparently on the form.

    Remarks
    When the TransparencyKey property is assigned a Color, the areas of the form that have the same BackColor will be displayed transparently. Any mouse actions, such as the click of the mouse, that are performed on the transparent areas of the form will be transferred to the windows below the transparent area. For example, if the client region of a form is made transparent, clicking the mouse on that area would send the event notification of the click to any window that is below it. If the color assigned to the TransparencyKey property is the same as any controls on the form, they also will be displayed transparently. For example, if you have a Button control on a form that has its TransparencyKey property set to SystemColors.Control, the control will be displayed transparently unless the BackColor property of the Button control is changed to a different color.

    Windows 2000 Platform Note: Transparent windows and regions are only supported under the Windows 2000 operating system.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  26. #26
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    To add to confusion, some controls like panels and groupboxes are transparent in 32 bit on my machine and still dont register mouse clicks. I am going crazy.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  27. #27
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I got no more clue about this . But , if once I caught into this , I would compare both ways (1-pure APIs , then 2-GDI+(which sucks in this case) .

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