BCB多显示器开发的有关问题
发布时间:2011-06-28 12:22:01 文章来源:www.iduyao.cn 采编人员:星星草
BCB多显示器开发的问题!
1、现在有一个别人的程序,打开时是没有窗口标题栏的。
2、我要写一个程序,把它的程序移动到第二个显示器上显示
这里我遇到两个问题
1、如何获取别人程序的工作窗口
2、如何移动没有标题栏的窗口
------解决方案--------------------
获取一个窗口的方法很多:
有EnumWindows,EnumChildWindows,FindWindow,FindWindowEx,GetWindow等等。
移动没有标题栏的窗口:
获取到该窗口句柄以后,通过MoveWindow或SetWindowPos改变其位置就行了。
------解决方案--------------------
> > > 查询出程序中所有的窗口
用EnumWindows就可以了。
> > > 把窗口定位到我想要的显示器上
GetSystemMetrics(SM_CMONITORS)可以获取当前显示器的总数
EnumDisplayMonitors枚举每个显示器
至于把窗口定位到指定的显示器上,可以参考一下VCL中Forms.pas的源码:
procedure TCustomForm.SetWindowToMonitor;
var
AppMon, WinMon: HMONITOR;
I, J: Integer;
ALeft, ATop: Integer;
begin
if (FDefaultMonitor <> dmDesktop) and (Application.MainForm <> nil) then
begin
AppMon := 0;
if FDefaultMonitor = dmMainForm then
AppMon := Application.MainForm.Monitor.Handle
else if (FDefaultMonitor = dmActiveForm) and (Screen.ActiveCustomForm <> nil) then
AppMon := Screen.ActiveCustomForm.Monitor.Handle
else if FDefaultMonitor = dmPrimary then
AppMon := Screen.Monitors[0].Handle;
WinMon := Monitor.Handle;
for I := 0 to Screen.MonitorCount - 1 do
if (Screen.Monitors[I].Handle = AppMon) then
if (AppMon <> WinMon) then
for J := 0 to Screen.MonitorCount - 1 do
if (Screen.Monitors[J].Handle = WinMon) then
begin
if FPosition = poScreenCenter then
SetBounds(Screen.Monitors[I].Left + ((Screen.Monitors[I].Width - Width) div 2),
Screen.Monitors[I].Top + ((Screen.Monitors[I].Height - Height) div 2),
Width, Height)
else
if FPosition = poMainFormCenter then
begin
SetBounds(Screen.Monitors[I].Left + ((Screen.Monitors[I].Width - Width) div 2),
Screen.Monitors[I].Top + ((Screen.Monitors[I].Height - Height) div 2),
Width, Height)
end
else
begin
ALeft := Screen.Monitors[I].Left + Left - Screen.Monitors[J].Left;
if ALeft + Width > Screen.Monitors[I].Left + Screen.Monitors[I].Width then
ALeft := Screen.Monitors[I].Left + Screen.Monitors[I].Width - Width;
ATop := Screen.Monitors[I].Top + Top - Screen.Monitors[J].Top;
if ATop + Height > Screen.Monitors[I].Top + Screen.Monitors[I].Height then
ATop := Screen.Monitors[I].Top + Screen.Monitors[I].Height - Height;
SetBounds(ALeft, ATop, Width, Height);
end;
end;
end;
end;
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
C#项目中如何更改项目保存的文件夹名?
求解。。
------解决方案--------------------
好像需要重构吧,同样求高人解答。
------...
-
C#中让TextBox只能输入数字的问题
我用的如下的代码:
static private Regex r = new Regex("^[0-9]{1,}$ ");
...
-
带数据库的程序打包注意什么?
打的包出错:Error:System.InvalidOperationException: ExecuteReader 要求已打开且可用的连接。连接的...
-
想学习一下网络程序开发 请给推荐几本书
学习基于http协议的程序开发 比如获取网页 分析网页 模拟网页操作 下载上传文档等知识 ...
-
qq的安装包是用什么工具?
想用.net制作一个想qq一样比较漂亮的安装包。有例子最好
------解决方案--------------------
新建->安...
-
C# 写的windows服务 调用 C++ dll 的问题
我封装了一个dll
用一个普通的winform程序 调用的时候没 问题。
但是放在C#写的服务程...
-
在VS2005中怎么调出 解决方案 那个图标?(图示)求解释~~~
这是我用的VS
这是我在教学视频上看到的VS
------解决方案------------...
-
寻友
有人在自学c#编程吗,可以互相认识一下,以后共同探讨学习中的问题……
------解决方案--------------------
朋友多了,路好走~
...
-
急!急!急!C#代码
怎样将数据库中的数据动态加载到Treeview控件中
------解决方案--------------------
C# code
void CreateTree(T...
-
救急??????????????????
哪位高手帮我一下,在C#中怎么写关于鼠标和键盘监听事件,我的程序就差监听鼠标和键盘是否动,然后定时关机这个功能了,请高手指点,...