Label1的Caption颜色的问题。

hwchwc 2004-08-23 02:09:00
表AA的FONT_C字段(字符型)有一记录的值是Red,想让LABEL1上的文字的颜色为Red:
Label1->Font->Color=sjhjDataModule->IBQuery->FieldByName("FONT_C")->AsString;
这样写有错误?该如何写!但
Label1->Font->Color=Red;就可以。
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
arraden 2004-08-23
  • 打赏
  • 举报
回复
楼上说了
ccrun.com 2004-08-23
  • 打赏
  • 举报
回复
Label1->Font->Color = StringToColor(sjhjDataModule->IBQuery->FieldByName("FONT_C")->AsString);

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Private Declare Function GetCursorPos Lib "user32" (lpPoint As pointapi) As Long Private Declare Function CreateDCA& Lib "gdi32" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Type pointapi X As Long Y As Long End Type Private Sub Command1_Click() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Me.BackColor = GetPixel(a, p.X, p.Y) Command1.Caption = GetPixel(a, p.X, p.Y) DeleteDC a End Sub Private Sub Command2_Click() 'Shell "C:\WINDOWS\Pbrush.exe c:\9.bmp", 1 'SendKeys ("%{f}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%a") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") 'SendKeys ("%{F4}") End Sub Private Sub Command3_Click() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Label3.Caption = GetPixel(a, Text2.Text, Text3.Text) Label4.Caption = GetPixel(a, Text4.Text, Text5.Text) End Sub Private Sub Command4_Click() Form2.Show End Sub Private Sub Command5_Click() Cls For i = 1 To 85 Print ti(i) Next i End Sub Private Sub Command6_Click() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Public kaohao, haowei(10), kh(10, 10) As Integer Public kemu As String 10: '读取答题卡信息点作标 Dim fileso As New Scripting.FileSystemObject Dim ts As TextStream Set ts = fileso.OpenTextFile("\\teacher\记录$\a卡zuobiao.txt", ForReading, 1) '识别a 卡 X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then GoTo 100 '如果是b卡则专到100执行 '识别科目 X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "综文" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "数学" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "外语" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "理综" '识别10位考号 For i = 0 To 10 For j = 0 To 10 X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then haowei(i) = j Next j Next i For i = 0 To 10 kaohao = kaohao & haowei(i) Next '识别80道判断题 For i = 1 To 80 X = ts.ReadLine Y = ts.ReadLine a(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine b(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine c(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine d(i) = GetPixel(a, X, Y) If ti(i) = a(i) * 1 + b(i) * 2 + c(i) * 4 + d(i) * 8 Then fenshu = fenshu + 1 Next i 100: '识别b卡 Set ts = fileso.OpenTextFile("\\teacher\记录$\b卡zuobiao.txt", ForReading, 1) '识别b卡 X = ts.ReadLine Y = ts.ReadLine 'If GetPixel(a, x, y) = 0 Then GoTo 100 '如果是a卡则专到50执行 '识别科目 X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "综文" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "数学" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "外语" X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then kemu = "理综" '识别10位考号 For i = 0 To 10 For j = 0 To 10 X = ts.ReadLine Y = ts.ReadLine If GetPixel(a, X, Y) = 0 Then haowei(i) = j Next j Next i For i = 0 To 10 kaohao = kaohao & haowei(i) Next '识别80道判断题 For i = 1 To 80 X = ts.ReadLine Y = ts.ReadLine a(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine b(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine c(i) = GetPixel(a, X, Y) X = ts.ReadLine Y = ts.ReadLine d(i) = GetPixel(a, X, Y) If ti(i) = a(i) * 1 + b(i) * 2 + c(i) * 4 + d(i) * 8 Then fenshu = fenshu + 1 Next i Set shuju = zhuce.OpenTextFile("\\teacher\记录$\fenshu.txt", ForAppending, True) shuju.WriteLine xingming shuju.WriteLine xuehao shuju.WriteLine fenshu shuju.WriteLine kemu If fenshu = 0 Then GoTo 500 '如果部分为0则专到结束 shuju.WriteLine "@@@@@@@@@@" GoTo 10 500: MsgBox "识别结束,请查看\\teacher\记录$\fenshu.txt" End Sub Private Sub Command7_Click() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) 'GetCursorPos p 'Me.BackColor = GetPixel(a, p.X, p.Y) 'Command1.Caption = GetPixel(a, p.X, p.Y) For j = 1 To Int(Text6.Width / 22) For i = 1 To Int(Text6.Height / 22) X = i Y = j m = m + 1 'a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) 'GetCursorPos p If GetPixel(a, X, Y) > 0 Then Print " "; If GetPixel(a, X, Y) = 0 Then Print "a"; Print ""; ';If m > 15 Then Print: m = 0 Next i Print Next j 'Dim a As Long 'Dim p As pointapi 'Me.BackColor = GetPixel(a, p.X, p.Y) 'Command1.Caption = GetPixel(a, p.X, p.Y) Label1.Caption = X Label2.Caption = Y DeleteDC a End Sub Private Sub Command8_Click() End End Sub Private Sub Form_Load() Set Image1 = LoadPicture("c:\9.bmp") 'Shell "C:\WINDOWS\Pbrush.exe c:\9.bmp", 1 End Sub Private Sub Image1_Click() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Me.BackColor = GetPixel(a, p.X, p.Y) Command1.Caption = GetPixel(a, p.X, p.Y) Label1.Caption = p.X Label2.Caption = p.Y DeleteDC a Dim fileso As New Scripting.FileSystemObject Dim ts As TextStream Set ts = fileso.OpenTextFile("\\teacher\记录$\zuobiao.txt", ForAppending, 1) ts.Write " x:" ts.Write Label1.Caption For i = 0 To 5 - Len(Label1.Caption) ts.Write " " Next i ts.Write " y:" ts.Write Label2.Caption For i = 0 To 5 - Len(Label2.Caption) ts.Write " " Next i ts.WriteLine End Sub Private Sub Text1_DblClick() Cls Text6.Text = Text1.Text End Sub Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) Cls Text6.Text = Text1.Text Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) 'GetCursorPos p 'Me.BackColor = GetPixel(a, p.X, p.Y) 'Command1.Caption = GetPixel(a, p.X, p.Y) jc = Text6.Width / 16 ic = Text6.Height / 16 For j = 1 To Int(Text6.Width / jc) For i = 1 To Int(Text6.Height / ic) X = i Y = j m = m + 1 'a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) 'GetCursorPos p If GetPixel(a, X, Y) > 0 Then Print " "; If GetPixel(a, X, Y) = 0 Then Print "a"; Print ""; ';If m > 15 Then Print: m = 0 Next i Print Next j 'Dim a As Long 'Dim p As pointapi 'Me.BackColor = GetPixel(a, p.X, p.Y) 'Command1.Caption = GetPixel(a, p.X, p.Y) Label1.Caption = X Label2.Caption = Y DeleteDC a End Sub Private Sub Text6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Me.BackColor = GetPixel(a, p.X, p.Y) Command1.Caption = GetPixel(a, p.X, p.Y) DeleteDC a End Sub Private Sub Text7_Change() Cls End Sub Private Sub Timer1_Timer() Dim a As Long Dim p As pointapi a = CreateDCA("DISPLAY", vbNullString, vbNullString, 0) GetCursorPos p Me.BackColor = GetPixel(a, p.X, p.Y) Command1.Caption = GetPixel(a, p.X, p.Y) Label1.Caption = p.X Label2.Caption = p.Y DeleteDC a 'SendKeys "你好" 'SendKeys "{enter}" ''Shell ("C:\显示桌面.scf") 'Shell "C:\WINDOWS\Pbrush.exe c:\3333.bmp", 1 'SendKeys ("%{F4}") 'SendKeys "a" End Sub Private Sub Timer2_Timer() 'SendKeys ("%{F4}") 'SendKeys ("%{f}") 'Timer2.Interval = 0 'SendKeys "你好" 'SendKeys "{enter}" ''Shell ("C:\显示桌面.scf") 'Shell "C:\WINDOWS\Pbrush.exe c:\3333.bmp", 1 'SendKeys ("%{F4}") 'Shell "C:\WINDOWS\Pbrush.exe c:\3333.bmp", 1 End Sub Private Sub Timer3_Timer() 'SendKeys ("{a}") Timer3.Interval = 0 End Sub Private Sub Timer4_Timer() 'SendKeys ("{tab}") 'SendKeys ("{单}") 'SendKeys ("{tab}") 'SendKeys ("{s}") 'SendKeys ("{y}") 'SendKeys ("{y}") 'SendKeys ("%{F4}") Timer4.Interval = 0 End Sub
看实例学VFP:复选框控件 时间:2009-03-24来源:编程入门网 作者:老马   在vfp基础教程-复选框一文中,已经给出了复选框控件的常用属性。这个控件的使用重点是对它的value属性值的判断上,另外也可以通过controlsource属性把它和表中的某个逻辑型字段绑定,同时也可以在它支持的click、interactiveChange等事件中进行编程。   本文是一个在复选框控件的interactiveChange事件中编程的小例子,运行时通过复选框的选择来控制label控件的文字大小及颜色变化,运行界面如下:   制作步骤:   一、新建表单,将其caption属性值设置为“编程入门网-复选框控件”,保存为“复选框控件.scx”。   二、向表单上添加一个label控件,caption属性值设为“编程入门网”,fontsize属性值设为10,AutoSize属性值设为.t.,Forecolor属性值设为“0,0,255”(rgb颜色)   三、向表单添加两个复选框控件,caption属性值依次设置为“增大字号”和“改变颜色”,其它属性值采用默认的。   四、添加事件代码:   1.复选框check1(“增大字号”)的interactiveChange事件: if this.value=1 thisform.label1.fontsize=18 else thisform.label1.fontsize=10 endif   2.复选框check2(“改变颜色”)的interactiveChange事件: if this.value=1 thisform.label1.forecolor=rgb(255,0,0) else thisform.label1.forecolor=rgb(0,0,255) endif

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧