Click here to Skip to main content
15,899,825 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: about IActiveDesktop Pin
Anonymous26-Aug-04 21:11
Anonymous26-Aug-04 21:11 
GeneralRe: about IActiveDesktop Pin
Anonymous26-Aug-04 21:30
Anonymous26-Aug-04 21:30 
GeneralRe: about IActiveDesktop Pin
yingkou26-Aug-04 22:22
yingkou26-Aug-04 22:22 
GeneralRe: about IActiveDesktop Pin
David Crow27-Aug-04 9:22
David Crow27-Aug-04 9:22 
GeneralRe: about IActiveDesktop Pin
yingkou27-Aug-04 14:11
yingkou27-Aug-04 14:11 
GeneralRe: about IActiveDesktop Pin
David Crow28-Aug-04 17:27
David Crow28-Aug-04 17:27 
GeneralRe: about IActiveDesktop Pin
yingkou29-Aug-04 3:14
yingkou29-Aug-04 3:14 
GeneralHLOCAL -- Local Memory alloc/dealloc Pin
0v3rloader26-Aug-04 14:45
0v3rloader26-Aug-04 14:45 
Consider this code extract:

.
:
.
m_hLocal = ::LocalAlloc(LHND, sizeof(DLGTEMPLATE) + (sizeof(WORD) * 2) + sizeof(szDlgCaption));
if(!m_hLocal)
    return FALSE;
// now lock it!
pOut = pBuffer = (BYTE *)::LocalLock(m_hLocal);
if(!pBuffer)
{
    ::LocalFree(m_hLocal);  // free it up now!
    return FALSE;
}
// and transfer the contents of the
// dialog template
memcpy((void*)pOut, (void*)&DlgTemplate, sizeof(DlgTemplate));
pOut += sizeof(DlgTemplate);
*(WORD*)pOut = 0;
*(WORD*)(pOut + 1) = 0;
pOut += (sizeof(WORD) << 1);
memcpy((void*)pOut, (void*)szDlgCaption, sizeof(szDlgCaption));
// now initialise the modeless dialog box
// if all went fine,
// continue creating...
if((bRetVal = CreateIndirect((DLGTEMPLATE*)pBuffer)))
{
    // create the remaining objects
    m_pPrompt = new CXDebugPrompt;  // create the debug_command_prompt
    m_pConsole = new CXConsole(0x0000d200, 0x00000000);
    ASSERT(m_pPrompt != NULL);
    ASSERT(m_pConsole != NULL);
    // TOFIX: CXDebugPrompt needs to be initialised
//  pPrompt->Create(....)
    GetClientRect(&rect);
    if(!m_pConsole->Create(IDD_DEBUG_CONSOLE, this, &rect))
        bRetVal = FALSE;

    // attempt to unlock memory
    if(!::LocalUnlock(m_hLocal))
        XDEBUG_INFO("CXDebugConsole::Setup could not unlock Local Memory used in dialog creation\n");
    else
        .
        :
        .


In this extract you can see I am requesting Windows for Local memory allocation and locking (at the beginning). If it allocates and locks flawlessly, it then proceeds with what its meant to do, and, when the memory is finally no longer needed, it attempts to free it.

This is where it goes wrong!

Not only can I not Unlock the memory but also I can't Free it.

My question is, seeing I am creating a modeless-dialogbox, would it be possible, somehow, that CreateIndirect() (or a low-level Win32 API method) be already deallocating the memory for me? I am confused because CreateIndirect does not receive the memory handle held by m_hLocal, although it does receive a pointer to the dialog template...

Thank you so much!

David Nimrod
GeneralRe: HLOCAL -- Local Memory alloc/dealloc Pin
David Crow27-Aug-04 2:24
David Crow27-Aug-04 2:24 
Generalusing #define to determine #include Pin
AssemblySoft26-Aug-04 14:37
AssemblySoft26-Aug-04 14:37 
GeneralRe: using #define to determine #include Pin
Christian Graus26-Aug-04 16:04
protectorChristian Graus26-Aug-04 16:04 
GeneralRe: using #define to determine #include Pin
AssemblySoft27-Aug-04 1:27
AssemblySoft27-Aug-04 1:27 
GeneralRe: using #define to determine #include Pin
David Crow27-Aug-04 2:27
David Crow27-Aug-04 2:27 
GeneralRe: using #define to determine #include Pin
AssemblySoft27-Aug-04 8:46
AssemblySoft27-Aug-04 8:46 
GeneralRe: using #define to determine #include Pin
David Crow27-Aug-04 9:13
David Crow27-Aug-04 9:13 
GeneralRe: using #define to determine #include Pin
AssemblySoft29-Aug-04 12:29
AssemblySoft29-Aug-04 12:29 
GeneralRe: using #define to determine #include Pin
AssemblySoft27-Aug-04 8:50
AssemblySoft27-Aug-04 8:50 
GeneralRe: using #define to determine #include Pin
rotu27-Aug-04 0:07
rotu27-Aug-04 0:07 
GeneralRe: using #define to determine #include Pin
AssemblySoft27-Aug-04 1:26
AssemblySoft27-Aug-04 1:26 
GeneralRe: using #define to determine #include Pin
GKarRacer27-Aug-04 10:44
GKarRacer27-Aug-04 10:44 
GeneralRe: using #define to determine #include Pin
AssemblySoft29-Aug-04 12:29
AssemblySoft29-Aug-04 12:29 
GeneralRe: using #define to determine #include Pin
GKarRacer31-Aug-04 7:40
GKarRacer31-Aug-04 7:40 
Generalpretranslatemessageoverride Pin
prateekkathuria26-Aug-04 10:27
prateekkathuria26-Aug-04 10:27 
GeneralRe: pretranslatemessageoverride Pin
Bob Stanneveld26-Aug-04 10:33
Bob Stanneveld26-Aug-04 10:33 
GeneralRe: pretranslatemessageoverride Pin
prateekkathuria26-Aug-04 10:39
prateekkathuria26-Aug-04 10:39 

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.