how can i put a button in my forms titlebars (similar to context help buttons)?
Printable View
how can i put a button in my forms titlebars (similar to context help buttons)?
impossible. You have to cheat and make a 2nd form the size of a button and keep it in place with a timer.
OR i suppose you could paint over it a fake button the way aol used to and detect via subclassing where on the title bar it was clicked and if it is clicked on your fake button it runs your code
thanks. i'd already found that 1
i was hoping there might be an easier way to do it
simple way:
API (unmanaged code)
http://vbforums.com/showpost.php?p=1263274&postcount=6
isn't there a way to do it using ModifyStyleEx API
No there isn't. ModifyStyleEx lets you specify that a help button should be displayed but that's because that is standard Windows behaviour. As such you can display that button using managed code. If you just want your own button for your own purpose then there's hardly going to be a Windows constant declared for your button specifically like there is for a help button. What you're asking for is possible but very non-standard. As such the code to achieve it is more than a few lines.Quote:
Originally Posted by .paul.
Also, ModifyStyleEx is not a standard Windows API function as far as I can tell. It's a member of various MFC classes so if you're not building an MFC app then you have no access to the function.
i've just finished converting someones c# example for this.
i'll try to work it out later.
thanks
Hi,
Why not just draw your own titlebar and buttons:
Wkr,Code:Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = e.Graphics
Dim rect As New Rectangle(0, 0, Me.Width, 25)
Dim backbrush As New Drawing.Drawing2D.LinearGradientBrush(rect, Color.Blue, Color.White, Drawing2D.LinearGradientMode.Vertical)
g.DrawRectangle(Pens.Blue, rect)
g.FillRectangle(backbrush, rect)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class
sparrow1
no thanks sparrow.
i'll use the API method