Click to See Complete Forum and Search --> : Saving and Restoring Toolbars


pineapple7788
June 12th, 2009, 03:59 AM
I am trying to Saving and Restoring Toolbars status by sending TB_SAVERESTORE message. MSDN says if you don't have user data to store with the toolbar buttons, you don't need to handle TBN_SAVE or TBN_RESTORE notification. So, now, the saving and restoring are fine, the program restores toolbar buttons correctly. However, if I try to kill that toolbar control restored, Visual Studio gives a warning message "Unhandled exception at 0x7c901230 in win32tst.exe: User breakpoint." This warning only shows if the program is launched inside the Visual Studio. It just runs fine if launched outside of Visual Studio. So I tried to debug with WinDbg.exe, and it gives a more detailed description of that user breakpoint warning "Invalid Address specified to RtlFreeHeap". Anybody knows what's wrong with the restoring? Thanks.


case WM_NOTIFY:
{
switch (((LPNMHDR)lParam)->code)
{
case TBN_GETBUTTONINFO:
{
LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lParam;

// Pass the next button from our array. There is no need to
// filter out buttons that are already used; they will be
// ignored.
int buttonCount = sizeof(tbButtons) / sizeof(TBBUTTON);
if (lpTbNotify->iItem < buttonCount)
{
lpTbNotify->tbButton = tbButtons[lpTbNotify->iItem];
return TRUE;
}
else
{
// No more buttons.
return FALSE;
}
}
break;

case TBN_QUERYINSERT:
case TBN_QUERYDELETE:
return TRUE;
case TBN_ENDADJUST:
{
TBSAVEPARAMS tbSave;
tbSave.hkr = HKEY_CURRENT_USER;
tbSave.pszSubKey = "Software\\key";
tbSave.pszValueName = "tbsave";
SendMessage(GetDlgItem(hWnd,ID_TOOLBAR),TB_SAVERESTORE, TRUE, (LPARAM)&tbSave);
}
return TRUE;
}
}
break;

cilu
June 12th, 2009, 04:50 AM
Run in Debugger, choose Retry when the exception happens and look in the call stack, maybe you can identify the last function from your code. That could be a start to figure out what the problem is.