|
Are you sure LocalAlloc call succeeds?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
The function returns a valid handle to a piece of memory and not NULL, so it should have succeeded, BUT, i've found out that the when i allocate two pieces of memory after each other (which is what i do in my program) the second allocation is only 8 bytes away from the first one.
sSourceBuffer = (BYTE *)LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, dwSourceBufferSize);
sDestBuffer = (BYTE *)LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, dwDestBufferSize);
The first one gets the address 0x0091000c and the seconds gets 0x00910014. What could be wrong here?
BTW, at runetime the dwDestBufferSize is 73599, and the dwSourceBufferSize is 176400.
Thanks.
|
|
|
|
|
LocalAlloc() does not return a pointer, it returns a handle, aka HLOCAL. Your memset fails because the address you're sending is not really an address at all. In order to translate that HLOCAL into a valid pointer to physical memory, call LocalLock(). LocalLock will return an actual pointer to physical memory which you can then use. BTW, you wouldn't have to call memset there and initialize the buffer to zero, since you're specifying LMEM_ZEROINIT in the call to LocalAlloc()... it's redundant
DWORD dwBufferSize = 176400;
HLOCAL hBuffer = NULL;
LPVOID lpBuffer = NULL;
__try
{
hBuffer = LocalAlloc( LMEM_MOVEABLE | LMEM_ZEROINIT, dwBufferSize );
if( hBuffer )
{
lpBuffer = LocalLock( hBuffer );
if( lpBuffer )
{
}
}
}
__finally
{
if( hBuffer )
{
LocalUnlock( hBuffer );
LocalFree( hBuffer );
}
}
</code>
Ty
|
|
|
|
|
By specifying LMEM_MOVEABLE , LocalAlloc is not returning a pointer to memory, but a handle. Either use LMEM_FIXED instead, or use LocalLock to convert the handle to an actual pointer.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I developed a dialer which creates an entry in DUN but the problem is tht it can't disable multilink programatically. It doesnt work with my client as it doesnt connect to their ISP as long as multilink is enabled. It works on WinXP because it can disable multilink.
I dont want to disable it globally through registry. ANybody has any thought plz share it with me if it is gonna be helpful to me.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
ok I have read a few post now so I know that you have to handle the WM_KICKIDLE message to be able manipulate menus in a dialog nased app. What I now need to know is do I update the menu in the menus UPDATE_COMMAND_UI or do I have to create a CMenu object and pull and manipulate the menu in a user function? If someone could give me ALL the code snipits they used or walk my dumb @$$ through this I would apreciate it.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
You can find all code snippets you need to walk your dumb@$$ through this in DLGCBR32 MFC sample (which comes with VC++).
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
OK I soent some time looking through the code and still no. I now understand why just UPDATE_COMMAND_UI fails, it doesn't get a pointer to the dialog. Stupid MFC. SO I need to pass OnUpdateCmdUI the pointer to my dialog. But, sorry, I am new and this doesn't give me everything I need. How do I set up my app to call OnUpdateCmdUI() It gives me a not found error. I cannot find it in the Class wiz. I probably need to create it in the message map myself, but I wanted to ask.
Still a Dumb @$$
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
The KB article Q242577 'PRB: Update Command UI Handlers Do Not Work for Menu Attached to a Dialog Box' may help.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Tomasz I could kiss you. Why others could not reference this I don't know. This is EXACTLY what I was looking for. I guess I should start looking into thouse KB articles. THANK YOU SO MUCH!!!
Not so much of a Dumb @$$ anymore
Darroll
PS.
I am not really going to kiss you so don't get to excited.
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
darroll wrote:
I am not really going to kiss you so don't get to excited
Without the photo in your profile I didn't get excited anyway
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I still hope you don't get excited but I posted my pic in my profile.
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
darroll wrote:
I still hope you don't get excited
I don't.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Is it possible to get the height of the titlebar of a modeless CDialog? I have this code currently which fits the CDialog exactly into my ImageBox. I want it to fit such that the client area has the exact fit to the imagebox, and the titlebar extends above.
CRect picRect;
m_THBImage6.GetWindowRect(&picRect);
pdlg0->SetWindowPos(&CWnd::wndNoTopMost,picRect.left,picRect.top,picRect.Width(),picRect.Height(),SWP_SHOWWINDOW );
pdlg0->ShowWindow(SW_SHOW);
MSDN doesnt say, but does Width() return the number of pixels? In that case, I'd need to know the titlebar height in pixels too. I am thinking that the new code to do what I want would be:
CRect picRect;
m_THBImage6.GetWindowRect(&picRect);
pdlg0->SetWindowPos(&CWnd::wndNoTopMost,picRect.left,picRect.top,picRect.Width(),<code>picRect.Height()+ titleBarHeight</code>,SWP_SHOWWINDOW );
pdlg0->ShowWindow(SW_SHOW);
|
|
|
|
|
Use AdjustWindowRect[Ex].
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Simple and stupid question : I want to handle WM_HOTKEY in my CDialog dervied class, but I don't know how to do this ??
|
|
|
|
|
You'll have to add handler/message map entry (ON_MESSAGE) manually. Check ON_MESSAGE docs for more info.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Hi !
Anybody knows how can I highlite a specific line in the list control ?
If I try SetBkColor(..) it will do it fot the whole list.
I want to highlite just few items ?
Thank you !
|
|
|
|
|
SetItemState(itemIndex, LVIS_SELECTED, LVIS_SELECTED);
or
SetItemState(itemIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
|
You will most likely have to implement a custom draw algorithm for a specific line. Browse the list control section of CodeProject and CodeGuru for examples.
Kuphryn
|
|
|
|
|
To enable full row highlighting in a list control:
m_ctrlList.SetExtendedStyle(m_ctrlList.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
- Rob
|
|
|
|
|
I got the following suggestion (which worked, thanks) from one of you. Could anyone tell me where the wndTop argument came from and what it does? I did not declare it nor saw it anywhere in my code.
m_ProgBar.SetWindowPos(&wndTop,//???where did it come from?
rect.left,
rect.top,
rect.Width(),
rect.Height(),
NULL);
Thanks
ralf.riedel@usm.edu
|
|
|
|
|
CWnd::wndTop is MFC wrapper for HWND_TOP constant. Since you can't use constant where CWnd* is required, they had to create static object representing HWND_TOP value.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|