在View类里定义m_MyDialog;
在你想显示对话框的地方:
m_MyDialog.Create(IDD_ABOUTBOX, this);
m_MyDialog.ShowWindow(SW_SHOW);就出来了~~~我觉得VC很适合初学者~~~~~
在你想显示对话框的地方:
m_MyDialog.Create(IDD_ABOUTBOX, this);
m_MyDialog.ShowWindow(SW_SHOW);就出来了~~~我觉得VC很适合初学者~~~~~
解决方案 »
- 在数据库中查询一段时间内的数据,SQL语句怎么写?
- 估计我的问题没有高手来回答了,不过还是侥幸一下吧?关于声卡的。
- 如何改变标题栏的字体
- 我的这一段代码哪儿有问题?为什么有的地方字体可以修改,有的没变化
- 用CHTMLVIEW类打开DOC文件正常,但最大化程序之后,DOC文档显示不正常
- ping 程序如何实现
- 用过VC6和VC.NET的朋友请给些建议。答者有分。
- ATL COM Support MFC的问题一个!
- 谁能给我讲讲(SDK中)Dialog 是怎样由CreateWindowEx( )生成的?
- 为啥加索引的俩个表(全部字段) //查询比不加的慢呢。。。
- 怎样使文档在视图中显示?
- 请看ScrollBar
我运行了程序,什么现象都没有发生。
如果想在程序一开始的时候就显示这个对话框,该怎么办?
是在app中加命令吗?
enum { IDD = IDD_xxx_FORM };
把这个对话框资源赋予了view
怎样再在view中定义一个m_MyDialog?
CMyDialog m_MyDialog;
m_MyDialog.Create(IDD_ABOUTBOX);
m_MyDialog.ShowWindow(SW_SHOW);
以前我都是这么做的。
可是这次对话框资源是属于View的。
这是什么意思?难道资源还能归属某类不成?
在你的View类中定义成员CDialog m_MyDialog, 已经说得很清楚了`~`~~~回复人: zx_sanjin(1.5kg, 不赊账~~~) (2001-11-28 16:18:12) 得0分
在View类里定义m_MyDialog;
在你想显示对话框的地方:
m_MyDialog.Create(IDD_ABOUTBOX, this);
m_MyDialog.ShowWindow(SW_SHOW);就出来了~~~
但是怎么在程序一开始就显示呢?
可是这回什么都没有。
就是不知道该怎样在App里调用这个VIew。
一运行就出错。
“winocc.cpp有错”
我没有用这个东东啊?
if (!ProcessShellCommand(cmdInfo))
出错。
这么就了还没解决??>??
return _AfxDispatchCmdMsg(this, nID, nCode,
lpEntry->pfn, pExtra, lpEntry->nSig, pHandlerInfo);
Mydlg.DoModal();
但是我要的那个没有。
一,使用 CFormView作为基类来生成 doc/view程序,那么,就会自动产生一个大概叫做IDD_FORM_DIALOG的对话框资源
二,如果使用 CView 作为基类,那么就不会自动产生,而要手工添加对话框资源
如果是在程序主框架启动前就调用对话框资源,如果没有在对话框资源(IDD_FORM_DIALOG)里面添加控件,在 processshellcommand出错的机会就小,如果还不行,就查一下这个资源的属性和一般的对话框资源有什么不同
呵呵,其实我不知道你想干什么,所以很难回答
// StockServer.cpp : Defines the class behaviors for the application.
//#include "stdafx.h"
#include "StockServer.h"#include "MainFrm.h"
#include "StockServerSet.h"
#include "StockServerDoc.h"
#include "StockServerView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CStockServerAppBEGIN_MESSAGE_MAP(CStockServerApp, CWinApp)
//{{AFX_MSG_MAP(CStockServerApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CStockServerApp constructionCStockServerApp::CStockServerApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}/////////////////////////////////////////////////////////////////////////////
// The one and only CStockServerApp objectCStockServerApp theApp;/////////////////////////////////////////////////////////////////////////////
// CStockServerApp initializationBOOL CStockServerApp::InitInstance()
{
//AfxMessageBox("Socket Init ...");
//Initialize Socket for network connection
//if (!AfxSocketInit())
//{
// AfxMessageBox("Socket Init Error!");
// return FALSE;
// }
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CStockServerDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CStockServerView));
AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// CStockServerView sv;// int nResponse=sv.DoModal();// if (nResponse=IDOK)
// {
//
// }
// else
// {
// } return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()// App command to run the dialog
void CStockServerApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}/////////////////////////////////////////////////////////////////////////////
// CStockServerApp message handlers
即使调用成功了,在实现对CView的操作时设及到doc/view结构的话也会出错。
CDialog myDialog;
myDialog.Create(...IDD_VIEW_FORM..);(资源好象是叫这个名字)
由于某些原因,wizards生成时没有选用Dialog类,而是选用了View/Set类。
: CRecordView(CStockServerView::IDD)
{ //{{AFX_DATA_INIT(CStockServerView)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
CDialog m_MyDialog; m_MyDialog.Create(IDD_STOCKSERVER_FORM, this);
m_MyDialog.ShowWindow(SW_SHOW);
}
如果是这样的话,
CStockServerApp::InitInstance()
{...
CDialog m_MyDialog;
m_MyDialog.DoModal();
return TRUE;
}
不就可以了吗?
CStockServerApp::InitInstance()
{...
CMyDlg myDialog;
myDialog.DoModal();return TRUE;
}
你可能是想在对话框里面得到某个参数,这样,就可以在CSingleDocTemplate* pDocTemplate;以前调用对话框,把参数传递到需要的地方
在View里面这样做不行吗?
为什么一定要在App里面调用对话框?