请教,如何将一个窗体放在桌面之上,但又不会 遮住其它窗口

weiyulin 2008-05-17 12:08:43
如体
...全文
1084 51 打赏 收藏 转发到动态 举报
写回复
用AI写文章
51 条回复
切换为时间正序
请发表友善的回复…
发表回复
suimengdao2005 2012-01-18
  • 打赏
  • 举报
回复
经过调试,2000,xp都可以执行!

[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", EntryPoint = "SetParent")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
public Form1()
{
InitializeComponent();


IntPtr p = FindWindow("Progman", "Program Manager");//FindWindow("progman",null);
SetParent(this.Handle.ToInt32(), p.ToInt32());

}
suimengdao2005 2012-01-18
  • 打赏
  • 举报
回复
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", EntryPoint = "SetParent")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
public Form1()
{
InitializeComponent();


IntPtr p = FindWindow("Progman", "Program Manager");//FindWindow("progman",null);
SetParent(this.Handle.ToInt32(), p.ToInt32());

}
yinweihong 2008-05-27
  • 打赏
  • 举报
回复
楼主还不揭贴?~~~
ewang11 2008-05-22
  • 打赏
  • 举报
回复
使用键盘捕捉来屏蔽 Win + D 组合键吧
波导终结者 2008-05-22
  • 打赏
  • 举报
回复
mark
weiyulin 2008-05-22
  • 打赏
  • 举报
回复

我刚刚看完了 所有朋友的回复

但我不可能 每个人都.....


呵呵

我现在在网吧 没有运行环境 所以,, 我将在回公司 试了之后 决定 哪位朋友的效果 最好... 然后





谢谢大家
weiyulin 2008-05-22
  • 打赏
  • 举报
回复
不是,不是 我说的话 算术

只是这几天 我没有上网 出差了

sorry
yinweihong 2008-05-21
  • 打赏
  • 举报
回复
看来楼主的QB是等不到了,呵呵,算了,代码贴出来

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Public Sub PinToDesktop(FormToPin As Form)

Dim progman As Long
progman = FindWindow("progman", vbNullString)
SetParent FormToPin.hWnd, progman

End Sub

Public Sub UnPinFromDesktop(FormToUnPin As Form)

Dim lngExplorer As Long

lngExplorer = FindWindow("ExploreWClass", vbNullString)
SetParent FormToUnPin.hWnd, lngExplorer

End Sub
cbm6666 2008-05-21
  • 打赏
  • 举报
回复
呵呵....我晕啊.... 抱歉, 我就直接贴入你40F的代码测试的,没细看. 非常完美...

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Public Sub PinToDesktop(FormToPin As Form)
Dim progman As Long
progman = FindWindow("progman", vbNullString)
SetParent FormToPin.hWnd, progman
End Sub

Private Sub Command1_Click()
Call PinToDesktop(Form1)
End Sub
yinweihong 2008-05-21
  • 打赏
  • 举报
回复
我在xpsp2下面的,完全没问题啊,是调用了PinToDesktop这个方法么,传入form1.hwnd?
cbm6666 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 40 楼 yinweihong 的回复:]
看来楼主的QB是等不到了,呵呵,算了,代码贴出来
[/Quote]

哈哈哈....慢慢等吧,

是否我测试的方法不对 ? 40F 代码

1.窗口不盖住其它窗体 (置底)......没见效果,还是在上面

2.Win + D 并没保住窗体在桌面上, 而是消失了.

我用的是 2000 的系统.
nmd002 2008-05-21
  • 打赏
  • 举报
回复
标记一下
cbm6666 2008-05-18
  • 打赏
  • 举报
回复
回 23F win + D 是会将桌面上所有的运行中物件最小化的.

上面的方法是一种,直接补救结果的发生, 另种,使用键盘捕捉来屏蔽, 既然已解决也没啥必要来弄了.

24F 的 新建另外一个VB6 EXE 只有一张 "组合图" 来形容..

+
yinweihong 2008-05-18
  • 打赏
  • 举报
回复
怎么老是报错,说什么服务器积极拒绝....


再来一遍

老刘的代码不行,随便用VB6新建一窗体,Text就叫"Program Manager",再试试代码就知道了

再说,即使没有同名的应用程序,贴到底了,怎么回复原来状态?


我下午已经给加QQ解决了,嘿嘿,大家就别和我抢拉...

楼主说明天才给我冲QB,呵呵,我也不要这么多,有一半就不错了,过了后我会把代码贴上来的
cbm6666 2008-05-18
  • 打赏
  • 举报
回复
Win + D 时 也不会最小化 , 哎....懒得写了, 难道你自己不会试一下去屏蔽 win + D ? 非要我来帮你写 ?

别那么懒啦.......
舉杯邀明月 2008-05-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 haimin350 的回复:]
WIN+D也不会最小化也解决了吗?
[/Quote]

不会被 Win+D 最小化的。
舉杯邀明月 2008-05-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 haimin350 的回复:]
WIN+D也不会最小化也解决了吗?
[/Quote]

不会被 Win+D 最小化的。
舉杯邀明月 2008-05-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 haimin350 的回复:]
WIN+D也不会最小化也解决了吗?
[/Quote]

不会被 Win+D 最小化的。
yinweihong 2008-05-18
  • 打赏
  • 举报
回复
问题我已经加QQ给他解决了,呵呵,各位就不要和我抢拉,等他QB冲上来后,我再把代码发出来,呵呵
yinweihong 2008-05-18
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 Chen8013 的回复:]
我倒没注意到这样可以把窗口“置底”。

楼主在 3楼 说的问题也搞定了。
你的 50Q币 可以给 CMB666 了吧!
[/Quote]

老刘上面那个代码显然不行的,我随便做个什么程序 标题就叫Program Manager 运行起来,你试试
加载更多回复(31)

1,486

社区成员

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

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