资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb点虐 颜色代码 vb文字颜色代码

VB.NET设置屏幕分辨率、颜色位数、刷新率 实例代码

这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率

十多年的六合网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整六合建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“六合网站设计”,“六合网站推广”以来,每个客户项目都认真落实执行。

实例代码,有需要的朋友可以参考一下

复制代码

代码如下:

Private

Declare

Function

GetDeviceCaps

Lib

"gdi32"

(ByVal

hdc

As

Long,

ByVal

nIndex

As

Long)

As

Long

Private

Declare

Function

ChangeDisplaySettings

Lib

"user32"

Alias

"ChangeDisplaySettingsA"

(lpDevMode

As

Any,

ByVal

dwflags

As

Long)

As

Long

Private

Const

CCDEVICENAME

As

Long

=

32

Private

Const

CCFORMNAME

As

Long

=

32

Private

Const

DM_BITSPERPEL

As

Long

=

H40000

Private

Const

DM_PELSWIDTH

As

Long

=

H80000

Private

Const

DM_PELSHEIGHT

As

Long

=

H100000

Private

Const

DM_DISPLAYFLAGS

As

Long

=

H200000

Private

Const

DM_DISPLAYFREQUENCY

=

H400000

Private

Const

CDS_FORCE

As

Long

=

H80000000

Private

Const

BITSPIXEL

As

Long

=

12

Private

Const

HORZRES

As

Long

=

8

Private

Const

VERTRES

As

Long

=

10

Private

Const

VREFRESH

=

116

Private

Type

DEVMODE

dmDeviceName

As

String

*

CCDEVICENAME

dmSpecVersion

As

Integer

dmDriverVersion

As

Integer

dmSize

As

Integer

dmDriverExtra

As

Integer

dmFields

As

Long

dmOrientation

As

Integer

dmPaperSize

As

Integer

dmPaperLength

As

Integer

dmPaperWidth

As

Integer

dmScale

As

Integer

dmCopies

As

Integer

dmDefaultSource

As

Integer

dmPrintQuality

As

Integer

dmColor

As

Integer

dmDuplex

As

Integer

dmYResolution

As

Integer

dmTTOption

As

Integer

dmCollate

As

Integer

dmFormName

As

String

*

CCFORMNAME

dmUnusedPadding

As

Integer

dmBitsPerPel

As

Integer

dmPelsWidth

As

Long

dmPelsHeight

As

Long

dmDisplayFlags

As

Long

dmDisplayFrequency

As

Long

End

Type

Private

Sub

cmdChangeDesktopMode_Click()

Dim

DM

As

DEVMODE

With

DM

.dmPelsWidth

=

CInt(txtNewWidth.Text)

.dmPelsHeight

=

CInt(txtNewHeight.Text)

.dmBitsPerPel

=

CInt(txtNewColor.Text)

.dmDisplayFrequency

=

CInt(txtNewFreq.Text)

.dmFields

=

DM_PELSWIDTH

Or

DM_PELSHEIGHT

Or

DM_BITSPERPEL

Or

DM_DISPLAYFREQUENCY

.dmSize

=

LenB(DM)

End

With

If

ChangeDisplaySettings(DM,

CDS_FORCE)

Then

MsgBox

"错误!不支持此模式!"

End

If

End

Sub

Private

Sub

Form_Load()

txtOldWidth.Text

=

GetDeviceCaps(Me.hdc,

HORZRES)

txtOldHeight.Text

=

GetDeviceCaps(Me.hdc,

VERTRES)

txtOldColor.Text

=

GetDeviceCaps(Me.hdc,

BITSPIXEL)

txtOldFreq.Text

=

GetDeviceCaps(Me.hdc,

VREFRESH)

End

Sub

vb点虐 复选框及字体颜色问题 题目是图上的第十题,计算代码我会做,但是那个红字黄底的代码怎么写

TextBox1.ForeColor = Color.Red

TextBox1.BackColor = Color.Yellow

TextBox1.Text = 1234

请问VB.NET里面改textbox文字颜色(forecolor)和背景颜色(backcolor)怎么弄?有具体的题目!!

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

If CheckBox1.Checked = True Then

TextBox1.ForeColor = Color.Red

Else

TextBox1.ForeColor = Color.Black

End If

End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

If CheckBox2.Checked = True Then

TextBox1.BackColor = Color.Yellow

Else

TextBox1.BackColor = Color.White

End If

End Sub

vb点虐 怎么实现单击数字区域的按钮使按钮变红色,单击运算符按钮变蓝色同时数字区按钮还原?紧急在线等…

您好,这种方法可以通过按钮的MouseDown和MouseUp事件来实现,比如说,当单击按钮RedColor(RedColor为这个按钮的Name属性的属性值)的时候,要使按钮的颜色变成红色,这可以在代码视图中的控件选择下拉列表中选择RedColor这个控件,然后在右边的事件下拉列表中选择MouseDown事件(当按下鼠标时发生),这时,Visual Studio会自动生成如下代码:

Private Sub RedColor_MouseDown(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles RedColor.MouseDown

End Sub

接下来就在当前生成的代码中写入如下代码:

RedColor.BackColor = Color.FromArgb(255, 0, 0)

这句代码的作用是利用Color下的FromArgb方法来设置RGB颜色参数,在RGB颜色系统中,R代表红色,G代表绿色,B代表蓝色,根据这三种颜色的不同程度的调和,就会得到不同的颜色,如果您要得到深色的天蓝色,则可以设置FromArgb(0, 191, 255),这个颜色转换为HTML中的RGB颜色就是#00BFFF。

当然颜色还原最好是写在MouseUp事件里面,这样就不必在单击其他按钮时来还原上一次按下的按钮的颜色,在这里,为了方便描述,我们假设按钮的默认颜色为白色,也就是FromArgb方法设置为FromArgb(255, 255, 255)的时候,所标示的颜色就是白色

所以选择了RedColor按钮的MouseUp事件后,Visual Studio会自动生成下列代码:

Private Sub RedColor_MouseUp(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles RedColor.MouseUp

End Sub

MouseUp的含义是当鼠标弹起时发生,所以在这个事件就可以设置按钮颜色的还原,即添加下列代码来实现:

RedColor.BackColor = Color.FromArgb(255, 255, 255)

当然,这就编写好了一个按钮按下时变色,回弹时还原的功能,至于另外一个按钮的功能,这与这个按钮的功能一样,只是代码有一些细微的差别而已,假设这个按钮的Name属性的属性值为BlueColor,相应的代码对应如下:

Private Sub BlueColor_MouseDown(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles BlueColor.MouseDown

BlueColor.BackColor = Color.FromArgb(0, 0, 255) '蓝色的FromArgb

End Sub

Private Sub BlueColor_MouseDown(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles BlueColor.MouseDown

BlueColor.BackColor = Color.FromArgb(255, 255, 255)

End Sub

另外,为了避免代码的冗余,可以将RedColor和BlueColor的MouseUp事件进行合并,这合并后的代码如下:

Private Sub BlueColor_MouseDown(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles BlueColor.MouseDown, RedColor.MouseUp

BlueColor.BackColor = Color.FromArgb(255, 255, 255)

RedColor.BackColor = Color.FromArgb(255, 255, 255)

End Sub

当然,这个你只要分析了控件事件代码的基本结构,一切就一目了然了,控件事件代码的基本结构如下:

[作用域] Sub 事件名([参数列表]) Handles 控件事件1 [, 控件事件2, 控件事件3...]

[事件代码区域]

End Sub

如果此回答对您有帮助,别忘了采纳哦,如果没有解决您的问题,您可以在互联网上寻找更多关于此问题的解决方案,谢谢!


当前名称:vb点虐 颜色代码 vb文字颜色代码
文章地址:http://cdkjz.cn/article/ddjopgs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220