To Christian Graus & Nish
-
Hello, it's me again. I did all your advises but still have nothing changes ... If it's possible, can you, please look my code, where is mistake? all best .. ----------------------------- void CRegListDlg::QueryKey(HWND hDlg, HKEY hKey) { CHAR achKey[MAX_PATH]; CHAR achClass[MAX_PATH] = ""; // buffer for class name DWORD cchClassName = MAX_PATH; // length of class string DWORD cSubKeys; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, j; DWORD retCode, retValue; CHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; CHAR achBuff[80]; // Get the class name and the value count. RegQueryInfoKey(hKey, // key handle achClass, // buffer for class name &cchClassName, // length of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // SetDlgItemText(hDlg, IDE_CLASS, achClass); // SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE); ::SendMessage(GetDlgItem(hDlg, m_list), LB_ADDSTRING, 0, (LONG) ".."); DWORD dwLength = MAX_PATH; // Enumerate the child keys, until RegEnumKeyEx fails. Then // get the name of each child key and copy it into the list box. SetCursor(LoadCursor(NULL, IDC_WAIT)); for (i = 0, retCode = ERROR_SUCCESS; retCode != ERROR_NO_MORE_ITEMS; i++) { retCode = RegEnumKeyEx(hKey, i, achKey, &dwLength, NULL, NULL, NULL,
-
Hello, it's me again. I did all your advises but still have nothing changes ... If it's possible, can you, please look my code, where is mistake? all best .. ----------------------------- void CRegListDlg::QueryKey(HWND hDlg, HKEY hKey) { CHAR achKey[MAX_PATH]; CHAR achClass[MAX_PATH] = ""; // buffer for class name DWORD cchClassName = MAX_PATH; // length of class string DWORD cSubKeys; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, j; DWORD retCode, retValue; CHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; CHAR achBuff[80]; // Get the class name and the value count. RegQueryInfoKey(hKey, // key handle achClass, // buffer for class name &cchClassName, // length of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // SetDlgItemText(hDlg, IDE_CLASS, achClass); // SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE); ::SendMessage(GetDlgItem(hDlg, m_list), LB_ADDSTRING, 0, (LONG) ".."); DWORD dwLength = MAX_PATH; // Enumerate the child keys, until RegEnumKeyEx fails. Then // get the name of each child key and copy it into the list box. SetCursor(LoadCursor(NULL, IDC_WAIT)); for (i = 0, retCode = ERROR_SUCCESS; retCode != ERROR_NO_MORE_ITEMS; i++) { retCode = RegEnumKeyEx(hKey, i, achKey, &dwLength, NULL, NULL, NULL,
GetDlgItem doesn't take a handle to a window as its first parameter, it takes a control ID (ID_MY_BUTTON or something). -c
-
GetDlgItem doesn't take a handle to a window as its first parameter, it takes a control ID (ID_MY_BUTTON or something). -c
Hello, the codegurus around the world;) The poster simply misunderstands between CWnd function and Windows API function. Windows API
HWND GetDlgItem(
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);And, MFC
CWnd* GetDlgItem( int nID ) const;
void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;Also, if the poster wants to use WinAPI function in MFC, we need the global resultion ::GetDlgItem(...);:rolleyes: Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
-
Hello, the codegurus around the world;) The poster simply misunderstands between CWnd function and Windows API function. Windows API
HWND GetDlgItem(
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);And, MFC
CWnd* GetDlgItem( int nID ) const;
void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;Also, if the poster wants to use WinAPI function in MFC, we need the global resultion ::GetDlgItem(...);:rolleyes: Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
Yah! And as you can see exactly like this I called this function: ::GetDlgItem Or I did smf wrong? ============== www.design.kg
-
GetDlgItem doesn't take a handle to a window as its first parameter, it takes a control ID (ID_MY_BUTTON or something). -c
I found it here: http://msdn.microsoft.com/library/en-us/sysinfo/regapi\_0tq1.asp?frame=true is it MSDN mistake, that GetDlgItem take a handle to a window as its first parameter? ============== www.design.kg
-
I found it here: http://msdn.microsoft.com/library/en-us/sysinfo/regapi\_0tq1.asp?frame=true is it MSDN mistake, that GetDlgItem take a handle to a window as its first parameter? ============== www.design.kg
Hello, the codegurus around the world.;) First of all, you must understand the dif between C and C++ code. In msdn example, this is written by C code. In this case, we don't need the global resolution "::".
VOID QueryKey(HWND hDlg, HANDLE hKey)
{
.....
//GetDlgItem means the Windows API function.
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
}However, if you use this one in MFC,
void CMyDialog::QueryKey(...)
{
.....
//In this case, this->GetDlgItem(...) is called.
// this means CMyDialog's pointer.
// So, you got the compiler error!
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
//As a result, this is right.
//
.....
SendMessage(::GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
or GetDlgItem(IDL_LISTBOX);}
Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
-
Hello, the codegurus around the world.;) First of all, you must understand the dif between C and C++ code. In msdn example, this is written by C code. In this case, we don't need the global resolution "::".
VOID QueryKey(HWND hDlg, HANDLE hKey)
{
.....
//GetDlgItem means the Windows API function.
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
}However, if you use this one in MFC,
void CMyDialog::QueryKey(...)
{
.....
//In this case, this->GetDlgItem(...) is called.
// this means CMyDialog's pointer.
// So, you got the compiler error!
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
//As a result, this is right.
//
.....
SendMessage(::GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
or GetDlgItem(IDL_LISTBOX);}
Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
Like this: ::SendMessage(::GetDlgItem(m_hWnd, m_list), LB_ADDSTRING, 0, (LONG) ".."); The result is: : error C2664: 'GetDlgItem' : cannot convert parameter 2 from 'class CString' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called ============== www.design.kg
-
Like this: ::SendMessage(::GetDlgItem(m_hWnd, m_list), LB_ADDSTRING, 0, (LONG) ".."); The result is: : error C2664: 'GetDlgItem' : cannot convert parameter 2 from 'class CString' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called ============== www.design.kg
Hello, the codegurus around the world.;)
::SendMessage(::GetDlgItem(m_hWnd, m_list),
LB_ADDSTRING, 0, (LONG) "..");How did you declare m_list? CString m_list? GetDlgItem has the second parameter as ID of the control. So, this should take something like IDC_LIST1. But, are you sure that you add ListBox (ID: IDC_LIST1) on your dialog box? Simply copying the code never works unless you have enough knowledge of both MFC and Win32 program in this case. :cool: Or, to be sure, you add ListBox on your dialog box. This works. If you declare CListBox m_list;
::SendMessage(m_list.m_hWnd, LB_ADDSTRING, 0, (LONG) "..");
or
m_list.AddString ("..");
or
m_list.SendMessage(LB_ADDSTRING, 0, (LONG)"..");Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
-
Like this: ::SendMessage(::GetDlgItem(m_hWnd, m_list), LB_ADDSTRING, 0, (LONG) ".."); The result is: : error C2664: 'GetDlgItem' : cannot convert parameter 2 from 'class CString' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called ============== www.design.kg
"::GetDlgItem(m_hWnd, m_list)" <--- error line The second parameter should be the control id. replace m_list with the control id,something like IDLIST01 Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut
-
Hello, the codegurus around the world.;)
::SendMessage(::GetDlgItem(m_hWnd, m_list),
LB_ADDSTRING, 0, (LONG) "..");How did you declare m_list? CString m_list? GetDlgItem has the second parameter as ID of the control. So, this should take something like IDC_LIST1. But, are you sure that you add ListBox (ID: IDC_LIST1) on your dialog box? Simply copying the code never works unless you have enough knowledge of both MFC and Win32 program in this case. :cool: Or, to be sure, you add ListBox on your dialog box. This works. If you declare CListBox m_list;
::SendMessage(m_list.m_hWnd, LB_ADDSTRING, 0, (LONG) "..");
or
m_list.AddString ("..");
or
m_list.SendMessage(LB_ADDSTRING, 0, (LONG)"..");Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-
Oh, ÎÃÐÎÌÍÎÅ ÑÏÀÑÈÁÎ! thats in my language mean THANK YOU VERY MUCH! Masaaki :) ============== www.design.kg
-
"::GetDlgItem(m_hWnd, m_list)" <--- error line The second parameter should be the control id. replace m_list with the control id,something like IDLIST01 Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut
Hello, the codegurus around the world.;) Yesterday, I forgot to say that if we use the class wziard... X| Simply if we declare CListBox listbox, listbox will never get the right stuff. If we declare CListBox listbox by the class wizard, DoDataExchange(...) assign the right stuff to listbox. Or, we can use Create or CreateEx function like listbox.Create(...) X| Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)
-Masaaki Onishi-