代码
#include <windows.h>
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ) ; //声明用来处理消息的函数
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
static TCHAR szAppName[] = TEXT("MyWindow") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; //声明一个窗口类对象
//以下为窗口类对象wndclass的属性
wndclass.style = CS_HREDRAW | CS_VREDRAW ; //窗口样式
wndclass.lpszClassName = szAppName ; //窗口类名
wndclass.lpszMenuName = NULL ; //窗口菜单:无
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ; //窗口背景颜色
wndclass.lpfnWndProc = WndProc ; //窗口处理函数
wndclass.cbWndExtra = 0 ; //窗口实例扩展:无
wndclass.cbClsExtra = 0 ; //窗口类扩展:无
wndclass.hInstance = hInstance ; //窗口实例句柄
wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION ) ; //窗口最小化图标:使用缺省图标
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ) ; //窗口采用箭头光标
if( !RegisterClass( &wndclass ) )
{ //注册窗口类, 如果注册失败弹出错误提示
MessageBox( NULL, TEXT("窗口注册失败!"), TEXT("错误"), MB_OK | MB_ICONERROR ) ;
return 0 ;
}
hwnd = CreateWindow( //创建窗口
szAppName, //窗口类名
TEXT("我的窗口"), //窗口标题
WS_OVERLAPPEDWINDOW, //窗口的风格
CW_USEDEFAULT, //窗口初始显示位置x:使用缺省值
CW_USEDEFAULT, //窗口初始显示位置y:使用缺省值
CW_USEDEFAULT, //窗口的宽度:使用缺省值
CW_USEDEFAULT, //窗口的高度:使用缺省值
NULL, //父窗口:无
NULL, //子菜单:无
hInstance, //该窗口应用程序的实例句柄
NULL //
) ;
ShowWindow( hwnd, iCmdShow ) ; //显示窗口
UpdateWindow( hwnd ) ; //更新窗口
while( GetMessage( &msg, NULL, 0, 0 ) ) //从消息队列中获取消息
{
TranslateMessage( &msg ) ; //将虚拟键消息转换为字符消息
DispatchMessage( &msg ) ; //分发到回调函数(过程函数)
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
HDC hdc ; //设备环境句柄
PAINTSTRUCT ps ; //绘制结构
RECT rect; //矩形结构
switch( message ) //处理得到的消息
{
case WM_CREATE: //窗口创建完成时发来的消息
MessageBox( hwnd, TEXT("窗口已创建完成!"), TEXT("我的窗口"), MB_OK | MB_ICONINFORMATION ) ;
return 0;
case WM_PAINT: //处理窗口区域无效时发来的消息
hdc = BeginPaint( hwnd, &ps ) ;
GetClientRect( hwnd, &rect ) ;
DrawText( hdc, TEXT( "Hello, 卫班科技!" ), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER ) ;
EndPaint( hwnd, &ps ) ;
return 0 ;
case WM_LBUTTONDOWN: //处理鼠标左键被按下的消息
MessageBox( hwnd, TEXT("鼠标左键被按下。"), TEXT("单击"), MB_OK | MB_ICONINFORMATION ) ;
return 0;
case WM_DESTROY: //处理窗口关闭时的消息
MessageBox( hwnd, TEXT("关闭程序!"), TEXT("结束"), MB_OK | MB_ICONINFORMATION ) ;
PostQuitMessage( 0 ) ;
return 0;
}
return DefWindowProc( hwnd, message, wParam, lParam ) ; //DefWindowProc处理我们自定义的消息处理函数没有处理到的消息
}
加qq 慢慢请教 2469194208 谢了
追答抱歉噢,画图板是要很专业的水平的,我对此只算个门外汉........
就一个画图板 要用windows函数吗
追答#include
#include
#include
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define UP 0x4800
#define DOWN 0x5000
#define COL 0x2c7a/*z改变色彩*/
#define FIG 0x2d78/*x改变图形*/
#define HOLD 0x1e61/*A握笔提笔*/
#define SPACE 0x3920/*移动速度*/
#define ENTER 0x1c0d/*像cad一样输入命令画图,未完成*/
#define ESC 0x011b/*退出*/
#define LOAD 0x266c/*load存档*/
#define CHANG 57.2957795
/*tc2.0编译*//*c语言画图板*//*能画线、圆、弧、斜椭圆*/
void *pen,*cross;
int x=320,y=210,s[5]={1,2,3,4,5},i,fig=1,col=1,com,m,step,key,ch;
char *textstring="Save or not?y/n";
char *fig1="pixel";
char *fig2="line";
char *fig3="circle";
char *fig4="arc";
char *fig5="ellipse";
char *col0="ERASE";
char *col1="BLUE";
char *col2="GREEN";
char *col3="CYAN";
char *col4="RED";
char *col5="MAGENTA";
char *col6="BROWN";
char *col7="LIGHTGRAY";
char *col8="DARKGRAY";
char *col9="LIGHTBLUE";
char *col10="LIGHTGREEN";
char *col11="LIGHTCYAN";
char *col12="LIGHTRED";
char *col13="LIGHTMAGENTA";
char *col14="YELLOW";
char *col15="WHITE";
struct col
{int sav;
};
typedef struct dpcol
{
char *dpcol;
struct dpcol *next1;
}*chead,*dc;
typedef struct dpfig
{
char *dpfig;
struct dpcol *next2;
}*fhead,*df;
void assign()
{
}
void init()
{
int gd=VGA,gm=VGAHI;
initgraph(&gd,&gm,"");
cleardevice();
}
void info()
{}
void help()
{}
void curs()
{
int points[12]={320,240,330,235,350,215,345,210,325,230,320,240};
/*moveto(320,240);*/
/*setcolor;*/
/*setlinestyle;*/
drawpoly(6,points);
pen=malloc(imagesize(320,210,350,240));
getimage(320,210,350,240,pen);
setlinestyle(0,0,3);
line(10,50,40,50);
line(25,35,25,65);
cross=malloc(imagesize(10,35,40,65));
getimage(10,35,40,65,cross);
cleardevice();
}