菜鸟,在线等待! 请教关于模态窗口创建到显示到关闭。请举个例子。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CYourDialog dlg;dlg.DoModal(); 调用如 isdong(西西) ;关闭调用CDialog::OnCancel(); 怎么使用createshowwindowdestroywindow 这几个函数,给个实例先,tks 参考一下,我用的是DialogBoxParam,你需要自己建立一个资源void CVCDebugDlg::OnBtnwin() { int iRet; // TODO: Add your control notification handler code here PGINA_CONTEXT pgContext; pgContext = (PGINA_CONTEXT)malloc(sizeof(GINA_CONTEXT)); iRet = DialogBoxParam(AfxGetApp()->m_hInstance, (LPTSTR)MAKEINTRESOURCE(IDD_DLGTEST), AfxGetApp()->m_pMainWnd->m_hWnd, LogonDlgProc, (LPARAM)pgContext); if (iRet== 1) { ShowMessage("WLX_SAS_ACTION_NONE", "IDCANCEL", 1); } if (iRet== 2) { ShowMessage("WLX_SAS_ACTION_LOGON", "IDOK", 1); } if (iRet== 3) { ShowMessage"WLX_SAS_ACTION_SHUTDOWN", "BTNSHUTDOWN", 1); }}VOIDCenterWindow( HWND hwnd ){ RECT rect; LONG dx, dy; LONG dxParent, dyParent; LONG Style; // Get window rect GetWindowRect(hwnd, &rect); dx = rect.right - rect.left; dy = rect.bottom - rect.top; // Get parent rect Style = GetWindowLong(hwnd, GWL_STYLE); if ((Style & WS_CHILD) == 0) { // Return the desktop windows size (size of main screen) dxParent = GetSystemMetrics(SM_CXSCREEN); dyParent = GetSystemMetrics(SM_CYSCREEN); } else { HWND hwndParent; RECT rectParent; hwndParent = GetParent(hwnd); if (hwndParent == NULL) { hwndParent = GetDesktopWindow(); } GetWindowRect(hwndParent, &rectParent); dxParent = rectParent.right - rectParent.left; dyParent = rectParent.bottom - rectParent.top; } // Centre the child in the parent rect.left = (dxParent - dx) / 2; rect.top = (dyParent - dy) / 3; // Move the child into position SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, 0, 0, SWP_NOSIZE); SetForegroundWindow(hwnd);}LogonDlgInit( HWND hDlg, LPARAM lParam){ CenterWindow(hDlg); return(TRUE);}intCALLBACKLogonDlgProc( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam){ switch (Message) { case WM_INITDIALOG: return(LogonDlgInit(hDlg, lParam)); case WM_COMMAND: if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, 1); } if (LOWORD(wParam) == IDOK) { EndDialog(hDlg, 2); } if (LOWORD(wParam) == IDC_BTNSHUTDOWN) { EndDialog(hDlg, 3); } break; return TRUE; } return FALSE;} 非模态显示CYouDialog *pDialog ;pDialog = new CYouDialog();pDialog->ShowWindow(SW_SHOW) ;销毁delete pDialog ; taoni(堕落天使) 的方法好像不行.我刚试了一下至于SnowTopCh的方法,菜鸟迷惘中 CYouDialog dlg;dlg.Create(YOUR_ID)dlg.ShowWindow(SW_SHOW) ;whlie()。。dlg.DestroyWindow() 显示不出来,只是屏幕闪烁一下。while().....是什么意思?? 你不是把dlg.DestroyWindow()也跟上了吧 哦,漏写了一条语句,抱歉。CYouDialog *pDialog ;pDialog = new CYouDialog();pDialog->Create(ID_YOURDIALOG);//漏写了这条pDialog->ShowWindow(SW_SHOW) 关于linux网络编程远程命令调用的问题 判断鼠标的位置。。。 MFC中的鼠标拖拽图像问题!(急) 请教:如何将几个属性页对话框弄得同样大小? 如何判断两幅图实际上是对同一物体拍的? CString str; str.Formate("%f",num)后出错!其中num为float型 高手们,斑竹们快进来阿:视图不显示的状况下,如何进行视图的打印?(详细请看文章内容) 急!!!!ATL中怎么重载函数?? 怎么让CEdit响应ctrl+c,ctrl+v,ctrl+x快捷键! 状态条分区问题 renn请进 关于工具栏的重新设置大小的问题?
dlg.DoModal();
关闭调用CDialog::OnCancel();
showwindow
destroywindow 这几个函数,给个实例先,tks
void CVCDebugDlg::OnBtnwin()
{
int iRet;
// TODO: Add your control notification handler code here
PGINA_CONTEXT pgContext;
pgContext = (PGINA_CONTEXT)malloc(sizeof(GINA_CONTEXT));
iRet = DialogBoxParam(AfxGetApp()->m_hInstance,
(LPTSTR)MAKEINTRESOURCE(IDD_DLGTEST),
AfxGetApp()->m_pMainWnd->m_hWnd,
LogonDlgProc,
(LPARAM)pgContext);
if (iRet== 1)
{
ShowMessage("WLX_SAS_ACTION_NONE", "IDCANCEL", 1);
}
if (iRet== 2)
{
ShowMessage("WLX_SAS_ACTION_LOGON", "IDOK", 1);
}
if (iRet== 3)
{
ShowMessage"WLX_SAS_ACTION_SHUTDOWN", "BTNSHUTDOWN", 1);
}
}VOID
CenterWindow(
HWND hwnd
)
{
RECT rect;
LONG dx, dy;
LONG dxParent, dyParent;
LONG Style; // Get window rect
GetWindowRect(hwnd, &rect); dx = rect.right - rect.left;
dy = rect.bottom - rect.top; // Get parent rect
Style = GetWindowLong(hwnd, GWL_STYLE);
if ((Style & WS_CHILD) == 0) { // Return the desktop windows size (size of main screen)
dxParent = GetSystemMetrics(SM_CXSCREEN);
dyParent = GetSystemMetrics(SM_CYSCREEN);
} else {
HWND hwndParent;
RECT rectParent; hwndParent = GetParent(hwnd);
if (hwndParent == NULL) {
hwndParent = GetDesktopWindow();
} GetWindowRect(hwndParent, &rectParent); dxParent = rectParent.right - rectParent.left;
dyParent = rectParent.bottom - rectParent.top;
} // Centre the child in the parent
rect.left = (dxParent - dx) / 2;
rect.top = (dyParent - dy) / 3; // Move the child into position
SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, 0, 0, SWP_NOSIZE);
SetForegroundWindow(hwnd);
}
LogonDlgInit(
HWND hDlg,
LPARAM lParam)
{
CenterWindow(hDlg);
return(TRUE);
}
int
CALLBACK
LogonDlgProc(
HWND hDlg,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
switch (Message)
{
case WM_INITDIALOG:
return(LogonDlgInit(hDlg, lParam)); case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, 1);
}
if (LOWORD(wParam) == IDOK)
{
EndDialog(hDlg, 2);
}
if (LOWORD(wParam) == IDC_BTNSHUTDOWN)
{
EndDialog(hDlg, 3);
}
break;
return TRUE;
}
return FALSE;
}
CYouDialog *pDialog ;
pDialog = new CYouDialog();
pDialog->ShowWindow(SW_SHOW) ;
销毁
delete pDialog ;
至于SnowTopCh的方法,菜鸟迷惘中
dlg.Create(YOUR_ID)
dlg.ShowWindow(SW_SHOW) ;
whlie()
。。
dlg.DestroyWindow()
while()
.....
是什么意思??
CYouDialog *pDialog ;
pDialog = new CYouDialog();
pDialog->Create(ID_YOURDIALOG);//漏写了这条
pDialog->ShowWindow(SW_SHOW)