使用Z顺序和位置来组织MS Access中的打开窗体 [英] Use Z-order and position to organize open forms in MS Access

查看:178
本文介绍了使用Z顺序和位置来组织MS Access中的打开窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于MS Access 2010,我需要一种方法来灵活地维护十几个表单打开时的位置和Z顺序。父表单可以有多个实例,并且每个实例都可以导致Child表单的多个实例(这里有一些背景 )。

我希望用户能够选择哪种表单是最顶层的 - 这意味着我不希望将任何表单设置为弹出。另外,我希望在新的Child打开时,Z-Order基本保留。当孩子打开时,家长失去了焦点;此时我希望父母以Z顺序回到原来的位置。我可以根据这条线添加需求,但是你明白了......我想像一个默认行为可能会做我想做的事,但是如果我必须从一个数组或者类似的东西中分配Z-order的位置,我可以接受它。

我也想要控制子窗体的屏幕位置(我的意思是只有当他们第一次打开时,他们可以重新定位)。如果它们使用相同的 X,Y 坐标打开,它们将显示为堆叠在一起,用户必须重新定位顶部实例以查看其他实例。这是不方便的,更重要的是我认为,迷失方向。



到目前为止,我无法拥有这一切。通过指定 X,Y 位置,我可以得到一个很好的级联结果,但是当我使用标志戳到Z顺序时它会停止工作。



我一直在使用API​​ ...

  Declare Sub SetWindowPos Libuser32 (_ 
ByVal Hwnd& ;,; _
ByVal hWndInsertAfter&,_
ByVal X& ByVal Y& ByVal cX&,_
ByVal cY& ByVal wFlags& b
$ b全局常量HWND_TOP = 0
全局常量HWND_TOPMOST = -1

SetWindowPos Hwnd,HWND_TOP,lngPosX,lngPosX,0,0,SWP_NOSIZE

当我尝试 hWndInsertAfter& wFlags&安培; 。另外,当我将表单设置为 Popup 时(结果会更好,但如前所述,我希望用户将任何表单带到顶部;因此不会出现 Popup )。



<>(I ...我敢打赌 Popup (和'Modal` )正是将API引入最佳用法的原因,因为在显示必须回答对话框时,控制基本上会恢复到Windows。确认?)

我最大的挫折感API的文档看起来是片断和不连贯的。我想知道,我是否坚持使用该API?还有什么我可以使用?我喜欢除了API之外的VBA解决方案,但我想这是API的用途。还有,我是否缺少一种方法?



我可以更详细地发布我的变体尝试,但我觉得我一直在黑暗中拍摄,所以我将等待您的反馈。



更新



我试过读手册。我尝试过使用表单所有权和 NO / TOPMOST 。对于Child表单,我仍然必须做出以下选择:


  1. 能够在打开

  2. 能够将父窗体带回到子窗口的顶部


解决方案

我相信这个解决方案不存在,或者不值得追求,因为它会依赖几年内可能无法提供的Windows API库。 (这种悲观主义并不是基于具体的见解;但总的来说,我认为Windows用户界面上的压力很大,所以很容易想象事情会发生变化。)



我看到一些其他危害。用户将打开大量的窗口;资源在某个时候会失败,在此之前他们可能会从人类分析的角度失去任何优势。尽管如此,他们仍将继续超越收益递减点。另外,我预计会发现一些陷入困境的陷阱,无论我花了多少时间来缓解它们,它们都会抱怨开发时间并最终导致抱怨。想想多用户,你就会明白我的意思。



相反,我需要重新思考这种方法。该应用程序提供复杂的,有时体积庞大的信息。有办法做到这一点。不是这样。

我可能会删除这个OP,但它会得到三张最高票数,所以我会拭目以待。我总是可以踢到社区维基。


For MS Access 2010, I need a way to flexibly maintain the position and Z-order when a dozen forms are open. There can be multiple instances of the Parent form, and each one can lead to multiple instances of the Child form (some background here).

I want the user to be able to choose which form is top-most -- which means I don't want any forms set as Popup. Also, I want the Z-Order essentially preserved when a new Child opens. As the Child opens, the Parent loses the focus; at that point I'd like the Parent to drop back to its former position in the Z-order. I could add requirements along this line, but you get the idea ... I imagined a default behavior might do what I want, but if I have to assign Z-order locations from an array or something like that, I could accept that.

I also want to control the on-screen position of the Child forms (I mean only when they are first opened; they can be repositioned). If they open with the same X,Y coordinates, they'll appear stacked on top of each other and the user will have to reposition the top instance in order to see the others. That is inconvenient and, more important I think, disorienting.

So far I'm not able to have it all. I can get a nice cascade result by specifying X,Y positions, but it stops working when I use the flags to poke at the Z-order.

I've been using the API...

Declare Sub SetWindowPos Lib "user32" ( _
                ByVal Hwnd&, _
                ByVal hWndInsertAfter&, _
                ByVal X&, ByVal Y&, ByVal cX&, _
                ByVal cY&, ByVal wFlags&)

Global Const HWND_TOP = 0
Global Const HWND_TOPMOST = -1

SetWindowPos Hwnd, HWND_TOP, lngPosX, lngPosX, 0, 0, SWP_NOSIZE

I have different results when I try options for hWndInsertAfter& and wFlags&. Also when I set forms as Popup (results are better, but as mentioned, I want the user to bring any form to the top; therefore no Popup).

(Hmm... I bet Popup (and 'Modal`) are precisely what bring the API into best usage, because while a "must-answer" dialog is showing, control basically reverts to Windows. Confirm?)

My biggest frustration is that documentation for the API seems fragmentary and incoherent. And I wonder, am I stuck with that API? Is there something else I can use? I'd love a VBA solution apart from the API, but I guess this is what the API is for. Still, is there a method I'm missing?

I can post my variant attempts in more detail, but I feel I've been shooting in the dark, so I will wait on your feedback.

Update

I tried Reading The Manual. I tried twiddling with "form ownership" and NO/TOPMOST. For the Child form, I still have to choose between:

  1. Being able to set the position upon opening
  2. Being able to bring the Parent form back "on top" of the Child

解决方案

I believe the solution doesn't exist, or isn't worth pursuing because it would lean on Windows API libraries that may not be available in a few years. (This pessimism is not based on specific insights; but in general I see big pressures on the Windows user interface, so it's easy to imagine things shifting.)

I see some other hazards. Users will open numerous windows; resources will fail at some point, and probably before then they'll have lost any advantages from a human analytical point of view. Nonetheless they'll continue past the point of diminishing returns. Also I can expect to find a few pitfalls that gobble development time and lead in the end to complaints no matter how much time I spend mitigating them. Think "multi-user" and you'll know what I mean.

Instead, I need to re-think the approach. The application offers complicated and sometimes volumnous information. There's a way to do it. Not this way.

I might delete this OP, but it's gotten three up-votes, so I'll wait and see what you think. I can always punt to community wiki.

这篇关于使用Z顺序和位置来组织MS Access中的打开窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆