屏幕画家






4.55/5 (11投票s)
用于在屏幕上绘画的应用程序。
概述
本文展示了如何使用命令行参数在屏幕上绘画。该应用程序是基于对话框的,具有透明属性,因此在屏幕上绘画实际上是在不可见(透明)的对话框上绘画。命令行参数为其他应用程序提供了将其用作组件的可能性。
类
该项目包含 5 个类
CCmdLineParser
- 命令行参数类CScreenPainterApp
- 应用程序类CScreenPainterDlg
- 对话框实现CStroke
- 从 Scribble 教程修改的类SShortcuts
- 快捷键的结构
命令行参数
命令行参数的实现基于 Pavel Antonov 的 CCmdLineParser
类。下面的代码展示了命令行参数的实现。
void CScreenPainterApp::CommandLine(CScreenPainterDlg *pWnd) { //Parsing the command parameters //First we check the security code if(parser.HasKey("sec")) { CString strSec=parser.GetVal("sec"); if(strSec!="123874981724sjdhflaksjdoaisdj20938448laskfj") { //string is wromg so there is no security code pWnd->SendMessage(WM_CLOSE); } } else { //ther is no security code pWnd->SendMessage(WM_CLOSE); } //No nedd for this parameter thue to Start Annotation when app starts if(parser.HasKey("start")) { pWnd->StartAnnotation(); } //Clear command if(parser.HasKey("clear")) { pWnd->ClearTheScreen(); } //Cursor if(parser.HasKey("cursor")) { CString strCursor=parser.GetVal("cursor"); pWnd->SetCursor(strCursor); } //Color of the pen if(parser.HasKey("color")) { CString col=parser.GetVal("color"); pWnd->SetColor(ParseColor(col)); } //Thinkness if(parser.HasKey("thinkness")) { CString think=parser.GetVal("thinkness"); pWnd->SetThinkness(atoi(think)); } //PenType if(parser.HasKey("pentype")) { CString pen=parser.GetVal("pentype"); pWnd->SetPenType(atoi(pen)); } //Exit App if(parser.HasKey("exit")) { pWnd->SendMessage(WM_CLOSE); } //option command for clear the screen if(parser.HasKey("Pclear")) { CString str=parser.GetVal("Pclear"); pWnd->m_sShotcuts.clear=str.GetAt(0); } //option command for exit app if(parser.HasKey("Pexit")) { CString str=parser.GetVal("Pexit"); pWnd->m_sShotcuts.exit=str.GetAt(0); } //option command for pen width if(parser.HasKey("Pincrw")) { CString str=parser.GetVal("Pincrw"); pWnd->m_sShotcuts.incrw=str.GetAt(0); } //option command for pen width if(parser.HasKey("decrq")) { CString str=parser.GetVal("Pdecrq"); pWnd->m_sShotcuts.decrq=str.GetAt(0); } //option command for blue color if(parser.HasKey("Pblue")) { CString str=parser.GetVal("Pblue"); pWnd->m_sShotcuts.blue=str.GetAt(0); } //option command for red color if(parser.HasKey("Pred")) { CString str=parser.GetVal("Pred"); pWnd->m_sShotcuts.red=str.GetAt(0); } //option command for green color if(parser.HasKey("Pgreen")) { CString str=parser.GetVal("Pgreen"); pWnd->m_sShotcuts.green=str.GetAt(0); } //option command for yellow color if(parser.HasKey("Pyellow")) { CString str=parser.GetVal("Pyellow"); pWnd->m_sShotcuts.yellow=str.GetAt(0); } //Start Annotation have to be the last action pWnd->StartAnnotation(); }
屏幕画笔参数
命令行参数具有如下标准格式
screenpainter.exe [Argument list]
[参数列表] 可以是以下之一
- sec:value
- clear
- start
- cursor:filename
- color: Red,Green,Blue
- thinkness:value
- pentype:pentype
- close
- Pclear:value
- Pexit:value
- Pincrw:value
- Pdecrq:value
- Pblue:value
- Pred:value
- Pgreen:value
- Pyellow:value
参数
- sec:value 参数。设置启动的安全代码。 启动应用程序时需要安全代码。 如果没有安全代码,则无法启动应用程序。
示例
screenpainter.exe –sec:SecurityCode
- clear 参数。 清除屏幕。 当您要清除屏幕内容时,请使用此参数。
示例
screenpainter.exe –clear
- start 参数。 此参数启动注释。
示例
screenpainter.exe –start
- cursor: filename 参数。 cursor 参数从文件名设置光标。 此参数具有一个值。 cursor 参数的值是*.cur 或 *.ani 文件名。 如果文件不在应用程序的根目录中,则必须指定完整路径名。
示例
screenpainter.exe –cursor:test.cur
或
screenpainter.exe –cursor :c:\test.cur
- color:red,green,blue 参数。 Color 参数设置笔的颜色。
示例
screenpainter.exe –color: 0,0,255
- thinkness:value 参数。 设置笔的宽度。
示例
screenpainter.exe –thinkness:2 - determines the pen width of 2 pixels.
- pentype:pentype 参数。 设置笔的类型。 有 7 种类型的笔
- pentype: 1 =
PS_SOLID
- 创建实心笔 - pentype: 2 =
PS_DASH
- 创建虚线笔。 仅当笔的宽度为 1 或更小(以设备单位表示)时有效。 - pentype: 3 =
PS_DOT
- 创建点状笔。 仅当笔的宽度为 1 或更小(以设备单位表示)时有效。 - pentype: 4 =
PS_DASHDOT
- 创建带有交替的短划线和点的笔。 仅当笔的宽度为 1 或更小(以设备单位表示)时有效。 - pentype: 5 =
PS_DASHDOTDOT
- 创建带有交替的短划线和双点的笔。 仅当笔的宽度为 1 或更小(以设备单位表示)时有效。 - pentype: 6 =
PS_NULL
- 创建空笔。 - pentype: 7 =
PS_INSIDEFRAME
- 创建在封闭形状的框架内绘制线条的笔。
示例
screenpainter.exe –pentype:2 - Set the pen type PS_DASH..
- pentype: 1 =
- close 参数。 关闭应用程序。
示例
screenpainter.exe –close
当然,当您启动应用程序时,可以使用上述参数的任意组合。
示例
screenpainter.exe -sec:SecurityCode -cursor:filename.cur -color:127,233,147 -thinkness:20 -pentype:2
或
screenpainter.exe –clear -close
等等……。
屏幕画笔选项
在绘图过程中,您可以使用一些选项命令。 您可以通过按相应的键盘键来触发任何选项命令。 以下命令可用
- x - 退出应用程序。
- c - 清除屏幕。
- w - 将笔的宽度增加一个像素。
- q - 将笔的宽度减少一个像素。
- b - 将笔的当前颜色更改为蓝色。
- r - 将笔的当前颜色更改为红色。
- g - 将笔的当前颜色更改为绿色。
- y - 将笔的当前颜色更改为黄色。
所有选项都可以在您在屏幕上绘图时使用。 选项命令的快捷方式是预定义的,可以通过命令行参数进行修改。
Pclear:value 参数将清除的默认快捷键 ‘c’ 更改为 ‘value’ 键。
示例
screenpainter.exe –Pclear:z -after executing this parameter,
default key for clear is cahanged in to ‘z’.
Pexit:value 参数将清除的默认快捷键 ‘x’ 更改为 ‘value’ 键。