|
楼主 |
发表于 2019-5-23 18:14:03
|
显示全部楼层
广西壮族自治区河池市
求助,为什么FORM2字体颜色没有改变呀
form1:
'定义全局变量
Public 颜色 As String
Public 字色 As Boolean
Public ZC As Integer
Public ZH As Long
Public 字体1 As Integer
Option Explicit
Dim d(12) As String
Dim e(12) As Integer
Dim x As Long
Private Sub Form_Load()
'黑色=0
'藏青 = 8388608
'深青 = 8421376
'紫红 = 8388736
'** = 8421504
'蓝色 = 16711680
'绿色 = 65280
'红色 = 255
'品红 = 16711935
'黄色 = 65535
'白色 = 16777215
'藏蓝 = 14692440
Combo1.AddItem 50, 0
Combo1.AddItem 55, 1
Combo1.AddItem 60, 2
Combo1.AddItem 65, 3
Combo1.AddItem 70, 4
Combo1.AddItem 75, 5
Combo1.AddItem 80, 6
Combo1.AddItem 85, 7
Combo1.AddItem 90, 8
Combo1.AddItem 95, 9
Combo1.AddItem 100, 10
Combo1.AddItem 110, 11
Combo1.Text = Combo1.List(0)
End Sub
Combo11.AddItem "红色", 0
Combo11.AddItem "绿色", 1
Combo11.AddItem "蓝色", 2
Combo11.AddItem "黄色", 3
Combo11.AddItem "黑色", 4
Combo11.AddItem "白色", 5
Combo11.AddItem "品红", 6
Combo11.AddItem "紫红", 7
Combo11.AddItem "藏青", 8
Combo11.AddItem "深青", 9
Combo11.AddItem "藏蓝", 10
Combo11.AddItem "**", 11
Combo11.Text = Combo11.List(0)
End Sub
Private Sub Command1_Click()
ZH = Combo1.ListIndex
ZC = Combo11.ListIndex
颜色 = Combo11.Text
MsgBox "你选择了第" & (Combo11.ListIndex + 1) & "项," & "对应的值为:" & (Combo11.ListIndex) & (Combo11.Text)
Form2.Show 0, Me
End Sub
Private Sub Command2_Click()
Unload Form2
End Sub
Private Sub Command3_Click()
End
End Sub
form2:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongW" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongW" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
Call SetWindowLong(hwnd, -20, &H80020 Or GetWindowLong(hwnd, -20))
Call SetLayeredWindowAttributes(hwnd, 0, 0, 1)
Call SetWindowPos(hwnd, -1, 0, 0, 0, 0, 19)
AutoRedraw = True
BorderStyle = 0
Caption = "-"
Width = Screen.Width
Height = Screen.Height
BackColor = 0 '窗口背景黑色
Select Case ZC '文字颜色(不能跟背景一样)
Case ZC = 0
ForeColor = vbRed
Case ZC = 1
ForeColor = 65280
Case ZC = 2
ForeColor = 16711680
Case ZC = 3
ForeColor = 65535
Case ZC = 4
ForeColor = 0
Case ZC = 5
ForeColor = 16777215
Case ZC = 6
ForeColor = 16711935
Case ZC = 7
ForeColor = 8388736
Case ZC = 8
ForeColor = 8388608
Case ZC = 9
ForeColor = 8421376
Case ZC = 10
ForeColor = 14692440
Case Else
ForeColor = 8421504
End Select
print "改变颜色"
|
|