开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1190|回复: 2
收起左侧

[其它] 为什么字体颜色不改变呀

[复制链接]
发表于 2019-5-23 08:56:06 | 显示全部楼层 |阅读模式   广西壮族自治区河池市
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

 楼主| 发表于 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 "改变颜色"
回复 支持 反对

使用道具 举报

发表于 2019-5-23 11:03:46 | 显示全部楼层   河南省周口市
看看是什么操作
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表