c语言实现窗口中物品拖动模块.doc
文本预览下载声明
/*模块绘制
*时间:2010-10-19 8:12:28
*功能:实现了模块的拖动,产品
*作者:姚庆良
*完成时间:2010年10月21日12:21:05
*/
#includestdio.h
#includegraphics.h
#includedos.h
#include bios.h
#includemalloc.h
#includestdlib.h
#define R 15
/*图形初始化模块*/
void init_graph()
{
int gdriver = DETECT, gmode, errorcode;
registerbgidriver(EGAVGA_driver);
initgraph(gdriver, gmode, );
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf(Graphics error: %s\n, grapherrormsg(errorcode));
system(pause);
exit(1);
}
}
/*鼠标初始化*/
void init_mouse()
{
union REGS reg;
reg.x.ax=0x01;
int86(0x33,reg,reg);
}
/*鼠标信息的取得*/
void get_mouse(int *x,int *y,int *key)
{
union REGS inreg,outreg;
inreg.x.ax=3;
int86(0x33,inreg,outreg);
*x=outreg.x.cx;
*y=outreg.x.dx;
*key=outreg.x.bx;
}
/*定义结构*/
typedef struct _msg
{
/*l为新 左*/
int l_x;
int l_y;
/*r为旧 右*/
int r_x;
int r_y;
int judge;
}msg;
/*鼠标的绘制*/
void draw_mouse(msg *s)
{
int *pmouse;
pmouse=(int *)malloc(imagesize(s-l_x,s-l_y,s-l_x+R,s-l_y+R));
getimage(s-l_x,s-l_y,s-l_x+R,s-l_y+R,pmouse);
/*上次出现的异地同颜色,问题出在这里,已经修改*/
s-r_x=s-l_x;
s-r_y=s-l_y;
while(1!=s-judge)
{
/*悲剧,第一次写成get_mouse(s-l_x,s-l_y,s-judge);*/
get_mouse(s-l_x,s-l_y,s-judge);
/*此处标记的原因是:能够抓屏成功 此处可以修改,对于malloc与getimage2个*/
if(s-l_x=getmaxx()-R)
{
s-l_x=getmaxx()-R;
}
if(s-l_y=getmaxy()-R)
{
s-l_y=getmaxy()-R;
}
if((s-l_x!=s-r_x)||(s-l_y!=s-r_y))
{
putimage(s-r_x,s-r_y,pmouse,0);
getimage(s-l_x,s-l_y,s-l_x+R,s-l_y+R,pmouse);
setcolor(GREEN);
setlinestyle(0,0,1);
line(s-l_x,s-l_y,s-l_x+R,s-l_y+R/2);
line(s-l_x,s-l_y,s-l_x+R/2,s-l_y+R);
line(s-l_x+R,s-l_y+R/2,s-l_x+R/2,s-l_y+R);
line(s-l_x+R*3/4,s-l_y+R*3/4,s-l_x+R,s-l_y+R);
显示全部