如何更好地通过"window.h"创建窗口? [英] How better to create a window by "window.h" ?

查看:101
本文介绍了如何更好地通过"window.h"创建窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法1:

HWND cbb_Disk1;
cbb_Disk1 = CreateWindow(_T("COMBOBOX"),_T(""),WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|CBS_AUTOHSCROLL|CBS_UPPERCASE|CBS_SORT,T_ToaDo.m_iX,T_ToaDo.m_iY,T_ToaDo.m_iW,T_ToaDo.m_iH,wd_Current,(HMENU)IDCBB_DISK1,ist_Current,NULL);


->通过cbb_Disk1调用

方法2:


->call by cbb_Disk1

Method 2:

CreateWindow(_T("COMBOBOX"),_T(""),WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|CBS_AUTOHSCROLL|CBS_UPPERCASE|CBS_SORT,T_ToaDo.m_iX,T_ToaDo.m_iY,T_ToaDo.m_iW,T_ToaDo.m_iH,wd_Current,(HMENU)IDCBB_DISK1,ist_Current,NULL);


->通过GetDlgItem(wd_Current,IDCBB_DISK1)进行调用;

我不知道更好的方法:更快?:confused :: confused :: confused:


-> call by GetDlgItem(wd_Current, IDCBB_DISK1);

I don''t know the better way: faster?:confused::confused::confused:

推荐答案


您是在问是否最好存储窗口句柄或通过GetDlgItem检索它?如果您考虑一下,与您可能会使用该手柄执行的任何操作相比,获取窗口手柄总是非常快的.任何涉及重绘的内容.

在此基础上,使用保存的hWnd或GetDlgItem不会对应用程序的速度产生任何实际的影响,因此您应该使用提供更清晰代码的方法.就个人而言,仅当通过资源文件中的对话框定义了窗口时,才使用GetDlgItem.

艾伦.
Hi,
Are you are asking if is better to store a window handle or retrieve it via GetDlgItem? If you think about it, getting the window handle will always be fast compared to any operation you may perform using the handle, e.g. anything that involves redrawing.

On that basis the use of the saved hWnd or GetDlgItem won''t make any real difference to the speed of your application and you should use whichever gives clearer code. Personally I only use GetDlgItem when the window has been defined via a dialog in a resource file.

Alan.


如果您使用的是MFC,则可以执行此操作-
If you''re using MFC, you can do this -
CComboBox cmb;
cmb.Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|CBS_AUTOHSCROLL|CBS_UPPERCASE|CBS_SORT, CRect(T_ToaDo.m_iX,T_ToaDo.m_iY,T_ToaDo.m_iW,T_ToaDo.m_iH), this, IDCBB_DISK1);


您的问题不是很清楚;您是否要将组合框添加到主窗口或对话框窗口?您可以尝试解释您要实现的目标吗?
Your question is not very clear; are you trying to add the combobox to a main window or to a dialog window? Can you try to explain what you are trying to achieve?


这篇关于如何更好地通过"window.h"创建窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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