ComboBox의 GetCurSel의 ItemDate를 가져와서 SQL Querey 하기

2010.05.13 20:06 개발언어/C++

ComboBox의 GetCurSel의 ItemDate를 가져와서 SQL Querey 하기

연관된 글보기

2010/05/14 - [개발언어/C++] - ComboBox 의 Item과 List 구성하기


1 // ComboBox의 GetCurSel의 ItemDate를 가져와서 SQL Querey 하기
2 CString CSearchModule::GetJoinCode()
3 {
4     int nItem = m_comboPatientDiv2.GetCurSel();
5     long lValue;
6     if(nItem > 0)
7     {
8         lValue = *(reinterpret_cast<long*>(m_comboPatientDiv2.GetItemDataPtr(nItem)));
9         CString strT = _T("");
10         strT.Format(" A.PNT_ID = X.PNT_ID AND X.CODE = %d AND ", lValue);
12         return strT;
13     }
14     return _T("");
15 }

Combo의 변환 참고하기
// 선택한 콤보의 커서값으로 ItemData값을 얻는다. 얻은 ItemData값을 long형으로 변환하여 비교한다.
if( (long) m_wndDoctorCombo.GetItemDataPtr( m_wndDoctorCombo.GetCurSel() ) == 1)
    //  처리..     

reinterpret_cast 이란?

reinterpret_cast Operator

The reinterpret_cast operator allows any pointer to be converted into any other pointer type. It also allows any integral type to be converted into any pointer type and vice versa. Misuse of the reinterpret_cast operator can easily be unsafe. Unless the desired conversion is inherently low-level, you should use one of the other cast operators.


reinterpret_cast < type-id > ( expression )

The reinterpret_cast operator can be used for conversions such as char* to int*, or One_class* to Unrelated_class*, which are inherently unsafe.

The result of a reinterpret_cast cannot safely be used for anything other than being cast back to its original type. Other uses are, at best, nonportable.

The reinterpret_cast operator cannot cast away the const, volatile, or __unaligned attributes. See const_cast Operator for information on removing these attributes.

The reinterpret_cast operator converts a null pointer value to the null pointer value of the destination type.

Send feedback to MSDN. Look here for MSDN Online resources.

  1. Favicon of BlogIcon 사기토비밀방문자
    2010.05.16 00:14 신고 edit/del reply

    오호 이런거 하시는분들 보면 신기합니다