|
Well, most of the errors are MFC errors, but I get these, and I think that it will not be difficult for somebody outhere to tell me whether these errors are in my code, or some MFC stuff, and a possible workaround if any.
Thanks, still waiting....
|
|
|
|
|
and also any comments on these first - chance exceptions?! what is the cause for them?
|
|
|
|
|
Deian wrote:
what is the cause for them?
It could be any number of things. Searching MSDN for "first chance exception access violation" yielded a bunch of hits, all of which show various reasons.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I have been using BC since the DOS/Win31 days and prefer not to compile and run any program in debug mode without it. Some of the things BC reports as errors may not be, the most common example is invalid argument. Some times it is correct, but other times it is reporting a NULL or some other value as incorrect. In the case of NULL, it has failed to take in account the the function description specifies a NULL parameter is valid. Once in a while it will report an interger value is invalid because it is not in a known range, this is not always correct. If it is reporting memory leaks and resource leaks (watch out), because it is almost always correct. First-chance exceptions (Access Violation) you see in the debug pane are usualy an MFC thing and may mean nothing. Normaly if you have commited an access violation, you will know it; because the program will up-chuck and the debugger will break on offending line (not normaly where the original violation occured).
INTP
|
|
|
|
|
Well, as far as the mutex problem. You need to call CloseHandle(m_hMutex) to close the mutex handle. That is the reason for the resource leak.
Kelly Herald
Software Developer
MPC
|
|
|
|
|
In the first case, ReleaseMutex only releases ownership, it does not delete the mutex.
if (m_hMutex)
{
ReleaseMutex(m_hMutex);
CloseHandle(m_hMutex);
}
For the second problem, you are loading hBitmap, then setting it in a control, but then deleting that bitmap. drop the DeleteObject(hBitmap) and modify the first section as follows:
if (hModule)
{
HBITMAP hBitmap = ::LoadBitmap(hModule, MAKEINTRESOURCE(1000));
ASSERT(hBitmap != NULL);
m_bmp.SetBitmap(hBitmap);
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'm writing a dialog based app and when I created it I didn't enable active x support now I'm wanting to add a rich edit to the dialog, but my program wont run. I added the AfxEnableControlContainer () to the InitInstance function, but when I call DoModal () on the dialog it's returning -1. I walked through the code and it never seems to return any error from any of the intermediate functions that DoModal calls. Is there anything besides AfxEnableControlContainer () that I need to call/do in order to enable active x controls? I know the control (rich edit) is the problem because when I remove it the program runs fine. Thanks.
- Aaron
|
|
|
|
|
Got any trace output?
Typically you'll see messages in the Output window which can help with debugging, if it's due to an ActiveX control.
The rich edit box is not an ActiveX control. It's a common control. You need to call AfxInitRichEdit if you're going to use one in a dialog box.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
My mistake. I thought it was an ActiveX control because there was trace output when I didn't have the AfxEnableControlContainer that said to add it. I assumed (falsely it would seem) that it meant the rich edit was an ActiveX. Thanks for the help.
- Aaron
|
|
|
|
|
Hi Aaron,
You are obviously adding the RichEdit control from the Controls toolbar. If this is the case then you need to do the following for it to work:
BOOL CNoactivexApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
AfxInitRichEdit();
CNoactivexDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
also make sure that #include <afxcmn.h> is listed in your stdafx.h
As a side note, this isn't an ActiveX control, if you go to the dialog resource and right-mouse "Insert ActiveX control...", select "Microsoft Rich Textbox Control 6.0" then this WILL use the ActiveX control and you DONT need to perform the AfxInitRichEdit(); call.
Hope this helps,
Andy
|
|
|
|
|
Guess I should have done some reading on the rich edit instead of just assuming that it was an ActiveX control. Thanks for the code example. Quick question...Do I still need to be calling AfxEnableControlContainer if I'm not using any ActiveX controls? Thanks for the help.
- Aaron
|
|
|
|
|
Hi Aaron,
No you don't need to call AfxEnableControlContainer unless you want to support containment of ActiveX objects. My advice would be to add it anyway - YOU may not need it now but the developer that comes along after you may need it to enhance your app (save him going through the same hoops).
If you do leave it in, don't forget to include #include <afxdisp.h> in your stdafx.h file.
Cheers,
Andy
|
|
|
|
|
Thanks for all the help Andy.
- Aaron
|
|
|
|
|
Some how, when I opened up my project today, my class wizard was corrupt and woulnt open. An error popped up saying "Cannot access the ClassView information file. ClassView information will not be available." The clw file was there, but contained no class info.
When I deleted it, and went into the View->ClassWizard to rebuild it, I included all the files within my project. However, the new clw file still does not contain class info and I cannot browse my classes any more. Any ideas??
I did not create my class using the ClassWizard, but they always showed up in the ClassView and WizardBar etc. Any ideas on how to get this back? THanks
-C
|
|
|
|
|
Did you delete some project files on accident? If you saved backup copies of the project, then use one of them.
Kuphryn
|
|
|
|
|
I didnt delete any project files that I know of.
-C
|
|
|
|
|
delete ncb file
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I deleted the ncb file, but still no luck in rebuilding my ClassView. Any other ideas??
-C
|
|
|
|
|
1. Make sure the none of the files in the project are marked read-only.file is not marked read-only
2. Make sure no other instance of VC++ is open (sometimes VC++ does not release files when a workspace/project is closed). Also, check in the Task Manager that there is only one msdev.exe instance running - Sometimes the main window closes, but a msdev instance is still running in the background.
Bikram Singh
|
|
|
|
|
It worked for me when i deleted .clw and .ncb and rebuilt it.
|
|
|
|
|
Hi,
I have a list ctrl with 10 rows (items) and 4 subitems. Initially color of 4th subitem for each row is green. I achieved it through Custom Draw feature. Now i am displaying a popup menu items on the right click of the any row(item). This popup menu item is having two menu items red and blue. I want that when i select red option then 4th subitem of the selected row turned to red from green. Now to implement this functionality, I am doing like below:
Handler of the OnRed() is :
void CTestListCtrlView::OnRed()
{
int iItemIndex;
iItemIndex = m_ListCtrl.GetSelectionMark();
LVITEM Item;
Item.mask = LVIF_PARAM;
Item.iItem = iItemIndex;
Item.iSubItem = 4;
Item.lParam = RED;
BOOL x = m_ListCtrl.SetItem(&Item);
m_ListCtrl.SendMessage(WM_NOTIFY,NM_CUSTOMDRAW,(LPARAM)&Item);
}
Custom Draw Handler is:
void CTestListCtrlView::OnCustomdrawMyList(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
LVITEM rItem;
ZeroMemory ( &rItem, sizeof(LVITEM) );
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
rItem.iItem = nItem;
m_ListCtrl.GetItem ( &rItem );
LPARAM lp = rItem.lParam;
if (pLVCD->iSubItem == 4 && rItem.lParam == 0 )
{
TRACE("In the Green List");
crText = RGB(0,0,0);
crBkgnd = RGB(0,255,0);
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
}
if (pLVCD->iSubItem == 4 && rItem.lParam== 1 )
{
TRACE("In the Red List");
crText = RGB(0,0,0);
crBkgnd = RGB(255,0,0);
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
}
*pResult = CDRF_DODEFAULT;
}
}
Initially when list control is first drawn i am getting 4th subitem as GREEN bot when i am selecting RED through pop up menu item, 4th subitem is not getting red. In fact application is getting crashed and application never reaches to "In the Red List".
Please help me what i am doing wrong?. I am attaching the code sample also,please heve a look into it.
Thanks in Advance
Amit
|
|
|
|
|
There is no need to send a WM_NOTIFY message to the list control. One solution is just set the item's data, which in this case is index 3, to RED.
struct SubItemData
{
...
};
SubItemData *pSID = new SubItemData;
...
m_ListCtrl.SetItemData(INDEX, static_cast<dword>(pSID));
...
You got the idea.
Kuphryn
|
|
|
|
|
Instead of setting Item properties through SetItemData, i set the property through LVITEM structure and removed SendMessage as suggested by you but still not successful. Here is the code
void CTestListCtrlView::OnPopupRed()
{
LVITEM *Item = new LVITEM;
Item->iItem = 2;
m_ListCtrl.GetItem(Item);
Item->mask = LVIF_PARAM;
Item->lParam = 1; // 1 mean red
m_ListCtrl.SetItemData(iItemIndex,(DWORD&)*Item);
m_ListCtrl.Invalidate();
m_ListCtrl.UpdateWindow();
}
I included Invalidate() and UpdateWindow() so that my custom draw method OnCustomdrawMyList() could be called but still i am not getting the lparam value as 1 in my custom draw method. Please help.
Thanks for the reply.
|
|
|
|
|
What's up with dereferencing Item?
m_ListCtrl.SetItemData(iItemIndex,reinterpret_cast<dword>(Item));
Kuphryn
|
|
|
|