Results 1 to 2 of 2

Thread: i need help on custom title bar

  1. #1

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Turkey
    Posts
    274

    i need help on custom title bar

    hi guys i write a custom title bar with wndproc (form is sizable tool box because it haves rectangle shape)
    but theres 2 errors we cant click the close button i draw with visualstyles and sometimes title bar or close button (real one) appears

    Code:
        <DllImport("user32.dll")>
        Private Shared Function GetWindowsRect(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
        End Function
        <DllImport("user32.dll")>
        Private Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
        End Function
    
        <DllImport("User32.dll")>
        Private Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr
        End Function
        
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            Const WM_NCPAINT As Integer = 133
            MyBase.WndProc(m)
            If m.Msg = WM_NCPAINT Then
                Dim hdc As IntPtr = GetWindowDC(m.HWnd)
                If CInt(hdc) <> 0 Then
                    Dim brushy As Brush
                    brushy = New Drawing.SolidBrush(Color.FromArgb(120, 197, 87))
                    Dim g As Graphics = Graphics.FromHdc(hdc)
                    Dim screenRectangle As Rectangle = RectangleToScreen(Me.ClientRectangle)
                    Dim titleHeight As Integer = screenRectangle.Top - Me.Top
                    Dim rect As Rectangle = New Rectangle(0, 0, Me.Width, 30)
                    Dim rectx As Rectangle = New Rectangle(Me.Width - 18, 10, 10, 10)
                    Dim text As Rectangle = New Rectangle(5, 5, Me.Width, 30)
                    g.FillRectangle(brushy, rect)
                    g.FillRectangle(Brushes.Red, rectx)
                    Dim drawFont As New System.Drawing.Font("and", 14)
                    g.DrawString("androidify PRO", drawFont, Brushes.White, text)
    
    
    
                    Dim r As New VisualStyles.VisualStyleRenderer(VisualStyles.VisualStyleElement.Window.MdiCloseButton.Normal)
                    r.DrawBackground(g, New Rectangle(Me.Width - 30, 0, 30, 30))
    
                    g.Flush()
                    ReleaseDC(m.HWnd, hdc)
                End If
            End If
        End Sub

  2. #2

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Turkey
    Posts
    274

    Re: i need help on custom title bar

    ok im removing it

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