社区
VB
帖子详情
VB6中的ScaleWidth属性VB.NET中有吗?
textexe
2009-08-02 04:07:45
我想获得窗口的内部宽度高度,VB6中直接用Scalewidth,Scaleheight就行了,VB.NET怎么办啊?
...全文
248
4
打赏
收藏
VB6中的ScaleWidth属性VB.NET中有吗?
我想获得窗口的内部宽度高度,VB6中直接用Scalewidth,Scaleheight就行了,VB.NET怎么办啊?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
textexe
2009-08-04
打赏
举报
回复
自己找到了:Me.DisplayRectangle.Width
Me.DisplayRectangle.Height
yanlongwuhui
2009-08-04
打赏
举报
回复
试下:VB6.PixelsToTwipsX(Me.ClientRectangle.Width),VB6.PixelsToTwipsY(Me.ClientRectangle.Height)
古今多少事
2009-08-03
打赏
举报
回复
没有,已不再支持……
Me.Size = New System.Drawing.Size(500, 600)'设置大小
LZ需要什么效果,NET中的一些新方法或属性可以替代实现吧……
textexe
2009-08-03
打赏
举报
回复
顶起来
基于VB客票
中
心售票系统
VERSION 5.00 Begin VB.Form FrmBackUp BackColor = &H00E7DFE7& BorderStyle = 1 'Fixed Single Caption = "备份数据库" ClientHeight = 1695 ClientLeft = 45 ClientTop = 330 Client
Width
= 4680 Icon = "FrmBackUp.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MDIChild = -1 'True MinButton = 0 'False
Scale
Height = 1695
Scale
Width
= 4680 Begin VB.CommandButton cmdExit Caption = "退出" Height = 495 Left = 2640 TabIndex = 3 Top = 840
Width
= 1455 End Begin VB.CommandButton cmdBackUp Caption = "备份" Height = 495 Left = 600 TabIndex = 2 Top = 840
Width
= 1455 End Begin VB.Label lbTime AutoSize = -1 'True BackStyle = 0 'Transparent Height = 180 Left = 240 TabIndex = 1 Top = 720 Visible = 0 'False
Width
= 90 End Begin VB.Label Label1 AutoSize = -1 'True BackStyle = 0 'Transparent Caption = "单击“备份”按钮,开始备份数据库。" Height = 180 Left = 240 TabIndex = 0 Top = 240
Width
= 3060 End End Attribute VB_Name = "FrmBackUp" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'Dim fso As New FileSystemObject, fldr As Folder Dim cn As ADODB.Connection Dim success As Long Private Sub cmdBackUp_Click() Dim backFile As String Dim NowTime As String Dim sql As String Dim buff As String If fso.FolderExists(App.Path & "\BackUp") = False Then Set fldr = fso.CreateFolder(App
VB窗体控件大小随窗体大小变化而变化
VB窗体控件大小随窗体大小变化自動調整 有时窗体变化后,如改变分辨率后控件大小却不能随之改变。手工代码调整实在麻烦,下面的模块实现自动查找窗体上控件并使其改变大小以适应窗体变化。 在Form的Resize事件
中
调用函数Resize_All就能实现控件自动调整大小,如: Private Sub Form_Resize() Dim H, i As Integer On Error Resume Next Resize_ALL Me 'Me是窗体名,Form1,Form2等等都可以 End Sub 在模块
中
添加以下代码: Public Type ctrObj Name As String Index As Long Parrent As String Top As Long Left As Long Height As Long
Width
As Long
Scale
Height As Long
Scale
Width
As Long End Type Private FormRecord() As ctrObj Private ControlRecord() As ctrObj Private bRunning As Boolean Private MaxForm As Long Private MaxControl As Long Private Const WM_NCLBUTTONDOWN = &HA1 Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function ReleaseCapture Lib "USER32" () As Long Function ActualPos(plLeft As Long) As Long If plLeft < 0 Then ActualPos = plLeft + 75000 Else ActualPos = plLeft End If End Function Function FindForm(pfrmIn As Form) As Long Dim i As Long FindForm = -1 If MaxForm > 0 Then For i = 0 To (MaxForm - 1) If FormRecord(i).Name = pfrmIn.Name Then FindForm = i Exit Function End If Next i End If End Function Function AddForm(pfrmIn As Form) As Long Dim FormControl As Control Dim i As Long ReDim Preserve FormRecord(MaxForm + 1) FormRecord(MaxForm).Name = pfrmIn.Name FormRecord(MaxForm).Top = pfrmIn.Top FormRecord(MaxForm).Left = pfrmIn.Left FormRecord(MaxForm).Height = pfrmIn.Height FormRecord(MaxForm).
Width
= pfrmIn.
Width
FormRecord(MaxForm).
Scale
Height = pfrmIn.
Scale
Height FormRecord(MaxForm).
Scale
Width
= pfrmIn.
Scale
Width
AddForm = MaxForm MaxForm = MaxForm + 1 For Each FormControl In pfrmIn i = FindControl(FormControl, pfrmIn.Name) If i < 0 Then i = AddControl(FormControl, pfrmIn.Name) End If Next FormControl End Function Function FindControl(inControl As Control, inName As String) As Long Dim i As Long FindControl = -1 For i = 0 To (MaxControl - 1) If ControlRecord(i).Parrent = inName Then If ControlRecord(i).Name = inControl.Name Then On Error Resume Next If ControlRecord(i).Index = inControl.Index Then FindControl = i Exit Function End If On Error GoTo 0 End If End If Next i End Function Function AddControl(inControl As Control, inName As String) As Long ReDim Preserve ControlRecord(MaxControl + 1) On Error Resume Next ControlRecord(MaxControl).Name = inControl.Name ControlRecord(MaxControl).Index = inControl.Index ControlRecord(MaxControl).Parrent = inName If TypeOf inControl Is Line Then ControlRecord(MaxControl).Top = inControl.Y1 ControlRecord(MaxControl).Left = ActualPos(inControl.X1) ControlRecord(MaxControl).Height = inControl.Y2 ControlRecord(MaxControl).
Width
= ActualPos(inControl.X2) Else ControlRecord(MaxControl).Top = inControl.Top ControlRecord(MaxControl).Left = ActualPos(inControl.Left) ControlRecord(MaxControl).Height = inControl.Height ControlRecord(MaxControl).
Width
= inControl.
Width
End If inControl.IntegralHeight = False On Error GoTo 0 AddControl = MaxControl MaxControl = MaxControl + 1 End Function Function Per
Width
(pfrmIn As Form) As Long Dim i As Long i = FindForm(pfrmIn) If i < 0 Then i = AddForm(pfrmIn) End If Per
Width
= (pfrmIn.
Scale
Width
* 100) \ FormRecord(i).
Scale
Width
End Function Function PerHeight(pfrmIn As Form) As Double Dim i As Long i = FindForm(pfrmIn) If i < 0 Then i = AddForm(pfrmIn) End If PerHeight = (pfrmIn.
Scale
Height * 100) \ FormRecord(i).
Scale
Height End Function Public Sub ResizeControl(inControl As Control, pfrmIn As Form) On Error Resume Next Dim i As Long Dim
width
factor As Single, heightfactor As Single Dim minFactor As Single Dim yRatio, xRatio, lTop, lLeft, l
Width
, lHeight As Long yRatio = PerHeight(pfrmIn) xRatio = Per
Width
(pfrmIn) i = FindControl(inControl, pfrmIn.Name) If inControl.Left < 0 Then lLeft = CLng(((ControlRecord(i).Left * xRatio) \ 100) - 75000) Else lLeft = CLng((ControlRecord(i).Left * xRatio) \ 100) End If lTop = CLng((ControlRecord(i).Top * yRatio) \ 100) l
Width
= CLng((ControlRecord(i).
Width
* xRatio) \ 100) lHeight = CLng((ControlRecord(i).Height * yRatio) \ 100) If TypeOf inControl Is Line Then If inControl.X1 < 0 Then inControl.X1 = CLng(((ControlRecord(i).Left * xRatio) \ 100) - 75000) Else inControl.X1 = CLng((ControlRecord(i).Left * xRatio) \ 100) End If inControl.Y1 = CLng((ControlRecord(i).Top * yRatio) \ 100) If inControl.X2 < 0 Then inControl.X2 = CLng(((ControlRecord(i).
Width
* xRatio) \ 100) - 75000) Else inControl.X2 = CLng((ControlRecord(i).
Width
* xRatio) \ 100) End If inControl.Y2 = CLng((ControlRecord(i).Height * yRatio) \ 100) Else inControl.Move lLeft, lTop, l
Width
, lHeight inControl.Move lLeft, lTop, l
Width
inControl.Move lLeft, lTop End If End Sub Public Sub ResizeForm(pfrmIn As Form) Dim FormControl As Control Dim isVisible As Boolean Dim StartX, StartY, MaxX, MaxY As Long Dim bNew As Boolean If Not bRunning Then bRunning = True If FindForm(pfrmIn) < 0 Then bNew = True Else bNew = False End If If pfrmIn.Top < 30000 Then isVisible = pfrmIn.Visible On Error Resume Next If Not pfrmIn.MDIChild Then On Error GoTo 0 ' ' pfrmIn.Visible = False Else If bNew Then StartY = pfrmIn.Height StartX = pfrmIn.
Width
On Error Resume Next For Each FormControl In pfrmIn If FormControl.Left + FormControl.
Width
+ 200 > MaxX Then MaxX = FormControl.Left + FormControl.
Width
+ 200 End If If FormControl.Top + FormControl.Height + 500 > MaxY Then MaxY = FormControl.Top + FormControl.Height + 500 End If If FormControl.X1 + 200 > MaxX Then MaxX = FormControl.X1 + 200 End If If FormControl.Y1 + 500 > MaxY Then MaxY = FormControl.Y1 + 500 End If If FormControl.X2 + 200 > MaxX Then MaxX = FormControl.X2 + 200 End If If FormControl.Y2 + 500 > MaxY Then MaxY = FormControl.Y2 + 500 End If Next FormControl On Error GoTo 0 pfrmIn.Height = MaxY pfrmIn.
Width
= MaxX End If On Error GoTo 0 End If For Each FormControl In pfrmIn ResizeControl FormControl, pfrmIn Next FormControl On Error Resume Next If Not pfrmIn.MDIChild Then On Error GoTo 0 pfrmIn.Visible = isVisible Else If bNew Then pfrmIn.Height = StartY pfrmIn.
Width
= StartX For Each FormControl In pfrmIn ResizeControl FormControl, pfrmIn Next FormControl End If End If On Error GoTo 0 End If bRunning = False End If End Sub Public Sub SaveFormPosition(pfrmIn As Form) Dim i As Long If MaxForm > 0 Then For i = 0 To (MaxForm - 1) If FormRecord(i).Name = pfrmIn.Name Then FormRecord(i).Top = pfrmIn.Top FormRecord(i).Left = pfrmIn.Left FormRecord(i).Height = pfrmIn.Height FormRecord(i).
Width
= pfrmIn.
Width
Exit Sub End If Next i AddForm (pfrmIn) End If End Sub Public Sub RestoreFormPosition(pfrmIn As Form) Dim i As Long If MaxForm > 0 Then For i = 0 To (MaxForm - 1) If FormRecord(i).Name = pfrmIn.Name Then If FormRecord(i).Top < 0 Then pfrmIn.WindowState = 2 ElseIf FormRecord(i).Top < 30000 Then pfrmIn.WindowState = 0 pfrmIn.Move FormRecord(i).Left, FormRecord(i).Top, FormRecord(i).
Width
, FormRecord(i).Height Else pfrmIn.WindowState = 1 End If Exit Sub End If Next i End If End Sub Public Sub Resize_ALL(Form_Name As Form) Dim OBJ As Object For Each OBJ In Form_Name ResizeControl OBJ, Form_Name Next OBJ End Sub Public Sub DragForm(frm As Form) On Local Error Resume Next Call ReleaseCapture Call SendMessage(frm.hwnd, WM_NCLBUTTONDOWN, 2, 0) End Sub
vb圆形窗体
VERSION 5.00 Begin VB.Form Form1 BackColor = &H80000000& Caption = "椭圆窗体" ClientHeight = 3330 ClientLeft = 60 ClientTop = 345 Client
Width
= 4860 FillColor = &H00FF0000& BeginProperty Font Name = "宋体" Size = 12 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00FF0000& Icon = "Form1.frx":0000 LinkTopic = "Form1" Picture = "Form1.frx":000C
Scale
Height = 3330
Scale
Width
= 4860 StartUpPosition = 2 '屏幕
中
心 End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True 'Download by http://www.codefans.net Attribute VB_Exposed = False 'CODE Manger By BcodeXRose Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long '################################################################## '## 过程名称:Form_Load '## 参数: 无 '################################################################## Private Sub Form_Load() Dim rwnd, x2, y2 x2 =
Scale
X(Me.
Width
, vbTwips, vbPixels) y2 =
Scale
Y(Me.Height, vbTwips, vbPixels) SetWindowRgn Me.hWnd, CreateEllipticRgn(0, 20, x2, y2), True End Sub
VB长度宽度高度单位,
width
,
scale
Width
,Height,
scale
Height,
scale
Mode
如何理解VB窗体
中
的
scale
类
属性
及
width
height
属性
之间的关系 VB
中
的
SCALE
HIEGT,
SCALE
WIDTH
,与窗体
中
的
WIDTH
,HEIGHT的区别及关系是许多VB初学者难以理解的。本人在学习DELPHI的过程
中
也曾经对这类似的概论搞不清楚,但通过这次对VB
中
这些类似概念的学习后,可以说是已掌握了这种概念及原理了。现在回头看DELPHI的相关知识点有豁然开朗的感觉,
VB.Net
串口通信用法
vb.net
教程https://www.xin3721.com/eschool/vbnetxin3721/ 点击下载本文配套的演示程序代码https://files.cnblogs.com/xdesigner/VB-CS-WinformControl.zip。 一.前言: 虽然IT开发技术日新月异,不过业界仍然运行着大量的VB系统,这些系统凝聚了不少客户的投资,应当要一定程度的保护和利用。因此也就产生了一种需求,也就是使用旧的开发技术仍然可以使用新技术的产出。本文就讨论如何在
VB6
.0开发
中
使用上
VB
16,556
社区成员
110,528
社区内容
发帖
与我相关
我的任务
VB
VB技术相关讨论,主要为经典vb,即VB6.0
复制链接
扫一扫
分享
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章