How can I add system tray button in Titlebar?
Printable View
How can I add system tray button in Titlebar?
I want to add an extra button in titlebar other than min,max,close which will act as system tray button. Just like All API.Net window.
I think you'd need to subclass your form and intercept the WM_NCPAINT messages. Then draw all the buttons in their appropriate states...to draw the outline of the button use the DrawFrameRect API call.
HTH,
Duncan
You can do it without subclassing, but you would have to create your own titlebar using either a label or a picture box or something like that. In this case, you would have to set the ControlBox to False which means you would lose your Min, Max, and Close button.
If you are going to draw the caption bar yourself, you would be better to use the DrawFrameControl API call.
Which is used thus:Code:'\\ Declarations
Private Enum enDrawFrameControlTypes
DFC_CAPTION = 1
DFC_MENU = 2
DFC_SCROLL = 3
DFC_BUTTON = 4
DFC_POPUPMENU = 5
End Enum
Public Enum enDrawFrameCaption
DFCS_CAPTIONCLOSE = &H0
DFCS_CAPTIONMIN = &H1
DFCS_CAPTIONMAX = &H2
DFCS_CAPTIONRESTORE = &H3
DFCS_CAPTIONHELP = &H4
End Enum
Private Declare Function DrawFrameControlApi Lib "user32" Alias "DrawFrameControl" (ByVal hdc As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
Code:Private Sub DrawFrameCaption(ByVal RectIn As Rect, ByVal CaptionStyle As enDrawFrameCaption)
Call DrawFrameControl(RectIn, DFC_CAPTION, CaptionStyle)
End Sub
HTH,
Duncan