首页 > 开发 > 综合 > 正文

关于用VB做更漂亮的窗体的思考

2024-07-21 02:21:01
字体:
来源:转载
供稿:网友
注册会员,创建你的web开发资料库,首先申明:以下纯属个人观点!

  近来vb版中有一部分人问关于界面的美化问题.其实作为一个菜鸟.我也无法提供很专业的代码给大家.想必大家对如下代码应该很熟悉吧!

private declare function getwindowlong lib "user32" alias "getwindowlonga" (byval hwnd as long, byval nindex as long) as long
private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong 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 const ws_ex_layered = &h80000
private const gwl_exstyle = (-20)
private const lwa_alpha = &h2
private const lwa_colorkey = &h1
private declare function releasecapture lib "user32" () as long
private declare function sendmessage lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any) as long
private const wm_nclbuttondown = &ha1
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 sub form_load()
me.backcolor = &hff0000
dim rtn as long
borderstyler = 0
rtn = getwindowlong(hwnd, gwl_exstyle)
rtn = rtn or ws_ex_layered
setwindowlong hwnd, gwl_exstyle, rtn
setlayeredwindowattributes hwnd, &hff0000, 0, lwa_colorkey
end sub

--------------------------------------------

private sub form_mousedown(button as integer, shift as integer, x as single, y as single)
releasecapture
sendmessage me.hwnd, wm_nclbuttondown, 2, 0

end sub

这是美化窗体的时候很好的办法,比用编程语句描述一个特殊形状的窗体要简单的多,只要选自己合意的图片即可!

我们都知道象picturebox,combox,菜单,等等其实都是窗体.由此可以推出我们可以用替换法将其替换.当然这是我的设想了;毕竟我不是高手.

举个例子:

我想做一个图形化的按纽.那么我们可以用image来摸拟.用imagelist放三张图片用来表示mouse_on,mouse_down,mouse_up.当然如果你要求高一点可以用api来弥补其中的不足,使之更完善.

当然象checkbox,options用image来模拟都足足有余.-------------

只要设一个全局变量为boolean就行了.它们只要两张图片就够了.自己画还是引用 就随你便了.

好了例子也举完了.总结一下:

我想说的就是其实做界面并不是技术高才能做的.转个圈其实用一些简单的方法也可以解决的.

只要大家敢想什么都会变成现实!

希望我也能抛砖引玉啊,当然前提是老大们能用啊^_^.

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表