将控件放置在对话框上 [英] Positioning the controls onto dialog box

查看:65
本文介绍了将控件放置在对话框上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CButton* btnApply = new CButton;
CRect recto;
GetClientRect(&recto);
ScreenToClient(&recto);
btnApply->Create((LPCTSTR)"Apply", WS_CHILD | WS_VISIBLE, recto,this, 1234);
btnApply->ShowWindow(SW_SHOW);



不显示按钮控件.上面的代码是什么问题?



The button control is not displayed. What is the problem in the above code?

推荐答案

您不应在此呼叫ScreenToClient .您传递的矩形位于与父窗口相关的坐标中.并且您已经在父窗口上调用了GetClientRect .当然,这基本上会创建一个填充整个父窗口的按钮(但是也许这就是您想要的?)
You should not call ScreenToClient there. The rect you pass is in the coordinates relating to the parent window. And you''ve already called GetClientRect on the parent window. Of course this will basically create a button that fills your entire parent window (but perhaps that is what you want?)


这篇关于将控件放置在对话框上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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