| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 519 人关注过本帖
标题:用tc3.0编写图形程序关于编写鼠标程序的疑惑
只看楼主 加入收藏
不忘
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-18
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:4 
用tc3.0编写图形程序关于编写鼠标程序的疑惑

我们需要用tc编一个几千行的程序。现在遇到了一点麻烦:就是到图形界面后,虽然编了鼠标的程序,也是借鉴的,但是标在dos环境下的图形界面,就没用了。而且tc3.0也是支持鼠标操作的,不用在程序中写驱动了吧!但为什么就是不能实现鼠标在图形界面的移动等比较简单的动作呢?
搜索更多相关主题的帖子: 鼠标 
2012-07-18 18:38
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1933
专家分:3012
注 册:2009-12-22
收藏
得分:10 
你要最后加上一句 getch() ,程序才能在屏幕上停留。我用的WIN—TC就要加这句。

[ 本帖最后由 yuma 于 2012-7-18 21:59 编辑 ]

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2012-07-18 19:08
不忘
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-18
收藏
得分:0 
不行呀!下面是源代码:

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<graphics.h>
union REGS regs;
void cursor(int x,int y)  ;
int init(int xmi,int xma,int ymi,int yma);
void newxy(int *mx,int *my,int *mbutt);
int read(int *mx,int *my,int *mbutt)  ;
int xmin,xmax,ymin,ymax,x_max=639,y_max=479;
main()
{
    int buttons,xm,ym,x0,y0,x,y;
    char str[100];
    int gdriver=DETECT,gmode;
    initgraph(&gdriver,&gmode,"c:\\tc30\\bgi");
    clrscr();
    rectangle(0,0,x_max,y_max);
    setfillstyle(SOLID_FILL,BLUE);
    bar(1,1,x_max-1,y_max-1);
    outtextxy(3,15,"move mouse using any button.");
    outtextxy(285,15,"quit");
    xmin=2;
    xmax=x_max-1;
    ymin=8;
    ymax=y_max-2;
    setwritemode(XOR_PUT);
    if(init(xmin,xmax,ymin,ymax)==0) {
        printf("mouse or mouse driver absent ,please install!");
        delay(5000);
        exit(1);
    }
    x=320;
    y=240;
    cursor(x,y);(在这一步之后,转到DOS的图形界面后,图形中会有一个十字形,就是鼠标的形状,但是和鼠标的移动没有建立联系,是不是要在弄一个鼠标驱动程序?
    for(;;)  {
        newxy(&x,&y,&buttons);
        if(x>=280&&x<330&&y>12&&y<33&&buttons) {
            cleardevice();
            exit(1);
        }
    }
}
void cursor(int x,int y)
{
    int x1,x2,y1,y2;
    x1=x-4;
    x2=x+4;
    y1=y-3;
    y2=y+3;
    line(x1,y,x2,y) ;
    line(x,y1,x,y2);
}

int init(int xmi,int xma,int ymi,int yma)
{
    int retcode;
    regs.x.ax=0;
    int86(51,&regs,&regs);
    retcode=regs.x.ax;
    if(retcode==0)
        return 0;
    regs.x.ax=7;
    regs.x.cx=xmi;
    regs.x.dx=xma;
    int86(51,&regs,&regs);
    regs.x.ax=8;
    regs.x.cx=ymi;
    regs.x.dx=yma;
    int86(51,&regs,&regs);
    return retcode;
}

int read(int *mx,int *my,int *mbutt)
{
    int xx0=*mx,yy0=*my,but0=0,mb;
    int xnew,ynew;
    do{
        regs.x.ax=3;
        int86(51,&regs,&regs);
        xnew=regs.x.cx;
        ynew=regs.x.dx;
        *mbutt=regs.x.bx;

    }   while(xnew=xx0 && ynew==yy0 && *mbutt==but0 ) ;
    *mx=xnew;
    *my=ynew;
    mb=(*mbutt);
    if(mb)
    {
        if(mb==1)
        return 1;
        if(mb==2)
        return 2;

        return 3;
    }
    else
    return 0;
}

void newxy(int *mx,int *my,int *mbutt)
{
    int ch,xx0=*mx,yy0=*my,x,y;
    int xm,ym;
    ch=read(&xm,&ym,mbutt);
    switch(ch) {
        case 0:
            cursor(xx0,yy0);
            cursor(xm,ym);
            break;
        case 1:
            cursor(xx0,yy0);
            cursor(xm,ym);
            circle(xm,ym,6);
            break;
        case 2:
            cursor(xx0,yy0);
            cursor(xm,ym);
            rectangle(xm,ym,xm+12,ym+12);
            break;
        case 3:
            cursor(xx0,yy0);
            cursor(xm,ym);
            putpixel(xm,ym,7);
            break;
    }
    *mx=xm;
    *my=ym;
2012-07-18 19:17
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:10 
论坛前辈,写过比较好元代码!自己去看

用心做一件事情就这么简单
2012-07-19 00:47
不忘
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-18
收藏
得分:0 
恩,那我找一下。主要是鼠标程序的问题。谢拉!
2012-07-19 10:48
快速回复:用tc3.0编写图形程序关于编写鼠标程序的疑惑
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012163 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved