Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Assalam-o-alikum, I am making a tab controlled web browser i have placed the tabs on the title bar but now the images and the colors are not correct if someone you can provide the code in vb.net(because i am not good at c# and others)it will be a big help. this is the photo of the form:

<img src="http://imagizer.imageshack.us/v2/150x100q90/910/i0mqnd.png" border="0">

and this is my code:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Diagnostics
Imports System.Drawing.Drawing2D
Imports Ontop.AeroNonClientButtons

Public Class Form1
Private dwmMargins As Dwm.MARGINS
Private _marginOk As Boolean
Private _aeroEnabled As Boolean
Public Sub New()
SetStyle(ControlStyles.ResizeRedraw, True)

InitializeComponent()


DoubleBuffered = True

CheckGlassEnabled()
End Sub
#Region "Props"

'''
''' Gets if aero is enabled
'''

Public ReadOnly Property AeroEnabled() As Boolean
Get
Return _aeroEnabled
End Get
End Property


#End Region

#Region "Methods"

'''
''' Sets the value of AeroEnabled
'''

Private Sub CheckGlassEnabled()
If Environment.OSVersion.Version.Major >= 6 Then
Dim enabled As Integer = 0
Dim response As Integer = Dwm.DwmIsCompositionEnabled(enabled)

_aeroEnabled = enabled = 1
End If
End Sub

'''
''' Equivalent to the LoWord C Macro
'''

''' <param name="dwValue" />
''' <returns>
Public Shared Function LoWord(dwValue As Integer) As Integer
Return dwValue And &HFFFF
End Function

'''
''' Equivalent to the HiWord C Macro
'''

''' <param name="dwValue" />
''' <returns>
Public Shared Function HiWord(dwValue As Integer) As Integer
Return (dwValue >> 16) And &HFFFF
End Function
#End Region

Protected Overrides Sub OnResize(e As EventArgs)
MyBase.OnResize(e)

TabControl1.MaximumSize = New Size(Me.Size)
End Sub

Protected Overrides Sub OnActivated(e As EventArgs)
MyBase.OnActivated(e)

If dwmMargins.cyTopHeight < TabControl1.Bottom Then
dwmMargins.cyTopHeight = TabControl1.Bottom
End If

Dwm.DwmExtendFrameIntoClientArea(Me.Handle, dwmMargins)
End Sub

Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)

If _aeroEnabled Then
e.Graphics.Clear(Color.Transparent)
Else
e.Graphics.Clear(Color.FromArgb(&HC2, &HD9, &HF7))
End If

e.Graphics.FillRectangle(SystemBrushes.ButtonFace, Rectangle.FromLTRB(dwmMargins.cxLeftWidth - 100, dwmMargins.cyTopHeight - 100, Width - dwmMargins.cxRightWidth - 100, Height - dwmMargins.cyBottomHeight - 100))
End Sub

Protected Overrides Sub WndProc(ByRef m As Message)
Dim WM_NCCALCSIZE As Integer = &H83
Dim WM_NCHITTEST As Integer = &H84
Dim result As IntPtr

Dim dwmHandled As Integer = Dwm.DwmDefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam, result)

If dwmHandled = 1 Then
m.Result = result
Return
End If

If m.Msg = WM_NCCALCSIZE AndAlso CType(m.WParam, Integer) = 1 Then
Dim nccsp As NCCALCSIZE_PARAMS = CType(Marshal.PtrToStructure(m.LParam, GetType(NCCALCSIZE_PARAMS)), NCCALCSIZE_PARAMS)

' Adjust (shrink) the client rectangle to accommodate the border:
nccsp.rect0.Top += 0
nccsp.rect0.Bottom += 0
nccsp.rect0.Left += 0
nccsp.rect0.Right += 0

If Not _marginOk Then
'Set what client area would be for passing to DwmExtendIntoClientArea
dwmMargins.cyTopHeight = nccsp.rect2.Top - nccsp.rect1.Top
dwmMargins.cxLeftWidth = nccsp.rect2.Left - nccsp.rect1.Left
dwmMargins.cyBottomHeight = nccsp.rect1.Bottom - nccsp.rect2.Bottom
dwmMargins.cxRightWidth = nccsp.rect1.Right - nccsp.rect2.Right
_marginOk = True
End If

Marshal.StructureToPtr(nccsp, m.LParam, False)

m.Result = IntPtr.Zero
ElseIf m.Msg = WM_NCHITTEST AndAlso CType(m.Result, Integer) = 0 Then
m.Result = HitTestNCA(m.HWnd, m.WParam, m.LParam)
Else
MyBase.WndProc(m)
End If
End Sub

Private Function HitTestNCA(hwnd As IntPtr, wparam As IntPtr, lparam As IntPtr) As IntPtr
Dim HTNOWHERE As Integer = 0
Dim HTCLIENT As Integer = 1
Dim HTCAPTION As Integer = 2
Dim HTGROWBOX As Integer = 4
Dim HTSIZE As Integer = HTGROWBOX
Dim HTMINBUTTON As Integer = 8
Dim HTMAXBUTTON As Integer = 9
Dim HTLEFT As Integer = 2
Dim HTRIGHT As Integer = 11
Dim HTTOP As Integer = 12
Dim HTTOPLEFT As Integer = 13
Dim HTTOPRIGHT As Integer = 14
Dim HTBOTTOM As Integer = 15
Dim HTBOTTOMLEFT As Integer = 16
Dim HTBOTTOMRIGHT As Integer = 17
Dim HTREDUCE As Integer = HTMINBUTTON
Dim HTZOOM As Integer = HTMAXBUTTON
Dim HTSIZEFIRST As Integer = HTLEFT
Dim HTSIZELAST As Integer = HTBOTTOMRIGHT

Dim p As New Point(LoWord(CType(lparam, Integer)), HiWord(CType(lparam, Integer)))

Dim topleft As Rectangle = RectangleToScreen(New Rectangle(0, 0, dwmMargins.cxLeftWidth, dwmMargins.cxLeftWidth))

If topleft.Contains(p) Then
Return New IntPtr(HTTOPLEFT)
End If

Dim topright As Rectangle = RectangleToScreen(New Rectangle(Width - dwmMargins.cxRightWidth, 0, dwmMargins.cxRightWidth, dwmMargins.cxRightWidth))

If topright.Contains(p) Then
Return New IntPtr(HTTOPRIGHT)
End If

Dim botleft As Rectangle = RectangleToScreen(New Rectangle(0, Height - dwmMargins.cyBottomHeight, dwmMargins.cxLeftWidth, dwmMargins.cyBottomHeight))

If botleft.Contains(p) Then
Return New IntPtr(HTBOTTOMLEFT)
End If

Dim botright As Rectangle = RectangleToScreen(New Rectangle(Width - dwmMargins.cxRightWidth, Height - dwmMargins.cyBottomHeight, dwmMargins.cxRightWidth, dwmMargins.cyBottomHeight))

If botright.Contains(p) Then
Return New IntPtr(HTBOTTOMRIGHT)
End If

Dim top As Rectangle = RectangleToScreen(New Rectangle(0, 0, Width, dwmMargins.cxLeftWidth))

If top.Contains(p) Then
Return New IntPtr(HTTOP)
End If

Dim cap As Rectangle = RectangleToScreen(New Rectangle(0, dwmMargins.cxLeftWidth, Width, dwmMargins.cyTopHeight - dwmMargins.cxLeftWidth))

If cap.Contains(p) Then
Return New IntPtr(HTCAPTION)
End If

Dim left As Rectangle = RectangleToScreen(New Rectangle(0, 0, dwmMargins.cxLeftWidth, Height))

If left.Contains(p) Then
Return New IntPtr(HTLEFT)
End If

Dim right As Rectangle = RectangleToScreen(New Rectangle(Width - dwmMargins.cxRightWidth, 0, dwmMargins.cxRightWidth, Height))

If right.Contains(p) Then
Return New IntPtr(HTRIGHT)
End If

Dim bottom As Rectangle = RectangleToScreen(New Rectangle(0, Height - dwmMargins.cyBottomHeight, Width, dwmMargins.cyBottomHeight))

If bottom.Contains(p) Then
Return New IntPtr(HTBOTTOM)
End If

Return New IntPtr(HTCLIENT)
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim t As New TabPage
Dim newtab As New Tab
t.ImageIndex = 0
newtab.Show()
newtab.TopLevel = False
newtab.AxWebBrowser1.RegisterAsBrowser = True
newtab.Dock = DockStyle.Fill
t.Controls.Add(newtab)
TabControl1.TabPages.Add(t)
End Sub

please somebody help me
Thanks in Advance, hamza
Posted
Comments
Rob Grainger 14-Aug-14 5:50am    
Don't really see why this is tagged as C++ or C#, as you're really asking about VB.NET.
Hamza Abdullah Mirza 15-Aug-14 1:55am    
Yeah Sorry, But Do You Have An Answer please

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900