| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1389 人关注过本帖
标题:求助,为什么FORM2字体颜色没有改变呀
只看楼主 加入收藏
wdf126
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-9-16
结帖率:0
收藏
 问题点数:0 回复次数:1 
求助,为什么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 18:13编辑过]

搜索更多相关主题的帖子: Long Private Sub ByVal Case 
2019-05-23 09:01
wufuzhang
Rank: 9Rank: 9Rank: 9
来 自:广州
等 级:贵宾
威 望:21
帖 子:206
专家分:1346
注 册:2017-8-9
收藏
得分:0 
回复 楼主 wdf126
你这代码问题还挺多的:
1、全局变量怎么能在窗体模块中定义能,要在模块中定义
2、Form2中用Select Case 语句时,格式为Case 值或表达式,ZC=0、ZC=1。。。。。。。都是错的
3、Form2窗体上没有任何文字,你怎么知道窗体字体颜色没有修改?你可以Debug.Print Me.ForeColor
   在立即窗口(Ctrl+G)中查看,或者在窗体中添加一个Text控件,修改该控件的前景色。


PS:我试了一下,是可以修改颜色的。

不经历千百遍的调试,怎能体会成功时那一刹那的喜悦。
2019-05-23 10:55
快速回复:求助,为什么FORM2字体颜色没有改变呀
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032576 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved