窗口自适应问题。

lovercat 2002-06-30 11:17:27
怎么能让mdi父窗口自适应屏幕,子窗口自适应父窗口始终在中间并且要完全显示控件。 给个例子
...全文
74 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovercat 2002-06-30
  • 打赏
  • 举报
回复
最大化不理想。

控制位置的方法最好有个比较完美的例子
NowCan 2002-06-30
  • 打赏
  • 举报
回复
将WindowState改成最大化
zyl910 2002-06-30
  • 打赏
  • 举报
回复
.Left、.Top、.Width、.Height
gmlwx 2002-06-30
  • 打赏
  • 举报
回复
同意,这么简单不用这么复杂化
QQRN 2002-06-30
  • 打赏
  • 举报
回复
用 .Left、.Top、.Width、.Height 加点计算就可以了
弄得这么复杂干嘛……
cqfanli 2002-06-30
  • 打赏
  • 举报
回复
用 .Left、.Top、.Width、.Height 就可以了

可以不用API。

最大化還是可以的
mickwang 2002-06-30
  • 打赏
  • 举报
回复








以前down的一段代码,看看吧


Option Explicit
Public OldWindowProc As Long ' Original window proc


Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
' Function to define the address of the Message-Handling routine
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
' Function to copy an object/variable/structure passed by reference onto a variable of your own
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)
' Function to execute a function residing at a specific memory address
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

' This is the message constant
Public Const WM_GETMINMAXINFO = &H24

' This is a structure referenced by the MINMAXINFO structure
Type POINTAPI
x As Long
y As Long
End Type

' This is the structure that is passed by reference (ie an address) to your message handler
' The key items in this structure are ptMinTrackSize and ptMaxTrackSize
Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End Type
Public Function SubClass1_WndMessage(ByVal hwnd As Long, ByVal Msg As Long, ByVal wp As Long, ByVal lp As Long) As Long

' Watch for the pertinent message to come in
If Msg = WM_GETMINMAXINFO Then

Dim MinMax As MINMAXINFO

' This is necessary because the structure was passed by its address and there
' is currently no intrinsic way to use an address in Visual Basic
CopyMemory MinMax, ByVal lp, Len(MinMax)

' This is where you set the values of the MinX,MinY,MaxX, and MaxY
' The values placed in the structure must be in pixels. The values
' normally used in Visual Basic are in twips. The conversion is as follows:
' pixels = twips\twipsperpixel
MinMax.ptMinTrackSize.x = 3975 \ Screen.TwipsPerPixelX
MinMax.ptMinTrackSize.y = 1740 \ Screen.TwipsPerPixelY
MinMax.ptMaxTrackSize.x = Screen.Width \ Screen.TwipsPerPixelX \ 2
MinMax.ptMaxTrackSize.y = 3480 \ Screen.TwipsPerPixelY

' Here we copy the datastructure back up to the address passed in the parameters
' because Windows will look there for the information.
CopyMemory ByVal lp, MinMax, Len(MinMax)

' This message tells Windows that the message was handled successfully
SubClass1_WndMessage = 1
Exit Function

End If

' Here, we forward all irrelevant messages on to the default message handler.
SubClass1_WndMessage = CallWindowProc(OldWindowProc, hwnd, Msg, wp, lp)

End Function

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧