vb.net的仪表 vbnet ui( 二 )


Next i
End If
End With
End Sub
Private Sub Form_Load()
Dim Ret As Long
'Dim Ret As Long
'Set the window style to 'Layered'
Ret = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 200
SetLayeredWindowAttributes Me.hwnd, 0, 240, LWA_ALPHA
'X = Form1.Width / 2: Y = Form1.Height / 2
'Query anlegen und Handle darauf ermitteln
RetVal = PdhOpenQuery(0, 1, hQuery)
If RetVal0 Then
MsgBox "获取信息失败!", vbExclamation, "提示!"
End
End If
'Performance-Counter definieren
RetVal = PdhVbAddCounter(hQuery, "\Prozessor(0)\Prozessorzeit (%)", hCounter) 'German OS
If RetVal0 Then
RetVal = PdhVbAddCounter(hQuery, "\Processor(0)\% Processor Time", hCounter) ' English OS
If RetVal0 Then
MsgBox "获取信息失败!", vbExclamation, "提示!"
PdhCloseQuery hQuery 'Query im Fehlerfall wieder schlie遝n
End
End If
End If
'CPU Infos ermitteln via WMI !Slow!
CPU ' We do this Once at Start
HDAnz = ListDrives 'Die Anzahl der Laufwerke holen
xP = 0
iDir = 4
Unload splash2
Call LAufschrift 'Fill the Bottom Status Bar with Information
End Sub
Private Sub Form_Unload(Cancel As Integer)
PdhCloseQuery hQuery 'Query wieder schlie遝n
End Sub
'CarComputer like Display With Wordwrap Function
'Input: PictureBox, LeftTop Position with X,Y, Wide, height, BackgroundColor, ForegroundColor, Text
Sub CarComp(Pic As PictureBox, x, y, G, G1, fa, fa2, Text)
X1 = 0
y1 = 0
'Drawing the BAckground with Line and BF Option (B for Box, F for FILLED)
If fafa2 Then
Pic.Line (x, y)-(x + G, y + G1), fa, BF
End If
'Now Setting the Color for the Text and right Textsize
Pic.ForeColor = fa2
Pic.FontSize = 10
' Draw the Text on our little Display
For i = 1 To Len(Text)
s = Mid$(Text, i, 1)
A = Pic.TextWidth(s)
B = Pic.TextHeight(s)
Pic.CurrentX = x + X1
【vb.net的仪表 vbnet ui】Pic.CurrentY = y + y1
If s = Chr$(12) Then
X1 = 0
y1 = y1 + B
If y1G1 Then Exit Sub
Else
Pic.Print s
X1 = X1 + A
If X1 = G Then X1 = 0: y1 = y1 + B: If y1G1 Then Exit Sub
End If
Next i
End Sub
' Super Gauge Car like Speed Display with Leds
Sub SGauge(Pic As PictureBox, x, y, G, fa, Wert, Text)
Dim X1, X2, x3, y1, y2, y3 As Double
PI = 3.1415926543 'Pi
Z = 10
XT = 0 '
G1 = Int(G / 100) 'Our Mesarement ist %, so we build the unit
Gr = G1 * 70 'Z3 is the Radius of the Text, The lines starts from
Z1 = G1 * 110
Z2 = G1 * 130
Z3 = G1 * 90 'Radius Z2 to to radius of Z3
F1 = G1 - 2
If F110 Then F1 = 10 'We care about Font Size, should not be smaller then 10
Pic.FontSize = F1 'Setting the Font
Pic.DrawWidth = 1 'Starting with line a normal thick line
Pic.Circle (x, y), Gr, fa, 5.8, 4# 'Drawing in the inner Circle
A1 = (1.78 * PI) - ((((1.78 * PI) - 1) / 100) * Wert) 'Changing the Value in Wert to an angle
r = 0 'Starting Color is Black
For i = 1.78 * PI To 1 Step -0.0455
X1 = x + Int(sIn(i) * Z1)
y1 = y + Int(Cos(i) * Z1) 'Line From Point
X2 = x + Int(sIn(i) * Z2)
y2 = y + Int(Cos(i) * Z2) 'Line to Point
x3 = x + Int(sIn(i) * Z3)
y3 = y + Int(Cos(i) * Z3) 'Postion of Text
If A1 = i Then 'if our Value Angel is smaler or Equal then bright LEDs
If Wert70 Then fru = H6600 + Wert * 2 Else fru = H33 + Wert * 2
Pic.DrawWidth = 2 'a biger Line is like a LED ;-)
Else
Pic.DrawWidth = 2 'the Small dark line means the LED is off
fru = 0
End If
If Z = 10 Then 'Every Ten line we draw a longer White Line in the Gauge

推荐阅读