无法使用API​​重新定位/调整对话框应用的大小 [英] Can't reposition/resize dialog app using APIs

查看:88
本文介绍了无法使用API​​重新定位/调整对话框应用的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我正在尝试向基于对话框的应用程序添加功能,以记住其位置以及两次启动之间的尺寸.这样一来,我每次启动时都无需移动和调整大小.

我成功保存了窗口的桌面坐标以及宽度和高度,但发现在启动时将其应用于窗口是有问题的.我的意思是:无论我做什么,应用程序的对话框窗口都不会移动或调整大小:
-我尝试使用CWnd::SetWindowPos,但没有成功,对话框没有移动或调整大小;
-我尝试CWnd::MoveWindow-再次失败,同一个故事;
-我试图连续发送WM_MOVEWM_SIZE消息,并带有正确的位置和尺寸-同一故事.

似乎有点逻辑,到目前为止,我仅使用所有这些功能在其父窗口中移动/调整子窗口的大小.我从未使用过它们在其自身的函数/消息处理程序中移动/调整窗口窗体的大小.

如果您知道如何完成任务,请告诉我:)
任何帮助将不胜感激:)

Hi All :)

I''m trying to add to my dialog based app the functionality to remember its position and demensions between launches. So I won''t need to move and resize every time I start it.

I successfully saved window''s desktop co-ordinates and the width and height but I found it problematic to apply them to the very window at startup. What do I mean by that: The dialog window of my app won''t move nor resize no matter what I try:
- I tried to use CWnd::SetWindowPos but no success, the dialog doesn''t move nor resize;
- I tried CWnd::MoveWindow - no success again, the same story;
- I tried to send consecutively messages WM_MOVE and WM_SIZE with the correct position and dimensions - the same story.

It seems kind of logial, so far I only used all those functions to move/resize a child window within its parent. I''ve never used them to move/resize a window form within its own functions/message handlers.

If you know how to accomplish my task please tell me :)
any help will be appreciated :)

推荐答案

何时调用MoveWindow,我将在OnInitDialog的结尾处执行.问题最有可能是您的邮件之后正在调整其他消息的大小.
When do you call MoveWindow I would do at the end of OnInitDialog. Most likely the problem is some other message is resizeing after yours.


您的客户端坐标和屏幕坐标之间混淆了,或者您需要考虑Boader宽度.

ClientToScreenRect(认为是这样)会转换为屏幕坐标.

GetSystemMetrics允许您获取任何边界宽度,例如3D_DLGBORDER.

可能是字幕的高度或边框的宽度所致,最好的方法是保存主窗口的 screen 坐标-您可能需要对其进行转换.
Either your have a mix up between client and screen coordinates or you need to account for a boader width.

ClientToScreenRect (think it is called that) converts to screen coordinates.

GetSystemMetrics allow you to get any boarder widths such as 3D_DLGBORDER.

it is probably out by the height of the caption or width of the border, the best way is to save the screen co-ordinates of the main window - you may have to convert them.


这篇关于无法使用API​​重新定位/调整对话框应用的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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