``
```
// Win32Project1light18digui181008d.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include "Win32Project1light18digui181008d.h"
using namespace std;
#define PI18 3141592653589793238
#define PId 3.141592653589793238
#define MAX_LOADSTRING 100
// 全局变量:
long long diguiAllTimes1 = 0;
int C1s_rightTimes = 0;
int C2s_leftTimes = 0;
//HDC hdc;
HINSTANCE hInst; // 当前实例
TCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
TCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
// 此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: 在此放置代码。
//调用Console控制台
AllocConsole();
#pragma warning(disable:4996)
_tfreopen(TEXT("CONOUT$"), TEXT("w"), stdout);
_tfreopen(TEXT("CONOUT$"), TEXT("w"), stderr);
_tfreopen(TEXT("CONIN$"), TEXT("r"), stdin);
#pragma warning(default:4996)
_tsetlocale(LC_ALL, TEXT("chs"));
std::cout << PId << std::endl;
cout << PI18 << endl;
MSG msg;
HACCEL hAccelTable;
// 初始化全局字符串
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WIN32PROJECT1LIGHT18DIGUI181008D, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32PROJECT1LIGHT18DIGUI181008D));
// 主消息循环:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// 函数: MyRegisterClass()
//
// 目的: 注册窗口类。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32PROJECT1LIGHT18DIGUI181008D));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_WIN32PROJECT1LIGHT18DIGUI181008D);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// 函数: InitInstance(HINSTANCE, int)
//
// 目的: 保存实例句柄并创建主窗口
//
// 注释:
//
// 在此函数中,我们在全局变量中保存实例句柄并
// 创建和显示主程序窗口。
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // 将实例句柄存储在全局变量中
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
//
COLORREF getColor1RGB1(int i) {
if (0 == i) return (9, 9, 9); //黑灰
if (1 == i) return (0, 0, 200); //蓝
if (2 == i) return (0, 180, 0); //绿
if (3 == i) return (160, 0, 0); //红
if (4 == i) return (200, 0, 200); //品紫
if (5 == i) return (0, 255, 0); //亮绿
if (6 == i) return (0, 255, 255); //亮青
if (7 == i) return (255, 255, 0); //黄
// if(i>=7)
return (255, 200, 200);//灰白
}
//
////digui01andDrawlight 参数 : 01hdc, 2:tt光线总长,3:入射角度(角度非弧度), 4(当前)光线入口x坐标x01;5当前光线入口Y坐标Y01;
//digui01andDrawlight(hdc, tt, 125, 190, 200);
////int digui01DrawLine01light(HDC hdc, long long tt, int rsjiaodu, int x01, int y01)
int digui01DrawLine01light(HDC hdc , int whichCircle, long long tt, double rsHu01du01, int rsjiaodu, int x01, int y01) //int digui01DrawLine01light( long long tt, int rsjiaodu, int x01, int y01)
{//int digui01andDrawlight112110
diguiAllTimes1++;
printf_s("dgTimes:%lld", diguiAllTimes1);
// cout << "diguiAllTimes1:" << diguiAllTimes1 << endl;
// printf_s("run112110Here!");
// cout << "run112110Here!" << endl;
if (tt <= 1) { cout << "[tt=1?" << tt << "]"<<endl; return 1; }
// double rsHudu01 = ((double)rsjiaodu * 1000.0 / 180.0 / 1000.0 / 10000.0) * PI18 / 10000000000000;// 0;
double rsHudu01 = (double)rsjiaodu *PId / 180;
cout << "入射角1度:" << rsjiaodu;// << endl;
rsHudu01 = (double)rsjiaodu*3.1415926 / 180.0;
printf_s("_rsHu01du01:=%f", rsHu01du01);
cout << endl;
// cout << "rsHudu01:=" << rsHudu01 << endl;
long lightDuanlen01 = 0;//当前光线 线段长度
//
for (long long ii = 0; ii < tt; ++ii) {//for1110
++lightDuanlen01;
double danweiX01 = cos(rsHu01du01);
double danweiY01 = sin(rsHu01du01);
double yuanShiX001 = (double)danweiX01*lightDuanlen01;
double yuanShiY001 = danweiY01*lightDuanlen01;
//
int zhenShiX0001 = (double)yuanShiX001 + x01;
int zhenShiY0001 = (double)yuanShiY001 + y01;
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, RGB(0, 0, 200)); //亮蓝
//判断:
int C1s_rightTimes = 0;
int C2s_leftTimes = 0;
//判断真实点的轴距
//判断 是否 撞过 C1 圆1:
if (/*1*/ 1==whichCircle && zhenShiX0001 >= 200 /*1*/) {//if11a10
long long tt1new01 = tt - ii;
double faXian1Hudu01 = PId; //法线初始值弧度为PI=π
double rsNewHudu01 = faXian1Hudu01 + (2*PId- rsHu01du01) ;// PId;//
//faXian1Hudu01 - rsOld00Hu1du01; //double rsNewHudu01 = faXian1Hudu01 + rsOld00Hu1du01;
int rsNewJiao1du = ceil(rsNewHudu01 * 180 / PId);
// double little_a_hudu= asin( )
// if (rsNewJiao1du < 0) rsNewJiao1du += 360;
// if (rsNewJiao1du > 360) rsNewJiao1du -= 360;
lightDuanlen01 = 1;
if (diguiAllTimes1 < 1900) {//if diguiAllTimes1 < 1900
//判断是否和第一个圆相撞,则切换到 第2号圆////切换 去第 1号圆的判断(和Draw
digui01DrawLine01light( hdc,2, (long long)tt1new01, rsNewHudu01, rsNewJiao1du, zhenShiX0001, zhenShiY0001); //digui01DrawLine01light(hdc, tt1new01, rsNewJiao1du, zhenShiX0001, zhenShiY0001);
}//if diguiAllTimes1 < 1950//3000//1900
else {
return 2;
}
}//if11a10
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, RGB(0, 200, 0)); //亮绿
//判断 是否 撞过 C2 圆2:
if (/*1*/ 2==whichCircle && zhenShiX0001 <=100 /*1*/) {//if11a10
long long tt1new01 = tt - ii;
double faXian1Hudu01 = 0; // (double)-PId; //法线弧度为PI=π
double rsOld00Hu1du01 = (double)PId*rsjiaodu / 180; //旧入射角度转弧度
double rsNewHudu01 = (double)faXian1Hudu01 +(PId- rsHu01du01);// -rsOld00Hu1du01;
int rsNewJiao1du = 0;//faXian1Hudu01;//废弃
//ceil( (double)150 * PId / 180); ////rsNewHudu01 * 180 / PId;
// if (rsNewJiao1du < 0) rsNewJiao1du += 360;
// if (rsNewJiao1du > 360) rsNewJiao1du -= 360;
lightDuanlen01 = 1;
if (diguiAllTimes1 < 1900) {//if diguiAllTimes1 < 1900
lightDuanlen01 = 1;
//切去第 1号圆的判断(和Draw
cout << "[22:rsNewHudu01" << rsNewHudu01 <<"]"<< endl;
//rsNewJiao1du废弃
digui01DrawLine01light( hdc, 1, tt1new01, rsNewHudu01, rsNewJiao1du, zhenShiX0001, zhenShiY0001); //digui01DrawLine01light(hdc, tt1new01, rsNewJiao1du, zhenShiX0001, zhenShiY0001);
}//if diguiAllTimes1 < 1950
}//if11a10
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, getColor1RGB1(diguiAllTimes1%8 )); //RGB(200, 0, 0)); //亮红
}//for1110
//
return 1;
}//int digui01DrawLine01light
//
//
//规整化角(弧度)
double getHudu1bound180rad01(double rad01) //规整为180度以内的角
{
double tmpr = rad01 * 180 / PId;
int itmpr = (int)tmpr % 180;
tmpr = itmpr * PId / 180;
return tmpr;
}
//
double getHudu1bound90rad01(double rad01) //规整为180度以内的角
{
double tmpr = rad01 * 90 / (PId/2);
int itmpr = (int)tmpr % 90;
tmpr = itmpr * PId / 90;
return tmpr;
}
//
//
double getRs1Hudu_andFaxianJiajiao(double faXian1Hudu01, double rsHu01du01) {
double deltaHD = (rsHu01du01 - faXian1Hudu01);
if (0 < (deltaHD) && deltaHD<(PId / 2) ) return deltaHD;
if (0 < (-deltaHD) && (-deltaHD)<(PId / 2) ) return (-deltaHD);
}
////digui01Draw02Circle02light 参数 : 01hdc, 2:tt光线总长,3:入射弧度(非角度), 4(当前)光线入口x坐标x01;5当前光线入口Y坐标Y01;
//digui01andDrawlight(hdc, tt, 125, 190, 200);
////int digui01DrawLine01light(HDC hdc, long long tt, int rsjiaodu, int x01, int y01)
int digui01Draw02Circle02light(HDC hdc, int whichCircle, long long tt, double rsHu01du01, int x01, int y01) //int digui01Draw02Circle02light(HDC hdc, int whichCircle, long long tt, double rsHu01du01, int rsjiaodu, int x01, int y01)
{//int digui01andDrawlight112110
diguiAllTimes1++;
printf_s("dgTimes:%lld", diguiAllTimes1);
// cout << "diguiAllTimes1:" << diguiAllTimes1 << endl;
// printf_s("run112110Here!");
// cout << "run112110Here!" << endl;
if (tt <= 1) { cout << "[tt=1?" << tt << "]" << endl; return 1; }
// double rsHudu01 = ((double)rsjiaodu * 1000.0 / 180.0 / 1000.0 / 10000.0) * PI18 / 10000000000000;// 0;
// double rsHudu01 = (double)rsjiaodu *PId / 180; //角度废弃
cout << "入射01弧度:" << rsHu01du01;// << endl;
cout << "{入射01角度度:" << rsHu01du01*180/PId<<"}"<<endl;
// rsHudu01 = (double)rsjiaodu*3.1415926 / 180.0;
printf_s("_rsHu01du01:=%f", rsHu01du01);
cout << endl;
// cout << "rsHudu01:=" << rsHudu01 << endl;
long lightDuanlen01 = 0;//当前光线 线段长度
//
for (long long ii = 0; ii < tt; ++ii) {//for1110
++lightDuanlen01;
double danweiX01 = cos(rsHu01du01);
double danweiY01 = sin(rsHu01du01);
double yuanShiX001 = (double)lightDuanlen01*danweiX01;
double yuanShiY001 = (double)lightDuanlen01*danweiY01;
//
int zhenShiX0001 = (double)yuanShiX001 + x01;
int zhenShiY0001 = (double)yuanShiY001 + y01;
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, RGB(0, 0, 200)); //亮蓝
//判断:
// int C1s_rightTimes = 0;
// int C2s_leftTimes = 0;
//判断真实点的轴距
//判断 是否 撞过 C1 圆1:
//真实轴距离
long long zhenshiZhouJvliToC1XY01 = zhenShiX0001 * zhenShiX0001 + (zhenShiY0001-200) * (zhenShiY0001-200);
//zhenShiX0001>=200 一定跑出了 圆1,所以是废话(多重保险……
////注意这里是撞 左侧大圆(1号圆)的右侧弧!
if /*1*/ ( (/*2*/ 1==whichCircle/*2*/) && (/*2*/ (/*3*/zhenshiZhouJvliToC1XY01>= 200*200 /*3*/) || ( zhenShiX0001 >= 200 ) /*2*/) )/*1*/ //if (/*1*/ 1 == whichCircle && zhenShiX0001 >= 200 /*1*/)
{//if11a10
++C1s_rightTimes;
cout << "C1s_rightTimes:" << C1s_rightTimes << endl;
long long tt1new01 = tt - ii;
//算法线:
double faXian1Hudu01 = PId;// -0.1; //法线弧度初始设置为PI=π3.1415926...
// faXian1Hudu01 = atan((double)zhenShiY0001-200) / (zhenShiX0001 );
faXian1Hudu01 = PId + asin((double)(zhenShiY0001 - 200) / (200)); //OK1
cout << "[撞圆1的法线角(弧度:" << faXian1Hudu01 << "]";
double little_b = getHudu1bound90rad01(rsHu01du01);
double little_cita = 1.0* PId / 2 - getHudu1bound90rad01(faXian1Hudu01) - little_b;
cout << "[撞圆1的法线角(角度度:" << faXian1Hudu01*180/PId << "]";
//暂时令法线等于PId,0
// faXian1Hudu01= PId+ asin((double)(zhenShiY0001 - 200) / (200)); //OK1
double rsNewHudu01 = faXian1Hudu01 +little_cita ; //faXian1Hudu01;
if ((-1.0*PId / 2) < rsNewHudu01 && rsNewHudu01<0 ) rsNewHudu01 = PId - rsNewHudu01;
if ((PId ) < rsNewHudu01 && rsNewHudu01 < PId*2) rsNewHudu01 = rsNewHudu01-PId;
//PId - faXian1Hudu01;
//PId-faXian1Hudu01;//这是 正确方向的法线 向量;
//BigA2 - rsHuDu_BuJiao + 3.0/2*PId;
//(PId+faXian1Hudu01)-3.0/4*Pid; // littleCeta;
//3.0/4*PId+2*faXian1Hudu01 - rsHu01du01;
// double rsNewHudu01 = faXian1Hudu01 + PId; //faXian1Hudu01; // PId - faXian1Hudu01;
//注意这里是撞 左侧大圆(1号圆)的右侧弧!
// int rsNewJiao1du = ceil(rsNewHudu01 * 180 / PId);
// if (rsNewJiao1du < 0) rsNewJiao1du += 360;
// if (rsNewJiao1du > 360) rsNewJiao1du -= 360;
lightDuanlen01 = 1;
if (diguiAllTimes1 < 1900) {//if diguiAllTimes1 < 1900
//判断是否和第一个圆相撞,则切换到 第2号圆////切换 去第 1号圆的判断(和Draw
digui01Draw02Circle02light(hdc, 2, (long long)tt1new01, rsNewHudu01, zhenShiX0001, zhenShiY0001); //digui01DrawLine01light(hdc, tt1new01, rsNewJiao1du, zhenShiX0001, zhenShiY0001);
}//if diguiAllTimes1 < 1950//3000//1900
else {
return 2;
}
if (C1s_rightTimes > 2) return 1;
system("pause");
}//if11a10
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, RGB(0, 200, 0)); //亮绿
//判断 是否 撞过 C2 圆2:
//真实轴距离
//2号圆的左侧弧:
long long zhenshiZhouJvliToC2xy02 = (300-zhenShiX0001) * (300-zhenShiX0001) + (zhenShiY0001-200) * (zhenShiY0001-200);
if /*1*/ ( (/*2*/2 == whichCircle/*2*/) && (/*2*/ (/*3*/zhenshiZhouJvliToC2xy02 >= 200 * 200 /*3*/) || ( zhenShiX0001 <= 100 ) /*2*/) )/*1*/ {//if11a10 //if (/*1*/ 2 == whichCircle && zhenShiX0001 <= 100 /*1*/) {//if11a10
++C2s_leftTimes;
cout << "C2s_leftTimes:" << C2s_leftTimes << endl;
long long tt1new01 = tt - ii;
//算法线:
double faXian1Hudu01 = 0; // (double)-PId; //初始法线弧度为0!法线弧度为
// faXian1Hudu01 = atan((double)zhenShiY0001-200.0) / (300.0-zhenShiX0001 );
faXian1Hudu01 = asin( ((double)zhenShiY0001 - 200.0) / 200 );
cout << "圆2号左侧faXian1Hudu01:" << faXian1Hudu01 << endl;
// double rsNewHudu01 = -(double)faXian1Hudu01;// -rsHu01du01 + PId;
// double rsNewHudu01 = -(double)faXian1Hudu01;// +(PId - rsHu01du01); // -rsHu01du01 + PId;
cout << "撞圆2时的入射角弧度:" << rsHu01du01<<endl;
double rsNewHudu01 = -(double)faXian1Hudu01;// +getRs1Hudu_andFaxianJiajiao(faXian1Hudu01, rsHu01du01);
// double rsNewHudu01 = PId-(rsHu01du01 -2 * faXian1Hudu01);
rsNewHudu01 = -( faXian1Hudu01 - (PId - rsHu01du01 - faXian1Hudu01)); //OK了
//;// +getHudu1bound180rad01(rsHu01du01) - faXian1Hudu01;//;;// -getHudu1bound180rad01(rsHu01du01);// +(PId - rsHu01du01); // -rsHu01du01 + PId;
int rsNewJiao1du = 0;//faXian1Hudu01;//废弃
//ceil( (double)150 * PId / 180); ////rsNewHudu01 * 180 / PId;
// if (rsNewJiao1du < 0) rsNewJiao1du += 360;
// if (rsNewJiao1du > 360) rsNewJiao1du -= 360;
lightDuanlen01 = 1;
if (diguiAllTimes1 < 1900) {//if diguiAllTimes1 < 1900
lightDuanlen01 = 1;
//切去第 1号圆的判断(和Draw
cout << "[22:rsNewHudu01" << rsNewHudu01 << "]" << endl;
//rsNewJiao1du废弃
digui01Draw02Circle02light(hdc, 1, tt1new01, rsNewHudu01, zhenShiX0001, zhenShiY0001); //digui01DrawLine01light(hdc, 1, tt1new01, rsNewHudu01, rsNewJiao1du, zhenShiX0001, zhenShiY0001);
}//if diguiAllTimes1 < 1950
if (C2s_leftTimes > 2) return 1;
system("pause");
}//if11a10
//根据真实 实际坐标,描点成线--…
SetPixel(hdc, zhenShiX0001, zhenShiY0001, getColor1RGB1(diguiAllTimes1 % 7)); //RGB(200, 0, 0)); //亮红
}//for1110
//
return 1;
}//int digui01Draw02Circle02light
//
//
int wm01paint01(HWND hWnd, PAINTSTRUCT ps, HDC hdc ) { //int wm01paint01(HWND hWnd, PAINTSTRUCT ps, HDC hdc) {
int c1_200_r01 = 200;
int c2_20b0_r02 = 200;
int c1XpianyiX = 0; //左圆用初始值-(圆心的偏移量为0
int c1YpianyiY = 200;//向下偏移200
int c2XpianyiX = 300;
int c2YpianyiY = 200;
int tt1chushi_R01 = 200;
int C1_R01 = 200;
int C2_R02 = 200;
//c1i01为角度变化,弧度需要计算 *π/180
MoveToEx(hdc, 100, 0, NULL); LineTo(hdc, 100, 400);
MoveToEx(hdc, 200, 0, NULL); LineTo(hdc, 200, 400);
//初始先画两圆:
//
for (int i1 = 0; i1 < 361; ++i1) {//for11100
double c1_hu01du01 = i1 * PId / 180;
int c1_x001 = C1_R01* cos(c1_hu01du01);
int c1_y001 = C1_R01*sin(c1_hu01du01);
SetPixel(hdc,c1_x001, c1_y001+ c1YpianyiY, RGB(0, 0, 200));//蓝色
}//for11100
//
//
for (int i2 = 0; i2 < 361; ++i2) {//for11120
double c2_hu01du01 = i2 * PId / 180;
int c2_x001 = C2_R02 * cos(c2_hu01du01);
int c2_y001 = C2_R02 * sin(c2_hu01du01);
SetPixel(hdc, c2_x001+ c2XpianyiX, c2_y001 + c2YpianyiY, RGB(0, 0, 200));//蓝色
}//for11120
//
//根据 时间 tt 描点成线-start
int light1R001 = 0;// 210;//发射光的初始半径 应大于200
int light1new01R001 = light1R001;
int ChuShi1RuSheJiao01jiaoDu = 165;// -10;// 180;// 45;// 0;// 130;// 100;////135 - 10;
double ruShejiao1Hu1du01 = ((double)0.1 * 100 * ChuShi1RuSheJiao01jiaoDu / 10000 * PI18 / 180 / 1000000000000000);//除 10^18
cout << "ruShejiao1Hu1du01 " << ruShejiao1Hu1du01 << endl;
int chushi1x001 = 190;// 200;// 0;// 190;
int chushi1y001 = 200;// 0;// 200;
//参数1:光线长度:光线长度!
long long tt = 1290;// 1190;// 911190;// 1190;// 190;// 390;// 590;
//digui01andDrawlight 参数 : 01hdc, 2:tt光线总长,3:入射弧度,4入射角度(废弃...角度非弧度), 5(当前)光线入口x坐标x01;6当前光线入口Y坐标Y01;
//初始撞向第2号圆 的 x==150左侧的内壁
//125度= 125/180*PId;
// digui01DrawLine01light( hdc, 2,tt, (165*PId/180), 125, 190, 200 ); //digui01DrawLine01light(hdc, tt, 125, 190, 200);
//
//digui01Draw02Circle02light参数 : 01hdc, 2:tt光线总长,3:入射弧度,4(当前)光线入口x坐标x01;5当前光线入口Y坐标Y01;
//参数2:入射角度: 等参数
digui01Draw02Circle02light(hdc, 1, tt, ( (1.0/4)* PId ), 160, 200); //digui01DrawLine01light(hdc, tt, 125, 190, 200);
//
return 1;
}//int wm01paint01
// 函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// 目的: 处理主窗口的消息。
//
// WM_COMMAND - 处理应用程序菜单
// WM_PAINT - 绘制主窗口
// WM_DESTROY - 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
{//case110
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
wm01paint01(hWnd, ps ,hdc); //wm01paint01(hWnd, ps, hdc);
EndPaint(hWnd, &ps);
}//case110//case WM_PAINT
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// “关于”框的消息处理程序。
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
```
![](https://box.kancloud.cn/c934b8a0d6a290478b9b79f5d024d1fe_607x514.jpg)
![](https://box.kancloud.cn/fe9dc4e44de33ed33462a99c07bc82b8_502x501.png)
如图的结果……
粒子碰撞圆1号的 右侧弧……还有点问题,需要调整……
- R高精“密率”-PI的分数的高精度表示形式-R语言181000a
- 高精“密率”-PI的分数的高精度表示形式181001
- java40k2011Terryfix181002
- PI的高精度分数表示形式180101
- c++算PI的分数表示形式180102
- 单圆弧的反射181001a
- 单个圆的圆弧反射181020a
- 附录11:181001非控制台(WindowsForm)窗口程序创建控制台(调试程序用
- 递归调用-判断两圆相碰撞情况181020
- 用递归算法模拟两圆反射Billiards181020
- 光线(粒子)在两圆间碰撞效果1810a
- 光线粒子在两圆内壁碰撞效果1810B
- twoBillards模拟光线(粒子)在重叠的两圆内壁的碰撞C++完整代码(带注释)Terry181001