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.
Printable View
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.
The form has an opacity property.The might want to start there.
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.
That shouldn't happen , can you show me your code ?
Quote:
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.
Try this now :
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For i As Integer = 1 To 100 Me.Opacity = i / 100 Application.DoEvents() Next End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint Dim bs As Brush Dim ft As Font Dim grf As Graphics = e.Graphics bs = New TextureBrush(New Bitmap("C:\WINDOWS\Prairie Wind.bmp")) ft = New Font("Impact", 50, Drawing.FontStyle.Bold) grf.DrawString("Pirate", ft, bs, 100, 100) Me.TransparencyKey = Me.BackColor End Sub
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.
Or just use Color enums in place of the form's backcolor .
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.
Well this is an example of what I was talking about but it seems like there have been some better suggestions since then.
I imagine , this wouldn't happen when using these massive Transparency API Calls . .NET GDI+ still for trivial tasks I guess .Quote:
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.
Nice code but with some flickering at startup . :DQuote:
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.
:o obviously transparency does not work on my machine with S3 integrated graphic card and latest drivers approved by MS.
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.
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 ?Quote:
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
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 .Quote:
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?
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 . :confused:
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?
It should be 'if user's GC does not support transparency in 32 bit, let him go to hell.:confused: ' just like the GC I have now :DQuote:
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 . :confused:
What happens in 32Bit , is the opposite of 16Bit mode . not transparent but handle events .Quote:
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?
:eek: , you mean on your computer its not transparent in 32 bit??? So you should go to hell too :bigyello: What is your GC? and driver?
no comment . :) ;)Quote:
Originally posted by Lunatic3
It should be 'if user's GC does not support transparency in 32 bit, let him go to hell.:confused: ' just like the GC I have now :D
No it's not . Nvidia GForce MX 440 , AGP 4X , 64Mb DDR(not sure tho.) . Driver : Nvidia GForce MX 440 , not digitaly signed .Quote:
Originally posted by Lunatic3
:eek: , you mean on your computer its not transparent in 32 bit??? So you should go to hell too :bigyello: What is your GC? and driver?
Is it really transparent under 32bit ? :rolleyes:
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.
:confused:Quote:
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.
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.
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) .