VB6中怎么将一个已经用load函数创建好的控件移动至另一个控件内?

Xfan0202 2019-03-03 08:06:08
一个已经用load函数创建好的控件移动至另一个控件内? 大神求教
...全文
253 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
vansoft 2019-06-12
  • 打赏
  • 举报
回复
Set .Container = Picture2 设置控件的所属对象。
milaoshu1020 2019-03-05
  • 打赏
  • 举报
回复
引用 5 楼 qq_43023041 的回复:
[quote=引用 1 楼 caozhy的回复:]setparent api函数

请问这个api怎么用呀?[/quote]

SetParent Function

--------------------------------------------------------------------------------

The SetParent function changes the parent window of the specified child window.

Syntax

HWND SetParent(
HWND hWndChild,
HWND hWndNewParent
);
Parameters

hWndChild
[in] Handle to the child window.
hWndNewParent
[in] Handle to the new parent window. If this parameter is NULL, the desktop window becomes the new parent window. Windows 2000/XP: If this parameter is HWND_MESSAGE, the child window becomes a message-only window.
Return Value

If the function succeeds, the return value is a handle to the previous parent window.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.




Remarks

An application can use the SetParent function to set the parent window of a pop-up, overlapped, or child window. The new parent window and the child window must belong to the same application.

If the window identified by the hWndChild parameter is visible, the system performs the appropriate redrawing and repainting.

For compatibility reasons, SetParent does not modify the WS_CHILD or WS_POPUP window styles of the window whose parent is being changed. Therefore, if hWndNewParent is NULL, you should also clear the WS_CHILD bit and set the WS_POPUP style after calling SetParent. Conversely, if hWndNewParent is not NULL and the window was previously a child of the desktop, you should clear the WS_POPUP style and set the WS_CHILD style before calling SetParent.

Windows 2000/XP: When you change the parent of a window, you should synchronize the UISTATE of both windows. For more information, see WM_CHANGEUISTATE and WM_UPDATEUISTATE.

Function Information

Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode version.

See Also

Windows Overview, GetParent

--------------------------------------------------------------------------------

脆皮大雪糕 2019-03-05
  • 打赏
  • 举报
回复
引用 5 楼 qq_43023041 的回复:
[quote=引用 1 楼 caozhy的回复:]setparent api函数
请问这个api怎么用呀?[/quote] 4楼已经给出那么简单的办法了,还折腾API干啥
threenewbee 2019-03-04
  • 打赏
  • 举报
回复
setparent api函数
Xfan0202 2019-03-04
  • 打赏
  • 举报
回复
引用 1 楼 caozhy的回复:
setparent api函数
请问这个api怎么用呀?
milaoshu1020 2019-03-04
  • 打赏
  • 举报
回复
移动到另一控件内的代码如下,主要内容是container那一行:
Private Sub Form_Load()
Load cmdTest(1)
With cmdTest(1)
.Caption = "Command2"
.Visible = True
Set .Container = Picture2
'.ZOrder
End With
End Sub

效果如图:

代码下载:
链接:https://pan.baidu.com/s/1hVmhjMtkPCeXBgWHonqW3w
提取码:4kcs
ZHRXJR 2019-03-04
  • 打赏
  • 举报
回复
除非对于数组动态控件,提前就下标为0的控件放置在VB的容器控件中,这样通过Load 语句可以将下标为1、2、3...的数组控件放置在这个容器控件中。
ZHRXJR 2019-03-04
  • 打赏
  • 举报
回复
Load 语句好像是动态放置控件对象的语句,根据自己的使用情况来看,Load 语句应该是放置在Form窗体最底层的,好像不能放置在其他控件的上方,即就是在设计时将“另一个控件”设置为最底层,Load 语句放置的控件也是在其他控件的最底层,因此好像不能实现你说的效果。因为Load 语句放置的控件永远在其他控件的底层,这样其他控件就可能覆盖了Load 语句放置的控件。

1,451

社区成员

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

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