超级模仿秀--挑战微软画图软件(1)

  学习Visual C++编程,有一个速成的办法就是首先跟着案例做,接着模仿现成的软件,最后独立创新。

                                                                                             -- Highness
 
       挑战微软 画图 软件,对于高手来说,其实并不是什么困难的事。对于刚入门的学习者利用 VisualC++ 编一个跟微软 画图 软件一模一样的工程,有一条路可以走。这条路就是 建立基本框架,功能逐一完善 。我们从画图软件中的菜单栏开始,首先在 ResouceView 视图里面,选择 Menu IDR_MAINFRAME, 使得菜单栏和画图一样。即:
------------------------------------------------------------------------------------------
文件 (F)| 编辑 (E)| 查看 (V)| 图像 (I)| 帮助 (H)   
------------------------------------------------------------------------------------------
建立好菜单,同时也明确了我们的任务。我们的主要任务是将菜单栏上每一个选项的功能逐一完善。那么我们的模仿秀基本就完成了。
   
万事皆从简单事情做起,编写软件更何况不是呢?我们从最简单的功能做起,一个一个将功能实现。
下面以提问的方式介绍。
   打开 Visual C++ ,新建 MFC APPWIZARD EXE 工程,工程名为 “Draw” ,在向导的第 1 “Step 1 of 6” ,选择单文档,在向导的第 4 “Step 4 of 6” ,将隐藏工具栏和打印和打印预览选项取消打勾。其它皆为缺省,点完成。
-------------------------------------------------------------------------------------------
帮助 (H)
 
帮助主题 (H)
 
关于画图 (A)
--------------------------------------------------------------------------------------------
1.
如何实现帮助主题?
   
在微软画图软件中,点击帮助下的帮助主题,将会弹出 一个后缀名为 chm 的文件,这个文件其实是在 window/help/mspaint.chm ,因为安装 Microsoft 公司的操作系统,一般都会自带画图软件,这样自然会自带 mspaint.chm 文件,这个文件要自己编写也可以,但是有现成的,我们只需要直接调用就行了。
   
帮助主题,其 ID 键名为 “IDH_THEMEHELP”   在建立类向导中,在 CDrawView 下建立 common 函数 --OnThemehelp()
其代码如下:
void CDrawView::OnThemehelp()
{
     // TODO: Add your command handler code here
     ::WinExec("HH mspaint.chm", SW_SHOW);
 
}
备注: WinExec() 函数介绍 (from MSDN)
    This function is provided for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function.
UINT WinExec(
  LPCSTR lpCmdLine,  //
调用应用程序地址
  UINT uCmdShow      //
新应用软件的窗口类型
);
   nCmdShow 特别介绍:
    Specifies how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides aSTARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values:

Value
Meaning
SW_FORCEMINIMIZE
Windows NT 5.0 and later: Minimizes a window, even if the thread that owns the window is hung. This flag should only be used when minimizing windows from a different thread.
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW
Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT
Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
SW_SHOWMAXIMIZED
Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED
Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE
Displays the window as a minimized window. The active window remains active.
SW_SHOWNA
Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE
Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL
Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.


2.
关于画图的实现?
       关于画图,其 ID 键名为 “ID_APP_ABOUT”   在建立类向导中,在 CDrawView 下建立 common 函数 --
OnAppAbout()
void CDrawView::OnAppAbout()
{
 // TODO: Add your command handler code here
 ShellAbout(this->m_hWnd, "
画图 ", "highness0520@gmail.com",NULL);
 
}
 未完待续...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值