Programming road - interface beauty

zhaozj2021-02-11  168

Now more and more software have a very cool 2D shape, what is ×××× xp, ×××× 2002, it seems that the position of competition for software hegemony, 2D interface is essential, there is Many people think that the innate lack of Visual Basic language causes it to change the interface very flexible, let's take a look at it. If you have used "Windows Optimization Master", it will definitely be dumped by its interface. In fact, you can use ActiveSkin to do, even more cool, but if you want to do, sharing software is just a file, plus a few OCX is cumbersome. It seems very uncomfortable, see how VB is using other stuffs to achieve it.

First create a new EXE project, then drag a few Label controls on the form, look at the powerful features of Label, the principle is to use the label to simulate a button, but first to adjust the property of the Label control, name: lblbtn, Borderstyle: 1, APPEARANCE: 0, Alignment: 2, this prototype of such a button has already come, if the engineering volume is large, you can set the Name property of multiple Label controls to the same, to identify the identification of the button Index property, and for convenience, into the code editor window, enter the following code: Private Const LBL_BACK_COLOR = & HE0E0E0 'background color Private Const normal Label control LBL_WHEN_MOUSE_MOVE = & HC0C0C0' mouse moves Label background color Private Const LBL_WHEN_MOUSE_DOWN = & H808080 'Mouse Pressing the background color of the Label in the Form's Load Event Enter the following private subform_load () Dim Count as integerfor count = 0 to 3' Please change this 3 to your LBLBTN number 1LblBtn (Count) .BackColor = LBL_BACK_COLOR 'initialization LblBtn background Next CountEnd Sub LblBtn then in the MouseMove and MouseDown event to get the remaining portion: Private Sub LblBtn_MouseDown (Index As Integer, Button As Integer, Shift As Integer, X As Single , Y as Single) 'while the mouse is pressed on the LblBtn LblBtn (Index) .BackColor = LBL_WHEN_MOUSE_DOWN' LblBtn temporary change in the background color End SubPrivate Sub LblBtn_MouseMove (Index as Integer, Button as Integer, Shift as Integer, X as Single, Y as Single) 'Mouse moves when moving on the LBLBTN, triggering the event DIM Count As integeroEvents' temporarily Quality control 权 权 系统 系统 系统 如果 如果 如果 ou 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 将 将 将 将 将 将 将 将 将 将 将 将 将 不 将 将 不 不 不 不 将 不Background is set to normal elselblbtn (index). Backcolor = lbl_when_mouse_move 'Set background Endness Countend Subprivate Sub Form_MouseMove (Button As Integer, Shift As Integer, x as single, y as single)

Dim count as integeroeventsfor count = 0 to 3lblbtn (count) .backcolor = lbl_backcolor 'Restore background Next CounteTend This "difficult" task is the simplest, the problem is coming, the Label control has no window handle How to do? But this problem has nothing to do with the questions, writing will have a decept fee :)

OK, Label control, talks about it, talking about the TextBox control, you are afraid to see the background of white colors, then change the color to raise our eyes like the sheep (why sheep? 俺I don't know, but the color of the RGB function provided by VB is not good. Here is a small TIP, RGB function Red, Green, Blue these three parameters, the resulting color is grayscale Of course, the closer, the better the white color, but you can't see you. It is recommended that the background of the TextBox is RGB (235, 235, 235), or actually combat, drag a TextBox to the form, the property settings are as follows Appearance 0BorderStyle 1MutilLine True Do not set the ScrollBars property, otherwise it will affect the results in the Form Load event to initialize TextBoxDim bkColor As LongPrivate Sub Form_Load () bkColor = RGB (235,235,235) Text1.BackColor = bkColorEnd Sub Form and in Text1 the MouseMove event: Private Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single) Text1.BorderStyle = 0End SubPrivate Sub Text1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single) DoEventStext1.Borderstyle = 1END SUB is not very COOL? Maybe you have a look at the stone era, you will feel very cool about the TEXTBOX in it, VB is not to do, the control of the focus can Use the setfocus method to set the focus, but if the control is too much on a form, is a single setfocus is too stupid? The protagonist of this section is -------- API function, first declare : Private Type Pointapi X As Long Y As Longend TypePrivate Declare Function GetCursorpos LIB "User32" Alias ​​"GetCursorpos" lpPoint As POINTAPI) As LongPrivate Declare Function WindowFromPoint Lib "user32" Alias ​​"WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As LongPrivate Declare Function SetFocus Lib "user32" Alias ​​"SetFocus" (ByVal hwnd As Long)

As long, the SETFOCUS will be confused, change it here, and change it. the name is simply furnished, in the establishment of a procedure: Public Function sSetFocus () As LongDim CPos As POINTAPI, successfull As Boolean, hWnd As LongDoEventsSuccessfull = GetCursorPos (CPos) If not successfull then exit Sub 'If it is not successful, quit the process hWnd = WindowFromPoint (Cpos.x, cpos.y) ssetfocus = nsetfocus (hwnd) End Sub put a Timer control on the form, the Interval property is set to 100, which is 0.1 seconds, fill in SSETFOCUS in the Timer event of the Timer1 control, running Look, how is the effect? ​​But Miss Miss is asking, can TextBox can't use scrollbar? Nothing, choose Engineering-> Parts -> Microsoft Windows Common Controls-2 6.0 (sp3) is your answer As for the scroll textbox to study the SendMessage function, otherwise there is a deception fee, if you want to make green software, you don't want to use the control, you can use the Label control you told before, use the font webdings to simulate scrollbar, you need to pay attention Yes, if simulating scrollbar, the arrows of the upper and lower left and left arrows are 5, 6, 3, 4, don't forget to set the font to WebDings.

Let's talk about the form of the form, actually set the BorderStyle property to 0 is a very good 2D beautification;),, this, the problem is coming, what should I do? Everything must ask the API to help, here you need two APIs , Is the declaration of the API: Public Declare Function ReleaseCapture LIB "User32" Alias ​​"ReleaseCapture" () As long 'This API is a tracker to solve the mouse, about his excessive usage and detailed introduction, you can write a letter俺 consult, there is also a public declare function sendMessage Lib "User32" Alias ​​"SendMessagea" (Byval HWnd As Long, Byval WParam As Long, LParam As Any) As long "Don't introduce more Public Const HTCAPTION = 2 'Represents the title area of ​​the form PUBLIC Const WM_NCLBUTTONDOWN = & ha1' indicates that the non-work area left mile is very simple, remove the message to the Form to send a mobile form to the Form, actually do this many ways, but I personally think that one of the most simple, add a procedure: Public Sub MoveForm (hWnd As Long) DoEventsReleaseCaptureSendMessage hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 & End Sub in MouseMove event Form of: Private Sub Form_MouseMove (Button As Integer, Shift As integer, x askLE, Y askLE) If button = vbleftbutton kilover HWND 'If the left mouse button is pressed, the lady under the mobile form END SUB is wonderful, but the bare form has no title bar. I don't look good, I want to recommend the stuff to this to Miss -ActiveX control, Toolsign, people who need it can write to the contact, the control needs to add code in the code editing area: 'Declaration is used in Toolsign Public const exit_force = 2 'for autoquit attributes, if you use this exit when running in VB, VB is also Exit Public const_Message = 1 'Send Close Message By Operating System PUBLIC ConST EXIT_CUSTOM = NOT (exit_force or exit_message)' Customize the E-Dogkid Studio Tools Sign in the part bar, add to the toolbox, Double-click to add to the form, add initialization code in the Form's LOAD event: private suform_load () with sign1.autoquit = exit_custom.parentshWnd =

HWnd 'Fill in this property directly with Toolsign to move the form without requiring the previous code endhend subsign1 Click Event Sub Sign1_Click () end' Close User End Sub Add Code in the Form's Resize event: Private Sub Form_Resize () Sign1.width = widthend Sub If you want the form to change the size, you can modify the property caption "" BorderStyle 2 or 5ControlBox False actual situation. Don't know how you see the explosion, don't you? You can have another ActiveX DLL, my stuff is actually given to my Software. If you don't discard it, you can use it, register after the project -> reference -> e-dogkid Runtime Library and enter the form Load event: Private Sub Form_Load () Dim System As e_Dogkid_Runtime_Library.SystemSet System = New e_Dogkid_Runtime_Library.SystemShowSystem.BoomIt hDC, 60, Width, Height, Left, TopSet System = NothingEnd Sub fact that I DLL There are hundreds of files to collect and write themselves, great. Different QQ numbers: 16184794, 俺 Email is e-dogkid@21cn.com

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

New Post(0)