Click here to Skip to main content
15,899,126 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Method 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);

->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);

-> call by GetDlgItem(wd_Current, IDCBB_DISK1);

I don't know the better way: faster?:confused::confused::confused:
Posted
Updated 3-Apr-10 5:51am
v2

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.
 
Share this answer
 
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);
 
Share this answer
 
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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900