Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralModeless Dialog without leakages Pin
Braulio Dez27-Nov-01 21:15
Braulio Dez27-Nov-01 21:15 
GeneralRe: Modeless Dialog without leakages Pin
Michael Dunn27-Nov-01 21:31
sitebuilderMichael Dunn27-Nov-01 21:31 
GeneralA simple problem for help Pin
27-Nov-01 21:11
suss27-Nov-01 21:11 
GeneralRe: A simple problem for help Pin
Eugene Pustovoyt27-Nov-01 21:18
Eugene Pustovoyt27-Nov-01 21:18 
GeneralRe: A simple problem for help Pin
27-Nov-01 21:46
suss27-Nov-01 21:46 
GeneralRe: A simple problem for help Pin
Eugene Pustovoyt27-Nov-01 22:41
Eugene Pustovoyt27-Nov-01 22:41 
GeneralGetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 20:56
suss27-Nov-01 20:56 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Nish Nishant27-Nov-01 23:03
sitebuilderNish Nishant27-Nov-01 23:03 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 23:21
suss27-Nov-01 23:21 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Jon Hulatt27-Nov-01 23:25
Jon Hulatt27-Nov-01 23:25 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Nish Nishant27-Nov-01 23:33
sitebuilderNish Nishant27-Nov-01 23:33 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 23:53
suss27-Nov-01 23:53 
GeneralToolBar Alignment Pin
27-Nov-01 20:54
suss27-Nov-01 20:54 
GeneralRe: ToolBar Alignment Pin
Nish Nishant27-Nov-01 23:00
sitebuilderNish Nishant27-Nov-01 23:00 
GeneralRe: ToolBar Alignment Pin
Christian Graus27-Nov-01 23:35
protectorChristian Graus27-Nov-01 23:35 
GeneralFile Dialog Problem Pin
San27-Nov-01 20:11
San27-Nov-01 20:11 
GeneralRe: File Dialog Problem Pin
Eugene Pustovoyt27-Nov-01 21:13
Eugene Pustovoyt27-Nov-01 21:13 
QuestionCan somebody help me? Pin
Karavaev Denis27-Nov-01 19:51
Karavaev Denis27-Nov-01 19:51 
AnswerRe: Can somebody help me? Pin
Christian Graus27-Nov-01 23:40
protectorChristian Graus27-Nov-01 23:40 
GeneralRe: Can somebody help me? Pin
Karavaev Denis28-Nov-01 0:03
Karavaev Denis28-Nov-01 0:03 
GeneralRe: Can somebody help me? Pin
Nish Nishant28-Nov-01 0:25
sitebuilderNish Nishant28-Nov-01 0:25 
GeneralRe: Can somebody help me? Pin
Christian Graus28-Nov-01 1:47
protectorChristian Graus28-Nov-01 1:47 
GeneralRe: Can somebody help me? Pin
Christian Graus28-Nov-01 0:31
protectorChristian Graus28-Nov-01 0:31 
Karavaev Denis wrote:
how do you think, if I'll be on this forum if I can't create a dialog box?

Well, you *did* say Unfortunly, I know C++ to bad to compile it myself.. You'd be amazed at some of the questions we get around here. Most are intelligent but some are just out of control.

C1004 means you either didn't put a final bracket, or you didn't include stdafx.h. The missing bracket is at the end. The HANDLE parameter should be a HKEY. Where the code checks if retValue == ERROR_SUCCESS, it should check for != ERROR_NO_MORE_ITEMS. Where it passes in MAX_PATH to RegEnumValues, it should set a DWORD to = MAX_PATH, pass in a pointer to that variable, and reset the variable to MAX_PATH. I think that was all, but my code follows to make sure. This smaple is SCREWED.

#define MAX_VALUE_NAME 255

// QueryKey - enumerates the subkeys of a given key and the associated 
//    values and then copies the information about the keys and values 
//    into a pair of edit controls and list boxes. 
// hDlg - dialog box that contains the edit controls and list boxes 
// hKey - key whose subkeys and values are to be enumerated 
 
VOID 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, IDL_LISTBOX), 
        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, 
                     &ftLastWriteTime); 
        if (retCode != (DWORD)ERROR_NO_MORE_ITEMS) 
        {
            SendMessage(GetDlgItem(hDlg, IDL_LISTBOX), 
                LB_ADDSTRING, 0, (LONG) achKey); 
        }

		dwLength = MAX_PATH;
    } 
    SetCursor(LoadCursor (NULL, IDC_ARROW)); 
 
    // Enumerate the key values. 
    SetCursor(LoadCursor(NULL, IDC_WAIT)); 
 
    if (cValues) 
    {
        for (j = 0, retValue = ERROR_SUCCESS; 
                j < cValues; j++) 
        { 
            cchValue = MAX_VALUE_NAME; 
            achValue[0] = '\0'; 
            retValue = RegEnumValue(hKey, j, achValue, 
                &cchValue, 
                NULL, 
                NULL,    // &dwType, 
                NULL,    // &bData, 
                NULL);   // &bcData 
 
            if (retValue != (DWORD) ERROR_SUCCESS && 
                    retValue != ERROR_INSUFFICIENT_BUFFER) 
            { 
                wsprintf (achBuff, 
                    "Line:%d 0 based index = %d, retValue = %d, " 
                     "ValueLen = %d", 
                     __LINE__, j, retValue, cchValue); 
                MessageBox (hDlg, achBuff, "Debug", MB_OK); 
            } 
 
            achBuff[0] = '\0'; 
 
            // Add each value to a list box. 
            if (!lstrlen(achValue)) 
                lstrcpy(achValue, "<NO NAME>"); 
            wsprintf(achBuff, "%d) %s ", j, achValue); 
            SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2), 
                LB_ADDSTRING, 0, (LONG) achBuff); 
        } 
	}
	SetCursor(LoadCursor(NULL, IDC_ARROW)); 
} 


and in OnPaint:

CDialog::OnPaint();
HKEY key;
DWORD result;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software"), NULL,
	NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &result);

ASSERT(REG_OPENED_EXISTING_KEY == result);

QueryKey(m_hWnd, key);
RegCloseKey(key);








Christian

After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

Sonork ID 100.10002:MeanManOz
I live in Bob's HungOut now

GeneralRe: Can somebody help me? Pin
Karavaev Denis28-Nov-01 1:04
Karavaev Denis28-Nov-01 1:04 
GeneralRe: Can somebody help me? Pin
Christian Graus28-Nov-01 1:48
protectorChristian Graus28-Nov-01 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.