「配枪朱丽叶。」

RootのCTF学习笔记。

C语言Windows图形界面学习(一)

1.新建工程Win32 Application
2.选择“一个简单的Win32程序”
3.转移到FileView区查看源代码:

// testwo.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// 在这里写下你的代码:
	return 0;
}

我们来编写一个最简单的弹窗:
·程序中TEXT能把中文转换成不会乱码的格式(暂时是这样)。
·使用到了MessageBox函数,第一个TEXT是正文内容,第二个TEXT是标题,MB是MessageBox的缩写。

MessageBox(NULL,TEXT("Hello,world!"),TEXT("This Is A Test"),MB_OK);


下面写一个有分支选项的弹窗:
·MessageBox返回的是用户点击的按钮,为IDYES等

你觉得小皮皮聪明吗?

是(Y)返回一个WARNING界面

否(N)返回一个RETRYCANCEL界面

// testwo.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	int ans = MessageBox(NULL,TEXT("你觉得小皮皮聪明吗?"),TEXT("QUESTION"),MB_YESNO|MB_ICONQUESTION);
	if (IDYES == ans)
	{
		MessageBox(NULL,TEXT("我也这么觉得!!!"),TEXT("Warning"),MB_OK|MB_ICONWARNING);
	}
	else
	{
		MessageBox(NULL,TEXT("哭哭,你确定吗?"),TEXT("Horrible"),MB_RETRYCANCEL);
	}
	return 0;
}