| |

VerySource

 Forgot password?
 Register
Search
View: 566|Reply: 3

Ask for help !!! The unhandled exception under Release!

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-4 19:30:01
| Show all posts |Read mode
The program has no problems in Debug, but an unhandled exception in config.exe: 0xC0000005: Access Violation will appear under Release.

There is a list control in the interface, which contains a line of content. Above this line, double-clicking the event is correct, but if you double-click in the blank space, you will get the above error.

BEGIN_MESSAGE_MAP (CSetODBCDlg, CDialog)
ON_NOTIFY (NM_DBLCLK, IDC_ODBC_BASE_LIST, OnListDbClick) // Double-click list control
END_MESSAGE_MAP ()

void CSetODBCDlg :: OnListDbClick ()
{
POSITION pos = ((CListCtrl *) GetDlgItem (IDC_ODBC_BASE_LIST))-> GetFirstSelectedItemPosition ();
if (pos == NULL) // click on a blank line
{
TRACE0 ("No items were selected!\n");
}
else // click on a non-empty row
{
int nItem = ((CListCtrl *) GetDlgItem (IDC_ODBC_BASE_LIST))-> GetNextSelectedItem (pos);
Ranch
CDirSearchCfgDlg dlg (this, EDirectoryODBC, nItem);
dlg.DoModal ();
}
}

Thank you Niuren for analysis, thank you very much! !! !!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-12 14:45:01
| Show all posts
NItem == -1, CDirSearchCfgDlgdlg(this, EDirectoryODBC, nItem) when clicking in the blank space;
If there is a problem with nItem==-1, just block the nItem==-1.
Reply

Use magic Report

0

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-12 19:15:01
| Show all posts
If you don’t know where the problem is, you can output debugging information
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Great Britain

 Author| Post time: 2020-6-14 14:00:02
| Show all posts
There will always be problems with this list control. I don't know if it is a problem with the initialization function.
BOOL CSetODBCDlg::OnInitDialog()
{
LOAD_DYNSTRINGS(theApp.GetDico());

m_popmenu.LoadMenu(IDR_DIR_PMENU_ODBC_CFG);
theApp.GetDico()->TranslateMenu(&m_popmenu);

CListCtrl *listCtrl = (CListCtrl*)GetDlgItem(IDC_ODBC_BASE_LIST);

// Draw and load control
DrawControl();

listCtrl->SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);

//Get defined base in registry
if (DIR_IsODBCDirectoryExist())
{
int nbODBCdir = DIR_GetODBCDirectoryNb();
ODBCBaseDef odbcBaseDef;

for (int i=0;i<nbODBCdir;i++)
{
DIR_GetODBCDirectoryInfo(i,&odbcBaseDef);
AddItem(&odbcBaseDef);
}
}

listCtrl->SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);


return FALSE;
}

void CSetODBCDlg::DrawControl()
{
CListCtrl *listCtrl = (CListCtrl*)GetDlgItem(IDC_ODBC_BASE_LIST);

CRect rect;
listCtrl->GetClientRect(&rect);
rect.right -= CXVSCROLL + 1;

// create column
LV_COLUMN lvC;

lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.fmt = LVCFMT_LEFT;

// Create only one column
lvC.iSubItem = 0;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_DIRECTORY_NAME");
lvC.cx = rect.Width()*3/10; // column 1

listCtrl->InsertColumn(0,&lvC);

lvC.iSubItem = 1;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_FILE_NAME");
lvC.cx = rect.Width()*11/20; // column 2

listCtrl->InsertColumn(1,&lvC);
The
lvC.iSubItem = 2;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_TABLE_NAME");
lvC.cx = rect.Width()*1/5; // column 3

listCtrl->InsertColumn(2,&lvC);

}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list