我想要一個面板有TabControl
這樣的陰影,這可能嗎?與TabControl具有相同樣式(陰影)的C#Winforms面板?
回答
邊框= Fixed3D
採取在這個例子中的樣子的陰影:
http://www.onteorasoftware.com/downloads/panelwithshadow.zip
最後,自定義的面板也能像(在VB):
Imports System.Drawing.Drawing2D
Public Class ShadowPanel
Inherits Panel
Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As IntPtr) _
As IntPtr
Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As IntPtr, _
ByVal hdc As IntPtr) As Integer
Public Sub New()
Me.BorderStyle = BorderStyle.Fixed3D
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WM_NCPAINT As Integer = &H85
If m.Msg = WM_NCPAINT Then
Dim hdc As IntPtr = GetWindowDC(m.HWnd)
Dim g As Graphics = Graphics.FromHdc(hdc)
Dim rDraw As Rectangle = New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)
Dim pBottom As Pen = New Pen(Color.Gray, 3)
Dim pTop As Pen = New Pen(Color.White, 3)
g.DrawRectangle(pBottom, rDraw)
Dim pts(2) As Point
pts(0) = New Point(0, Me.Height - 1)
pts(1) = New Point(0, 0)
pts(2) = New Point(Me.Width - 1, 0)
g.DrawLines(pTop, pts)
ReleaseDC(Me.Handle, hdc)
Else
MyBase.WndProc(m)
End If
End Sub
Private Sub ParentPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = Me.Parent.CreateGraphics
'this matrix zooms the text out to 1/4 size and offsets it by a little right and down
Dim mx As New Matrix(1.0F, 0, 0, 1.0F, 4, 4)
Dim rdraw As New Rectangle(Me.Left, Me.Top, Me.Width, Me.Height)
g.Transform = mx
g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Black)), rdraw)
g.Dispose()
End Sub
End Class
是的,在你的面板的繪畫事件中,使用這樣的東西:
void Paint(object sender, PaintEventArgs e) {
TabRenderer.DrawTabPage(e.Graphics, e.Bounds);
}
例外聲明視覺樣式未啓用...(this.Bounds) – serhio 2010-01-07 15:05:17
與panel.Bounds一起使用。 e不包含邊界 – MysticEarth 2010-01-07 15:11:05
@MysticEarth:Pondidum意在創建一個自定義的'myPanel:Panel'並覆蓋OnPaint,不是嗎? – serhio 2010-01-07 15:28:00
- 1. C++相同類型的簽名(陰影)
- 2. 陰影的窗口樣式?
- 3. javafx - 工具提示與標籤具有相同的樣式
- 4. Winforms創建下拉式樣面板
- 5. CSS的效率與文字陰影一樣壞框陰影?
- 6. Visual C#/ WinForms面板
- 7. 的TabControl和TabItem的與陰影效果效果WPF
- 8. 同時滾動兩個面板c#winForms
- 9. GLSL中的Photoshop陰影樣式
- 10. 的WinForms:瀏覽器一樣的TabControl
- 11. WinForms TabControl
- 12. Android。兩個完全相同的按鈕有不同的陰影
- 13. WinForms TextBox焦點與TabControl
- 14. 多個面板陰影非NA錯誤
- 15. wxPython面板是兩個灰色陰影?
- 16. WPF tabcontrol樣式
- 17. VS2012頁面檢查器忽略文本的陰影樣式
- 18. 內聯樣式陰影元素?
- 19. 在XAML中創建陰影樣式
- 20. 使用jQuery獲取陰影樣式
- 21. Polymer的陰影DOM與陰影DOM有什麼區別?
- 22. 元素樣式與計算樣式具有不同的值
- 23. 具有內置緩存的C++對象工廠 - 陰影模板參數
- 24. 陰影與GDlib
- 25. 下拉陰影具有梯度的CSS
- 26. 具有陰影效果的HTML5文本
- 27. C#UWP工具包DropShadowPanel內部陰影
- 28. C#,TabControl,視覺樣式 - 我如何給面板一個類似於TabControl背景的視覺背景?
- 29. C++店相同的類具有不同的模板陣列
- 30. WPF Tabcontrol所有選項卡的相同類型的模板
+1,簡單>油漆! – Pondidum 2010-01-07 14:52:43
這給了面板一個內嵌的外觀,我希望它能夠投下陰影...... – MysticEarth 2010-01-07 15:10:32
@Earth:看我的編輯。 – serhio 2010-01-07 15:31:05