CCommandLineInfo cmdInfo;

zhuliangsu 2003-10-21 01:23:40
1.用MFC WISARD创建的程序
为什么还要调用CCommandLineInfo 之类的与命令行有关的东西

2.没有下面的代码,程序就无法运行,为什么?

CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

if (!ProcessShellCommand(cmdInfo))
return FALSE;
...全文
30 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
leopardsmith 2003-10-21
  • 打赏
  • 举报
回复
解析你的程序名 和 各个参数这是必要的一步
C++面向对象编程八皇后问题 BOOL CMyqueenApp::InitInstance() { 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(CMyqueenDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CMyqueenView)); 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; VERIFY( 1 == InitSkinMagicLib( AfxGetInstanceHandle(), "Demo" , NULL, NULL ) ); VERIFY( 1 == LoadSkinFromResource( AfxGetInstanceHandle() , "DEFAULT" ,"DEFAULT") ); VERIFY( 1 == SetWindowSkin( m_pMainWnd->m_hWnd , "MainFrame" )); VERIFY( 1 == SetDialogSkin( "Dialog" ) ); //((CMainFrame*)m_pMainWnd)->m_bSkinned = TRUE; //((CMainFrame*)m_pMainWnd)->m_nIndex = 0; m_pMainWnd->SetWindowText("八皇后问题演示"); // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow();
Visual C++ 知识库电子书 VC 知识库文章 VC 知识库Faqs VC 知识库Tips VC++5.0是Microsoft新近推出的可视化C++集成开发环境。它在继承以前VC++的基础上增加了许多新的功能,用于支持Win32平台应用程序、服务程序和控件的开发。VC++5.0提供了强大、快捷的编程工具,其中最基本的是三个导航: AppWizard用于程序框架的生成,AppStudio用于资源的编辑, ClassWizard用于类的编辑和管理。其中,窗口、菜单等无需用户编写程序,而由系统自动生成。但在许多情况下,用户要设置自己希望的窗口(即定制窗口)。 一、如何在多文档界面下去掉开始的子窗口 在多文档界面下,自动生成一个新的子窗口,而一个实际的应用系统往往是由用户操作后再生成新的窗口。为了去掉开始的子窗口,可在应用程序文件分析命令行的语句 CcommandLineInfo cmdInfo; ParseCommandLine(cmdInfo);后加入: cmdInfo.m_nShellCommand=CcommandLineInfo::FileNothing; 去掉子窗口后,就只剩下主框架窗口了。因为在多文档界面中,系统生成两个菜单:一个是用户的菜单,另一个是系统主框架菜单。通常用户工作在用户菜单。为了保证菜单界面不变,可修改主框架菜单资源,使其与用户菜单保持一致。 二、修改窗口标题栏 在缺省情况下,窗口标题栏中显示的文档名为文件名。若要在标题栏显示一个长字符串,而又不修改文件名,则可将项目工作区转换到 Resource View面版,选择串表( StringTable)资源,在StringTable中双击 IDR-MAIN-FRAME项,caption中显示一字符串xx yy......,将第一个参数修改为用户自己希望见到的主窗口标题即可。 三、修改主框架窗口、子窗口及其显示性质 可通过覆盖CWnd的成员函数PreCreateWindow来修改主窗口和子窗口。PreCreateWindow函数在即将创建窗口前被调用,函数原型为: Virtual BOOL PreCreateWindow(CREATESTRUCT cs) 如果要覆盖 PreCreateWindow函数,则在创建窗口前可以修改 CREATESTRUCT结构以替换缺省参数。CREATESTRUCT结构存放窗口特征,如窗口坐标、风格等,还可以定义新窗口风格, 若想修改主框架窗口,则可以在MainFrm.cpp的下列成员函数中加入待修改的内容。例如: BOOL CmainFrame::PreCreateWindow(CREATESTRUCT&cs) { //通过修改CREATESTRUCT结构来修改窗口类或风格 //定义新窗口的高度、宽度 cs.cx=450; cs.cy=300; //定义新窗口风格为去掉主窗口名及最大化等按钮 cs.style=ws-POPWINDO; return CframeWnd::PreCreateWindow(cs); } 定制子窗口的操作与上述主窗口相同,可在 ChildFrm.cpp中加入以下内容: BOOL CmainFrame::PreCreateWindow(CREATESTRUCT&cs) { //通过修改CREATESTRUCT结构来修改窗口类或风格
本资源含大量的图像处理代码(C++) int kind = 0; // 图像类型(8位kind=1,24位kind=3,初始化kind=0) LONG Bytes = 0; // 图像分配内存的最大值 BOOL Step; // 菜单上一步、下一步启动禁用标志 -> FALSE为下一步禁用 BOOL Step_All = TRUE; // 初始化上一步、下一步 -> TRUE为禁用 BOOL fdj = TRUE; // 可以使用放大镜的标志 int screen_width = GetSystemMetrics(SM_CXSCREEN); // 获取屏幕宽度 int screen_height = GetSystemMetrics(SM_CYSCREEN); // 获取屏幕高度 BOOL DirectDraw_Pause = FALSE; // DirectDraw显示时键盘中断标志 int Match_x = 0; // 模板匹配中左上方坐标 - 行 int Match_y = 0; // 模板匹配中左上方坐标 - 列 CString Match_result = ""; // 模板匹配结果 SOCKET m_socket; // 定义一个套接字 ///////////////////////////////////////////////////////////////////////////// // CMy002App initialization BOOL CMy002App::InitInstance() { // *** 判断程序是否已运行 *** HANDLE hMutex; // 定义一个句柄 // 创建一个互斥对象,并返回句柄 hMutex = CreateMutex(NULL, TRUE, "7 4 的程序"); // 主线程拥有互斥对象,相当于一次请求互斥对象 // hMutex = CreateMutex(NULL, FALSE, "7 4 的程序"); // 主线程不拥有互斥对象 // WaitForSingleObject(hMutex,INFINITE); // 请求互斥对象 if (hMutex) // 判断句柄是否有值 { if (ERROR_ALREADY_EXISTS == GetLastError()) // 判断程序是否已运行 { AfxMessageBox("该应用程序已运行! ", MB_ICONINFORMATION | MB_OK); ExitProcess(0); // 退出应用程序 } } ReleaseMutex(hMutex); // 释放互斥对象 // *** 登陆密码对话框 *** Password dlg; // 定义对话框对象 dlg.DoModal(); // 显示并运行模态对话框 - 用户登录对话框 // CG: The following block was added by the Splash Screen component. \ { \ CCommandLineInfo cmdInfo; \ ParseCommandLine(cmdInfo); \ \ C_SplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash); \ } 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. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_MY002TYPE, RUNTIME_CLASS(CMy002Doc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CMy002View)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 启动时不打开子窗口 cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class 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) //}}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) //}}AFX_MSG_MAP END_MESSAGE_MAP() // App command to run the dialog void CMy002App::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CMy002App message handlers BOOL CMy002App::PreTranslateMessage(MSG* pMsg) { // CG: The following lines were added by the Splash Screen component. if (C_SplashWnd::PreTranslateAppMessage(pMsg)) return TRUE; return CWinApp::PreTranslateMessage(pMsg); }

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧