UpdateData(TRUE); if (m_user == _T("xiaoli") && m_pwd == _T("041104")) { MessageBox(_T("登录成功!")); CDialogEx::OnOK; }MessageBox内容不弹出来
时间: 2024-02-28 17:53:50 浏览: 125
根据您提供的代码,可能是因为在调用 `CDialogEx::OnOK();` 时,缺少了函数调用的括号,应该写成 `CDialogEx::OnOK();`,同时还需要注意,`CDialogEx::OnOK();` 应该在 `MessageBox` 弹出框之后调用。
因此,您可以尝试如下代码:
```
UpdateData(TRUE);
if (m_user == _T("xiaoli") && m_pwd == _T("041104")) {
MessageBox(_T("登录成功!"));
CDialogEx::OnOK();
}
```
另外,如果问题仍然存在,还需要检查对话框资源的设置和代码逻辑是否正确。
相关问题
void CMyImageView::OnBianyuan() { // TODO: 在此添加命令处理程序代码 CMyImageDoc* pDoc = GetDocument();//获取文档指针 ASSERT_VALID(pDoc); suanzi dlginputyuzhi;//定义阈值对话框类对象 dlginputyuzhi.DoModal();//弹出对话框 UpdateData(TRUE); if (pDoc->m_pDib == NULL) { AfxMessageBox("Error!"); return; } int mcols = pDoc->m_pDib->m_nCols; int mrows = pDoc->m_pDib->m_nRows; unsigned char* m_pData = NULL; m_pData = pDoc->m_pDib->pImgData; unsigned char* m_pDataOldPos = m_pData; unsigned char* a; int* b = NULL; int irows, jcols; int max = 0; int min = 255; vector<int>v; for (irows = 0; irows < mrows; irows++) { for (jcols = 0; jcols < mcols; jcols++) { int j = 0; int p = 0, q = 0; m_pData += irows * mcols + jcols; j += irows * mcols + jcols; if (j > mcols && (j + 1) % mcols != 0 && j < (mrows * (mcols - 1))) { p = 4 * (*m_pData) - *(m_pData + 1) - *(m_pData - 1) - *(m_pData - mcols) - *(m_pData + mcols); if (p > dlginputyuzhi.suanzi_1) { v.push_back(0); } else { v.push_back(255); } } m_pData = m_pDataOldPos; } } int aq = 0; for (irows = 0; irows < mrows; irows++) { for (jcols = 0; jcols < mcols; jcols++) { int j = 0; int p = 0, q = 0; m_pData += irows * mcols + jcols; j += irows * mcols + jcols; if (j > mcols && (j + 1) % mcols != 0 && j < (mrows * (mcols - 1))) { *m_pData = v[aq]; aq++; } m_pData = m_pDataOldPos; } } for (irows = 0; irows < mrows; irows++) { for (jcols = 0; jcols < mcols; jcols++) { int j = 0; int p = 0, q = 0; m_pData += irows * mcols + jcols; j += irows * mcols + jcols; if (irows>0&&irows<mrows-1&&jcols>0&&jcols<mcols-1) { if (*m_pData==0) { if (*(m_pData + 1) == 0 || *(m_pData - 1) == 0 || *(m_pData - mcols) == 0 || *(m_pData + mcols) == 0) { } else { *m_pData = 255; } } } m_pData = m_pDataOldPos; } } pDoc->UpdateAllViews(NULL); }仿照此代码,将其中的sobel算子改成Robert算子
void CMyImageView::OnBianyuan() {
// TODO: 在此添加命令处理程序代码
CMyImageDoc* pDoc = GetDocument();//获取文档指针
ASSERT_VALID(pDoc);
suanzi dlginputyuzhi;//定义阈值对话框类对象
dlginputyuzhi.DoModal();//弹出对话框
UpdateData(TRUE);
if (pDoc->m_pDib == NULL) {
AfxMessageBox("Error!");
return;
}
int mcols = pDoc->m_pDib->m_nCols;
int mrows = pDoc->m_pDib->m_nRows;
unsigned char* m_pData = NULL;
m_pData = pDoc->m_pDib->pImgData;
unsigned char* m_pDataOldPos = m_pData;
unsigned char* a;
int* b = NULL;
int irows, jcols;
int max = 0;
int min = 255;
vector<int>v;
for (irows = 0; irows < mrows; irows++) {
for (jcols = 0; jcols < mcols; jcols++) {
int j = 0;
int p = 0, q = 0;
m_pData += irows * mcols + jcols;
j += irows * mcols + jcols;
if (j > mcols && (j + 1) % mcols != 0 && j < (mrows * (mcols - 1))) {
// Robert算子
p = abs(*m_pData - *(m_pData + mcols + 1)) + abs(*(m_pData + 1) - *(m_pData + mcols));
if (dlginputyuzhi.suanzi_1 != 0 && p > dlginputyuzhi.suanzi_1) {
v.push_back(0);
}
else {
v.push_back(255);
}
}
m_pData = m_pDataOldPos;
}
}
int aq = 0;
for (irows = 0; irows < mrows; irows++) {
for (jcols = 0; jcols < mcols; jcols++) {
int j = 0;
int p = 0, q = 0;
m_pData += irows * mcols + jcols;
j += irows * mcols + jcols;
if (j > mcols && (j + 1) % mcols != 0 && j < (mrows * (mcols - 1))) {
*m_pData = v[aq];
aq++;
}
m_pData = m_pDataOldPos;
}
}
for (irows = 0; irows < mrows; irows++) {
for (jcols = 0; jcols < mcols; jcols++) {
int j = 0;
int p = 0, q = 0;
m_pData += irows * mcols + jcols;
j += irows * mcols + jcols;
if (irows > 0 && irows < mrows - 1 && jcols > 0 && jcols < mcols - 1) {
if (*m_pData == 0) {
if (*(m_pData + 1) == 0 || *(m_pData - 1) == 0 || *(m_pData - mcols) == 0 || *(m_pData + mcols) == 0) {
}
else {
*m_pData = 255;
}
}
}
m_pData = m_pDataOldPos;
}
}
pDoc->UpdateAllViews(NULL);
}
void CR312105010307lxtView::OnBianyuangenzong(){// TODO: 在此添加命令处理程序代码 double a1 = 254; CR312105010307lxtDoc* pDoc = GetDocument();//获取文档指针 ASSERT_VALID(pDoc); if (pDoc->m_pDib == NULL) { AfxMessageBox("Error!"); return; } CBianyuangenzongDlg dlginputyuzhi;//定义阈值对话框类对象 dlginputyuzhi.DoModal();//弹出对话框UpdateData(TRUE);// // 获取图像的列数和行数int mIMAGE_HEIGHT = pDoc->m_pDib->m_nIMAGE_HEIGHT; int mIMAGE_WIDTH = pDoc->m_pDib->m_nIMAGE_WIDTH; unsigned char* m_pData = NULL; m_pData = pDoc->m_pDib->pImgData; unsigned char* m_pDataOldPos = m_pData; unsigned char* a; int* b = NULL; int iIMAGE_WIDTH, jIMAGE_HEIGHT; int max = 0; int min = 255; vector<int>v; //操作二维数组中的元素for (iIMAGE_WIDTH = 0; iIMAGE_WIDTH < mIMAGE_WIDTH; iIMAGE_WIDTH++) { for (jIMAGE_HEIGHT = 0; j IMAGE_HEIGHT< mIMAGE_HEIGHT; jIMAGE_HEIGHT++) { int j = 0; int p = 0, q = 0; m_pData += iIMAGE_WIDTH * mIMAGE_HEIGHT + jIMAGE_HEIGHT; j += iIMAGE_WIDTH * mIMA这段代码使用了哪种算子
这段代码没有使用具体的边缘检测算子,而是实现了一种基于像素值的边缘检测方法。具体来说,代码中遍历了图像中的每个像素点,对于每个像素点,计算其周围像素点的像素值差异,并将差异值作为边缘强度。如果差异值大于预设的阈值,则将该像素点设置为最大灰度值,否则将其设置为最小灰度值。因此,这种方法可以被视为一种基于阈值的边缘检测方法,而不是基于特定算子的方法。
阅读全文