#include<stdio.h>
#include<stdlib.h>
#include<time.h>#include<minigui/common.h>
#include<minigui/minigui.h>
#include<minigui/gdi.h>
#include<minigui/window.h>
#include<minigui/control.h>HWND hMainWnd;
#define MWINDOW_LX 0
#define MWINDOW_TY 0
#define MWINDOW_RX 320
#define MWINDOW_BY 240
static int WinProc(HWND hWnd,int message,WPARAM wParam,LPARAM lParam)
{HDC hdc;
int x,y;
static int s_x0=10,s_y0=10;
static int s_x1=0,s_y1=0;
static BOOL s_erase=FALSE;
static BOOL s_draw=FALSE;
static int s_mycolor=0;
char str_color[50];
switch(message)
{case MSG_CREATE:
s_mycolor=random()%16;
sprintf(str_color,"SysPixelIndex[%d]",s_mycolor);
SetWindowCaption(hWnd,str_color);
break;
case MSG_LBUTTONDOWN:
s_x0=LOWORD(lParam);
s_y0=HIWORD(lParam);
SetCapture(hWnd);
s_draw=TRUE;
break;
case MSG_MOUSEMOVE:
x=LOWORD(lParam);
y=HIWORD(lParam);
ScreenToClient(hWnd,&x,&y);
hdc=GetClientDC(hWnd);
if(s_draw)
{SetPenColor(hdc,SysPixelIndex[s_mycolor]);
SetRasterOperation(hdc,ROP_XOR);
if(s_erase)
{MoveTo(hdc,s_x0,s_y0);
LineTo(hdc,s_x1,s_y1);
}
s_x1=x;
s_y1=y;
MoveTo(hdc,s_x0,s_y0);
LineTo(hdc,s_x1,s_y1);
s_erase=TRUE;
}
ReleaseDC(hdc);
break;
case MSG_LBUTTONUP:
s_erase=FALSE;
s_draw=FALSE;
ReleaseCapture();
break; case MSG_RBUTTONDOWN:
s_mycolor=random()%16;
sprintf(str_color,"SysPiexlIndex[%d]",s_mycolor);
SetWindowCaption(hWnd,str_color);
break; case MSG_CLOSE:
DestroyMainWindow(hWnd);
PostQuitMessage(hWnd);
break;
default:
return(DefaultMainWinProc(hWnd,message,wParam,lParam));
} return(0);
}//////////////////////////////////////////////////////////////////
int InitMainWindow(void)
{MAINWINCREATE window_info;
window_info.dwStyle=WS_VISIBLE|WS_BORDER|WS_CAPTION;
window_info.dwExStyle=WS_EX_IMECOMPOSE;
window_info.spCaption="Please use Mouse";
window_info.hMenu=0;
window_info.hCursor=GetSystemCursor(0);
window_info.hIcon=0;
window_info.MainWindowProc=WinProc;
window_info.lx=MWINDOW_LX;
window_info.ty=MWINDOW_TY;
window_info.rx=MWINDOW_RX;
window_info.by=MWINDOW_BY;
window_info.iBkColor=COLOR_lightwhite;
window_info.dwAddData=0;
window_info.hHosting=HWND_DESKTOP;
hMainWnd=CreateMainWindow(&window_info);
if(hMainWnd==HWND_INVALID) return(0);
else return(1);
}
////////////////////////////////////
int MiniGUIMain(int argc,const char *argv[])
{
MSG Msg;srand((unsigned)time(NULL));
InitMainWindow();
ShowWindow(hMainWnd,SW_SHOWNORMAL);while(GetMessage(&Msg,hMainWnd))
{TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainWindowThreadCleanup(hMainWnd);
return(0);
}
#include<minigui/dti.c>
minigui_code.rar_minigui
版权申诉
18 浏览量
2022-09-24
02:30:10
上传
评论
收藏 6KB RAR 举报
钱亚锋
- 粉丝: 86
- 资源: 1万+
最新资源
- sql-lap注入靶场
- 803916326552715醒图v9.7.0解锁会员版.apk
- 使用SpringBoot2.x 简单实现Java高并发之秒杀系统
- 基于python+opencv实现的手指静脉识别源码+数据集+项目说明毕业设计.zip
- Android AIDL基础-利用AIDL实现客户端向服务端传递Listener接口
- Android AIDL基础-利用AIDL实现客户端向服务端传递基本类型
- GHKQ-12.ass
- Android图像介绍-Bitmap常用操作
- 基于matlab实现的量化因子选股模型示例,包含数据读取、因子筛选、因子分类和回测部分.rar
- 基于matlab实现的粒子群算法,也称粒子群优化算法(Particle Swarm Optimization),.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈