Tài liệu Báo cáo tiểu luận môn Hệ Điều Hành - Pdf 98

Báo cáo tiểu luận môn Hệ Điều Hành
Sinh viên : Nguyễn Đức Đài
06119009
GVHD: Thầy Khoan.
Gới thiệu đề tài:
Trong quá trình học trên lớp ,tìm hiểu và tham khảo kiến thức về môn Hệ Điều
Hành,em thấy mảng đề tài về MOUSE là khá hay. Vì vậy với những kiến thức có
được,em đưa ra đề tài gồm nội dung sau:
• Hiển thị biểu tượng MOUSE trong MS DOS.
• Hiển thị vị trí của MOUSE trong khi di chuyển.
• Khi click MOUSE trái sẽ hiển thị ra vị trí đã click.
• Khi click MOUSE phải sẽ thoát khỏi chương trình.
Cách làm: int 33h
Công cụ: Borland c++3.1
Chương trình:
Chương trình này kiểm tra xem co mouse kết nối với PC chưa.( tìm driver của mouse)
#include <dos.h>#include<stdio.h>#include<conio.h>
void main()
{
union REGS i,o;
i.x.ax=0;
int86(0x33,&i,&o);
if(o.x.ax==0)
printf("No Mouse Available ");
else
printf("Mouse Available "); getch();
}MOUSE1.EXE
Chương trình trên đưa ra 2 giá trị của loại union REGS trong dos.h,bao gồm 2
structs (struct WORDREGS x, struct BYTEREGS h). Hai structures này chứa một
vài giá trị 1-byte long và 2-byte long đại diện cho thanh ghi của CPU. Đưa giá trị
0 (hàm con) vào thanh ghi AX và gọi chuột bằng interrupt(33h),chúng ta có thể

i.x.ax=0;
int86(0x33,&i,&o);

if(o.x.ax==0)
{
printf("No Mouse Available ");
exit(1);
}
i.x.ax=1;
int86(0x33,&i,&o);
gotoxy(24,23);
printf("Press any key to hide mouse cursor ");
getch();

i.x.ax=2; //hide mouse!!!!!
int86(0x33,&i,&o);

gotoxy(10,23);
printf("Mouse cursor is hidden !! Press any key to terminate the program ");
getch();
}MOUSE3.EXE
Chương trình trên dùng hàm con 2 và gọi ngắt để giấu con trỏ chuột.
5) Program to print which mouse button is pressed
#include <dos.h>#include<stdio.h>#include<conio.h>#include<stdlib.h>
void main()
{
union REGS i,o;
int button;

clrscr();

case 2:
printf("Right button pressed ");
break;

case 4:
printf("Middle button pressed ");
break;

case 3:
printf("Left and Right buttons pressed ");
break;

case 5:
printf("Left and Middle buttons pressed ");
break;

case 6:
printf("Right and Middle buttons pressed ");
break;

case 7:
printf("All the three buttons pressed ");
break;

default:
printf("No button pressed ");
}
}

i.x.ax=2;

int86(0x33,&i,&o);

outtextxy(100,400,"Mouse Pointer in graphics mode!!Press any key to exit");
getch();

i.x.ax=2;
int86(0x33,&i,&o);

restorecrtmode(); }
MOUSE7.EXE
ở chương trình này ,ta dung thư viện chuẩn là hàm initgraph() của hệ thống đò
họa. hàm này có 3 đối số: graphics driver(công cụ đồ họa), graphics mode(chế độ
đồ họa ),đường dẫn vào thư mục. By using DETECT,ta nói hàm chọn công
cụ(driver) phù hợp cho nó. Khi dùng DETECT ,không cần chọn bất kỳ graphics
mode nào.
9) Free-hand drawing//tham khảo
#include <graphics.h>#include
<dos.h>#include<stdio.h>#include<conio.h>#include<stdlib.h>
union REGS i,o;

void main()
{

int gd=DETECT,gm,button,x1,y1,x2,y2;

initgraph(&gd,&gm," d:\\borlandc\\bgi ");

i.x.ax=0;
int86(0x33,&i,&o);



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

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

void get_mouse_pos(int *x,int *y,int *button)
{
i.x.ax=3;
int86(0x33,&i,&o);

*x=o.x.cx;
*y=o.x.dx;
*button=o.x.bx&1;
}MOUSE9.EXE
10/ Chương trình hiện tọa độ chuột trên màn hình
#include <dos.h>#include <stdio.h>#include <conio.h>#include <string.h>#include <stdlib.h>
char * Str_Pos_Mouse = "00:00";
char * Str_Menu = "Quit ";
char Colum_Menu = 76;
char Row_Menu = 1;
const char Left_Click = 1;
int MouseX, MouseY, MouseClick;

{
gotoxy(x,y);
cprintf("%s",Msg);
}
void Show_Menu(char On_Menu)
{
WriteXY(Colum_Menu,Row_Menu,Str_Pos_Mouse);
WriteXY(Colum_Menu,Row_Menu+1,Str_Menu);
}
int Is_OnMenu(int x, int y)
{
int result;
result=0;
if ((x+1 >= Colum_Menu) && (x+1 <= Colum_Menu + 4)
&& ( y+1 >= Row_Menu + 1) && (y+1 <= Row_Menu+ 3 ))
result = y - Row_Menu +1;
return(result);
}
void Setup_Mouse()
{
union REGS _regs;
_regs.x.ax = 0x0000;
int86(0x33, &_regs, &_regs);
Num_Mouse_Button = _regs.h.bl;
_regs.x.ax = 0x0001;
int86(0x33, &_regs, &_regs);
}
void Get_Pos_Mouse(int * MP_x,int * MP_y,int * St_Button)
{
union REGS _regs;


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status