Use VB design to adapt to interfaces of various display properties

zhaozj2021-02-11  199

Use VB design to adapt to interfaces of various display properties (join time: 2001-1-22)

Author: Transfer: vb lovers ---- in the design of general application software, hoping to design the software, regardless of the display resolution setting is 640X480, 800X600 or 1024X768, whether the display is set in large fonts or small fonts software can be normal Run and have a beautifully consistent interface. This person is also encountered when using the VB5.0 "British Intelligence Training System V2.0". The method of explaining this question next time. - - 1: In order to enable interface elements to have reasonable layout at various display resolutions, one method is to obtain the current display resolution, then calculate the interface according to this resolution The location and size of the elements are set. Although this method can solve the problem of interfacial element, it is necessary to know the position and size of each element, and the programs are bored. ---- The method used in this is: First set up a window with a maximized, boundary, no title, no-controlled box, then place a container control Picture, put it in Picture. In the resolution of the display resolution in the top of the window, the entire interface is now realized. Specific code as follows: Private Sub Form_Load () Call CenterControl (Picture1) End SubPublic Sub CenterControl (obj As Object) Dim cx, cy As Singlecx = (Screen.Width / Screen.TwipsPerPixelX-obj.Width) / 2 # cy = (Screen .Height / screen.twipsperpixely-obj.height) /2#obj.Left = cxobj.top = cyend sub ---- 2: Make the interface to the big font and small font - Win95 is based on the creation control The current display attribute is a big font or a small font to make a corresponding adjustment. Although the parameters (control position and size) that should be transmitted should be used, the position and size of the actual controls are not in these two cases. If the application is only considering only the situation of small fonts, it is difficult to look down in the big font, and it is not possible to operate. In order to solve this problem, the first should first solve the previous display, which can be obtained through the system registration table.

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

New Post(0)