Click here to Skip to main content
15,905,913 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Question<![CDATA[NULL]]>is parsable? Pin
skoizumi291109-Jun-04 6:47
sussskoizumi291109-Jun-04 6:47 
AnswerRe: <![CDATA[NULL]]>is parsable? Pin
Dave Kreskowiak9-Jun-04 8:50
mveDave Kreskowiak9-Jun-04 8:50 
GeneralRe: <![CDATA[NULL]]>is parsable? Pin
vancouver7779-Jun-04 13:06
vancouver7779-Jun-04 13:06 
QuestionHow to get computer id? Pin
viettho9-Jun-04 5:37
viettho9-Jun-04 5:37 
AnswerRe: How to get computer id? Pin
Dave Kreskowiak9-Jun-04 6:45
mveDave Kreskowiak9-Jun-04 6:45 
GeneralProgress bar and dataadapter fill Pin
jshofner9-Jun-04 1:56
jshofner9-Jun-04 1:56 
GeneralRe: Progress bar and dataadapter fill Pin
Dave Kreskowiak9-Jun-04 6:43
mveDave Kreskowiak9-Jun-04 6:43 
GeneralWhy onpaint doesn't work in numericupdown Pin
beifangcc8-Jun-04 23:39
beifangcc8-Jun-04 23:39 
Please help me.
I want to build a xp themed numericupdown control, I Inherits NumericUpDown class and use API function to draw board and updown button in Onpaint events.
But it doesn't work,the numericupdown isn't redrawed. And I found if I inherits UserControl it works perfect.

Source Code:(only paint,no other function)

Imports System.Drawing
Imports System.Windows.Forms

Namespace WaterSoft

<toolboxbitmap(gettype(xpnumericupdown))> _
Public Class XPNumericUpDown

'Inherits NumericUpdown doesn't work
Inherits NumericUpDown

'Inherits UserControl it work perfect,someone can test it.Confused | :confused:
'Inherits UserControl

Private Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure

Private Declare Function IsAppThemed Lib "uxtheme.dll" () As Boolean
Private Declare Function IsThemeActiveXP Lib "uxtheme.dll" Alias "IsThemeActive" () As Boolean

Private Declare Unicode Function OpenThemeData Lib "uxtheme.dll" _
(ByVal hwnd As IntPtr, ByVal pszClassList As String) As IntPtr
Private Declare Unicode Function CloseThemeData Lib "uxtheme.dll" _
(ByVal hTheme As IntPtr) As Integer
Private Declare Unicode Function DrawThemeBackground Lib "uxtheme.dll" _
(ByVal hTheme As IntPtr, ByVal hDC As IntPtr, _
ByVal iPartId As Integer, ByVal iStateId As Integer, _
ByRef pRect As RECT, _
ByRef pClipRect As RECT _
) As Integer

Private rectUp As RECT
Private rectDown As RECT

Public Sub New()

MyBase.New()

' This call is required by the Windows Forms Designer.
'InitializeComponent()

' Add any initialization after the InitializeComponent() call.
Me.SetStyle(ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint _
Or ControlStyles.ResizeRedraw, _
True)
Me.UpdateStyles()
End Sub

#Region "其它函数"

Private Function IsThemedXP() As Boolean
Dim intVer As Integer

intVer = Environment.OSVersion.Version.Major * 10 + Environment.OSVersion.Version.Minor
If intVer >= 51 And IsThemeActiveXP And IsAppThemed Then
Return True
Else
Return False
End If
End Function

#End Region

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)

Application.DoEvents()
If IsThemedXP() Then
If True Then 'Me.UpDownAlign = LeftRightAlignment.Left Then
rectUp.left = 1
rectDown.left = 1
Else
rectUp.left = Me.Width - 18
rectDown.left = Me.Width - 18
End If
With rectUp
.top = 1
.right = .left + 17
.bottom = .top + 9
End With
With rectDown
.top = 11
.right = .left + 17
.bottom = .top + 9
End With

Dim br As Brush = New SolidBrush(Me.BackColor)
e.Graphics.FillRectangle(br, e.ClipRectangle)
br.Dispose()

Dim hTheme As IntPtr = IntPtr.Zero
Dim hDC As IntPtr = e.Graphics.GetHdc()
Dim rectPic As RECT

With rectPic
.left = 0
.top = 0
.right = Me.Width
.bottom = Me.Height
End With

Select Case Me.Enabled
Case True
hTheme = OpenThemeData(Me.Handle, "Edit")
DrawThemeBackground(hTheme, hDC, 1, 1, rectPic, rectPic)
CloseThemeData(hTheme)
hTheme = OpenThemeData(Me.Handle, "Spin")
DrawThemeBackground(hTheme, hDC, 1, 1, rectUp, rectUp)
CloseThemeData(hTheme)
hTheme = OpenThemeData(Me.Handle, "Spin")
DrawThemeBackground(hTheme, hDC, 2, 1, rectDown, rectDown)
CloseThemeData(hTheme)
Case False
hTheme = OpenThemeData(Me.Handle, "Edit")
DrawThemeBackground(hTheme, hDC, 1, 4, rectPic, rectPic)
CloseThemeData(hTheme)
hTheme = OpenThemeData(Me.Handle, "Spin")
DrawThemeBackground(hTheme, hDC, 1, 4, rectUp, rectUp)
CloseThemeData(hTheme)
hTheme = OpenThemeData(Me.Handle, "Spin")
DrawThemeBackground(hTheme, hDC, 2, 4, rectDown, rectDown)
CloseThemeData(hTheme)
End Select

e.Graphics.ReleaseHdc(hDC)
End If
End Sub

Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)

Me.Refresh()
End Sub
End Class

End Namespace
GeneralRe: Why onpaint doesn't work in numericupdown Pin
Aaron Eldreth9-Jun-04 3:02
Aaron Eldreth9-Jun-04 3:02 
GeneralRe: Why onpaint doesn't work in numericupdown Pin
beifangcc9-Jun-04 17:30
beifangcc9-Jun-04 17:30 
GeneralRe: Why onpaint doesn't work in numericupdown Pin
10-Jun-04 4:16
suss
10-Jun-04 4:16 
GeneralRe: Why onpaint doesn't work in numericupdown Pin
beifangcc10-Jun-04 15:55
beifangcc10-Jun-04 15:55 
GeneralRe: Why onpaint doesn't work in numericupdown Pin
Aaron Eldreth11-Jun-04 3:20
Aaron Eldreth11-Jun-04 3:20 
GeneralDropdownlist Pin
dotnet_cpp8-Jun-04 19:50
dotnet_cpp8-Jun-04 19:50 
GeneralRe: Dropdownlist Pin
Dave Kreskowiak9-Jun-04 0:07
mveDave Kreskowiak9-Jun-04 0:07 
Generalgetting listbox contents.. Pin
JasonRey8-Jun-04 16:54
JasonRey8-Jun-04 16:54 
GeneralRe: getting listbox contents.. Pin
Dave Kreskowiak9-Jun-04 6:57
mveDave Kreskowiak9-Jun-04 6:57 
GeneralCode for a Calculator Pin
nofrills138-Jun-04 16:14
nofrills138-Jun-04 16:14 
GeneralRe: Code for a Calculator Pin
Jim Taylor8-Jun-04 22:15
Jim Taylor8-Jun-04 22:15 
GeneralTreeView in run time Pin
Brad Fackrell8-Jun-04 9:16
Brad Fackrell8-Jun-04 9:16 
GeneralRe: TreeView in run time Pin
Dave Kreskowiak8-Jun-04 9:31
mveDave Kreskowiak8-Jun-04 9:31 
GeneralRe: TreeView in run time Pin
Brad Fackrell8-Jun-04 9:36
Brad Fackrell8-Jun-04 9:36 
GeneralRe: TreeView in run time Pin
Dave Kreskowiak8-Jun-04 10:08
mveDave Kreskowiak8-Jun-04 10:08 
GeneralRe: TreeView in run time Pin
Brad Fackrell8-Jun-04 10:12
Brad Fackrell8-Jun-04 10:12 
GeneralRe: TreeView in run time Pin
Brad Fackrell8-Jun-04 11:48
Brad Fackrell8-Jun-04 11:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.