关于用VB做更漂亮的窗体的思考
2009-05-12 22:24:41来源:未知 阅读 ()
近来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来模拟都足足有余.-------------
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- .net实现压缩功能的方法 2019-10-08
- asp.net如何读取配置文件 2019-09-17
- 关于FileStreaReder和StreamReader的介绍 2019-08-26
- 关于ASP.NET 前后台调用 2019-08-09
- 关于ASP.net路径问题 2019-08-09
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash