如何在Turbo C / C ++ 3.0中更改光标形状 [英] How to Change Cursor Shape in Turbo C/C++ 3.0

查看:127
本文介绍了如何在Turbo C / C ++ 3.0中更改光标形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从互联网上获得了以下程序,但不明白它是如何工作的。如何定义鼠标指针位图以及什么是沙漏屏幕遮罩?



I got this following program from the internet, but don't understand how it works. How is the mouse-pointer bitmap defined and what is the hour-glass screen mask?

#include "graphics.h"
#include "dos.h"

union REGS i, o ;
struct SREGS s ;

int cursor[32] =
{
    /* hour-glass screen mask */
    0x0000, 0x0000, 0x0000, 0x0000, 0x8001, 0xc003, 0xf00f, 0xfc3f, 0xfc3f, 0xf00f, 0xc003, 0x8001, 0x0000, 0x0000, 0x0000, 0x0000,
    /* the mouse pointer bitmap */
    0xffff, 0x8001, 0xffff, 0x8001, 0x4002, 0x2004, 0x1008, 0x0240, 0x0240, 0x0810, 0x2004, 0x4002, 0x8001, 0xffff, 0x8001, 0xffff
};

int main( )
{
    int gd = DETECT, gm ;
    initgraph ( &gd, &gm, "c:\\tc\\bgi" ) ;
    if ( initmouse( ) == 0 )
    {
        closegraph( ) ;
        printf ( "\n Mouse not installed!" ) ;
        exit ( 1 ) ;
    }
    gotoxy( 10, 1 ) ;
    printf( "Press any key to exit..." ) ;
    changecursor ( cursor ) ;
    showmouseptr( ) ;
    getch();
    return 0;
}

void initmouse( )
{
    i.x.ax = 0 ;
    int86 ( 0x33, &i, &o ) ;
    return ( o.x.ax ) ;
}

void showmouseptr( )
{
    i.x.ax = 1 ;
    int86 ( 0x33, &i, &o ) ;
}

void changecursor ( int *shape )
{
    i.x.ax = 9 ; /* service number */
    i.x.bx = 0 ; /* actual cursor position from left */
    i.x.cx = 0 ; /* actual cursor position from top */
    i.x.dx = ( unsigned ) shape ; /* offset address of pointer image */
    segread ( &s ) ;
    s.es = s.ds ; /* segment address of pointer */
    int86x ( 0x33, &i, &i, &s ) ;
}

推荐答案

代码只能在安装了鼠标驱动程序的MS-DOS上运行,或者在使用支持的DOS模拟时运行中断33h。



如果这是您的意图,您可以向您最喜欢的搜索引擎询问中断33h。该中断提供对DOS鼠标驱动程序的访问。



简短说明可在 https://courses.engr.illinois.edu/ece390/books/labmanual/io-devices-mouse.html [ ^ ]。
The code will only run on MS-DOS with installed mouse driver or when using a DOS emulation that supports the interrupt 33h.

If that is your intention you may ask your favorite search engine for "interrupt 33h". That interrupt provides access to the DOS mouse driver.

A short description can be found at https://courses.engr.illinois.edu/ece390/books/labmanual/io-devices-mouse.html[^].


这篇关于如何在Turbo C / C ++ 3.0中更改光标形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆