Thoughts on doing more beautiful forms with VB

zhaozj2021-02-16  93

First of all, declare: The following is purely personal view!

Some people in the VB version have asked about the beautification of the interface. In fact, as a rookie. I can't provide a very professional code to everyone. I want everyone to be very familiar with the following code!

Private Declare Function GetWindowLong Lib "user32" Alias ​​"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias ​​"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = & H80000Private Const GWL_EXSTYLE = (-20) Private Const LWA_ALPHA = & H2Private const LWA_COLORKEY = & H1Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Declare Function SendMessage Lib "user32" Alias ​​"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate const WM_NCLBUTTONDOWN = & Ha1private 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 = & HFF0000Dim 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_COLORKEYEND SUB ----------------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X as Single, Y As Single) ReleaseCaptureendMessage Me.hwnd, WM_NCLButtondown, 2, 0

End Sub

This is a good way to beautify the form, which describes a special shape of a special shape with a programming statement, as long as you choose your own image!

We all know that pictures of Picturebox, Combox, menu, and so on are actually a form. This can be launched that we can replace it with a replacement method. Of course, this is my idea; after all, I am not a master.

for example:

I want to make a graphic letter. Then we can touch it with image. Use imagelist to put three images used to represent mouse_on, mouse_down, mouse_up. Of course, if you require a high point to use the API to make up for the shortcomings, make it more perfect.

Of course, the simulation is enough to simulate the simulation of Checkbox, Options. -------------

Just set a global variable to Boolean. They are enough as long as two pictures are enough. I will still come back by yourself.

A good example is also finished. in conclusion:

What I want to say is that it is not a technical high to do it. Turning a circle It is also a simple method can also be solved.

As long as everyone dares to think, they will become a reality!

I hope I can also throw a jade, of course, the premise is that the boss can use it ^ _ ^.

转载请注明原文地址:https://www.9cbs.com/read-11563.html

New Post(0)