Making a custom control WITH opacity

Control w Background & a modified label

Page 1 of 1

2 Replies - 16309 Views - Last Post: 21 March 2008 - 05:21 AM Rate Topic: -----

#1 dawmail333  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 27
  • View blog
  • Posts: 174
  • Joined: 02-July 07

Making a custom control WITH opacity

Posted 21 March 2008 - 02:18 AM

I'm making a control which works like such:

(Psuedocode)
Custom Control

Backcolour is White

Label

Text Align is Center
Autosize is False
Dock is Fill
Font will be customized
Text will be customized

End Label

End Custom Control


What I need to do is modify this so I can set this control's opacity setting, as I will need it to fade in/out.

If you can help, I'd appreciate it.

Is This A Good Question/Topic? 0
  • +

Replies To: Making a custom control WITH opacity

#2 SpeeDemon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 18-March 08

Re: Making a custom control WITH opacity

Posted 21 March 2008 - 03:28 AM

I dont know if you can modify opacity! I know you can for the form, but for individual controls? Beyond me.

The best I came up with was
Private Sub MyCoolControl(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.BackColor = Color.Red
        ' Make the control display transparently.
        ' TransparencyKey makes anything transparent
        ' Provided its the color of said key...
        TransparencyKey = Button19.BackColor
End Sub

Was This Post Helpful? 0
  • +
  • -

#3 RodgerB  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Re: Making a custom control WITH opacity

Posted 21 March 2008 - 05:21 AM

Firstly, we aren't going to make the code for you. Here is my analysis on this subject:

1) The label can not a label at all, rather text drawn on the control using the System.Drawing namespace. Opacity with this control is a limitation imposed by the operating system, and implementations have been done with the drawing functions.

2) To set the opacity of the actual control, not the label, we would gradually decrement the opacity until we can no longer see it: e.g. like so:

Public Sub setOpacity(ByVal opacity As Integer)
    Me.BackColor = Color.FromArgb(opacity, 255, 255, 255)
End Sub



Of course, 255 being completely visible, and 0 being invisible.

Hope that helps. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1