如果想让MDI窗体内的子窗体象VB环境中的工具窗体及属性和窗体列表窗体一样固定其位置,让其它子窗体即使最大化,也只能拥有固定窗体占有后剩下的空间,要怎么写呢,多谢高手指点!!在线等高手回复!!
解决方案 »
- 求个vb的学生管理系统代码 或者数据库设计模型 有简单的功能就可以
- 用VB控制WebBrowser控件访问页面,可不可以不加载图片?
- 具备一点VB基础,请大家帮忙推荐一本重点讲ADO的好书吧??!!
- 在VB中能不能调用Win的默认程序打开文本文件?
- 字符串问题
- 请教:ActiveX控件不能创建对象??(有分)
- 数据导入,高分求解
- 谁有VB与DDE的电子书籍,有下载地址也可以。
- ADO Data控件?急??
- VB中菜单的集合是什么?我想历遍所以的菜单和子菜单,如果不历遍,有没有一个属性可以直接使所有的菜单隐藏?
- datagrid怎么样import到excel中?
- active report2 打印MsflexGird的问题!
Private sub Form_Resize()
if me.WindowState=vbMaximized then
me.WindowState=vbNormal
me.move 0,100,800,400 ''这个句子就是改变你的窗体为固定大小的!
endif
End Sub
frmMain的Code
Option Explicit
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)Private Sub Form_Load()
Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
Show
frmDock.Show , Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End SubPrivate Sub picHolder_Paint()
picTitle.Width = picHolder.ScaleWidth
picSizer.Visible = picHolder.Align > 0 frmDock.picContents.Width = picHolder.ScaleWidth
frmDock.picContents.Height = picHolder.ScaleHeight
frmDock.picContents_Resize
End SubPrivate Sub picSizer_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Dim nSide As Integer
If picHolder.Visible Then
'// need to do this or SendMessage fails
ReleaseCapture
'// Send message to start resizing frmDocking.Picture1
Select Case picSizer.Align
Case vbAlignRight
nSide = HTLEFT
Case vbAlignLeft
nSide = HTRIGHT
Case vbAlignTop
nSide = HTBOTTOM
Case vbAlignBottom
nSide = HTTOP
End Select
SendMessage picHolder.hwnd, WM_NCLBUTTONDOWN, nSide, ByVal &O0
If picHolder.Width < 500 Then picHolder.Width = 500
If picHolder.Height < 500 Then picHolder.Height = 500
picHolder_Resize
End If
Else End If
End SubPrivate Sub picSizer_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If picSizer.Width > picSizer.Height Then
picSizer.MousePointer = 7
Else
picSizer.MousePointer = 9
End IfEnd SubPrivate Sub picSizer_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
picSizer.BackColor = &H8000000A
Call frmDock.picContents_Resize
End SubPrivate Sub picTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > frmDock.picTitle.Width Then X = frmDock.picTitle.Width \ 2
firstDown.X = X
firstDown.Y = Y
End SubPrivate Sub picTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
'SendMessage frmDock.picTitle.hwnd, WM_LBUTTONDOWN, 0, 0
frmDock.picTitle_MouseMove 1, Shift, X, Y
End SubPrivate Sub picTitle_Paint()
picTitle.Cls
picTitle.Print "Teste"
End SubPrivate Sub picHolder_Resize()
picTitle.Width = picHolder.ScaleWidth
picSizer.Visible = picHolder.Align > 0 frmDock.picContents.Width = picHolder.ScaleWidth
frmDock.picContents.Height = picHolder.ScaleHeight
frmDock.picContents_Resize
End Sub
frmDock的CodePublic Sub Form_Resize()
picContents.Height = Me.Height - picTitle.Height - 50
picContents.Width = Width
End SubPublic Sub picContents_Resize()
'File1.Move 0, 0, picContents.Width, picContents.Height - 200
' File1.Width = picContents.Width
' File1.Height = picContents.Height
If GetParent(picContents.hwnd) = Me.hwnd Then
File1.Width = picContents.Width - 100
File1.Height = picContents.Height
Else
File1.Width = picContents.Width
File1.Height = picContents.Height - 500
End If
End SubPrivate Sub picTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
firstDown.X = X
firstDown.Y = Y
End SubPublic Sub picTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
Dim pp As POINTAPI
GetCursorPos pp
pp.Y = pp.Y * Screen.TwipsPerPixelY
pp.X = pp.X * Screen.TwipsPerPixelX
Me.Top = pp.Y - firstDown.Y
Me.Left = pp.X - firstDown.X
'fMainForm.picHolder.Width = Me.Width
Dim tmp
If (pp.Y > fMainForm.Top And _
pp.Y < fMainForm.Top + fMainForm.picSnap.Height And _
pp.X > fMainForm.Left And pp.X < fMainForm.Left _
+ fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignTop
' fMainForm.picHolder.Width = fMainForm.Width
fMainForm.picHolder.Height = Me.Height
'
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top + fMainForm.Height - fMainForm.picSnap.ScaleHeight And _
pp.Y < fMainForm.Top + fMainForm.Height And _
pp.X > fMainForm.Left And pp.X < fMainForm.Left _
+ fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignBottom
' fMainForm.picHolder.Width = fMainForm.Width
fMainForm.picHolder.Height = Me.Height
'
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top And pp.Y < fMainForm.Top + fMainForm.Height And pp.X > fMainForm.Left And pp.X < fMainForm.Left + fMainForm.picSnap.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignLeft
fMainForm.picHolder.Width = Me.Width
' fMainForm.picHolder.Height = Me.Height
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top And pp.Y < fMainForm.Top + fMainForm.Height And pp.X > fMainForm.Left + fMainForm.Width - fMainForm.picSnap.Width And pp.X < fMainForm.Left + fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignRight
fMainForm.picHolder.Width = Me.Width
' fMainForm.picHolder.Height = Me.Height
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
Else
fMainForm.picHolder.Visible = False
Visible = True
If GetParent(picContents.hwnd) <> Me.hwnd Then _
SetParent picContents.hwnd, Me.hwnd
End If
picContents.Refresh
picTitle_Paint
fMainForm.picSizer.Align = 0
fMainForm.picSizer.Align = fMainForm.picHolder.Align
Select Case fMainForm.picSizer.Align
Case vbAlignTop, vbAlignBottom
fMainForm.picSizer.Height = 80
Case vbAlignRight, vbAlignLeft
fMainForm.picSizer.Width = 80
End Select
If GetParent(picContents.hwnd) = Me.hwnd Then picContents.Height = Me.Height - picTitle.Height - 50
picContents.Width = Width
End If
End SubPrivate Sub picTitle_Paint()
picTitle.Cls
picTitle.Print "Teste"
End Sub