Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Паскаль, Turbo Pascal, PascalABC.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 24.02.2011, 16:21   #1
_-Re@l-_
C++, Java
Старожил
 
Аватар для _-Re@l-_
 
Регистрация: 10.04.2010
Сообщений: 2,665
Восклицание Непонятки с мышью

Ну вот код:
Код:
Unit Menus;

Interface

Uses CRT,GRAPH;

Const
     MB_LEFT   = 1;
     MB_RIGHT  = 2;
     MB_MIDDLE = 4;

Type
    TPoint = packed record
    X,Y:Integer;
End;
Type
    TMouseState = packed record
    Loc:TPoint;
    But:Integer;
end;

Function  ResetMouse:integer;
Procedure ShowMouse;
Procedure HideMouse;
Procedure GetMouseState(Var S:TMouseState);
Procedure MoveMouseCursor(P:TPoint);
Procedure SetMouseVert(max,min:Integer);
Procedure SetMouseHorz(max,min:Integer);
Procedure DrawMenu(A,B,C:String;P1,P2,P3:TPoint;Var M:TMouseState);

Implementation

Procedure DrawMenu(A,B,C:String;P1,P2,P3:TPoint;Var M:TMouseState);
Begin
     SetTextStyle(5,HorizDir,4);
     SetColor(Blue);
     OutTextXY(P1.X,P1.Y,A);
     OutTextXY(P2.X,P2.Y,B);
     OutTextXY(P3.X,P3.Y,C);
     While M.But <> MB_LEFT Do
     Begin
          GetMouseState(M);
          If (M.Loc.x>P1.X) and (M.Loc.x<P1.X+200) and
             (M.Loc.y>P1.Y) and (M.Loc.y<P1.Y+150) Then
          Begin
               If (M.Loc.y<P1.Y+50) Then
               Begin
                    SetColor(Yellow);
                    OutTextXY(P1.X,P1.Y,A);
                    SetColor(Blue);
                    OutTextXY(P2.X,P2.Y,B);
                    OutTextXY(P3.X,P3.Y,C);
                    Continue;
               End;
               If (M.Loc.y<P2.Y+50) Then
               Begin
                    SetColor(Blue);
                    OutTextXY(P1.X,P1.Y,A);
                    OutTextXY(P3.X,P3.Y,C);
                    SetColor(Yellow);
                    OutTextXY(P2.X,P2.Y,B);
                    Continue;
               End;
               If (M.Loc.y<P3.Y+50) Then
               Begin
                    SetColor(Blue);
                    OutTextXY(P1.X,P1.Y,A);
                    OutTextXY(P2.X,P2.Y,B);
                    SetColor(Yellow);
                    OutTextXY(P3.X,P3.Y,C);
                    Continue;
               End;
          End
          Else
          Begin
               SetColor(Blue);
               OutTextXY(P1.X,P1.Y,A);
               OutTextXY(P2.X,P2.Y,B);
               OutTextXY(P3.X,P3.Y,C);
               Continue;
          End;
     End;
End;

Function  ResetMouse:integer;assembler;
Asm
    xor ax, ax
    int 33h
End;

Procedure ShowMouse;assembler;
Asm
  mov ax, 1
  int 33h
End;

Procedure HideMouse;assembler;
Asm
  mov ax, 2
  int 33h
End;

Procedure GetMouseState;assembler;
Asm
  mov ax, 3
  int 33h
  push es
  push di
  les di, dword ptr s
  mov es:[di], cx
  mov es:[di+2], dx
  mov es:[di+4], bx
  pop di
  pop es
End;

Procedure MoveMouseCursor;assembler;
Asm
  mov ax, 4
  mov cx, p.x
  mov dx, p.y
  int 33h
End;

Procedure SetMouseVert;assembler;
Asm
 mov ax, 8
 mov cx, min
 mov dx, max
 int 33h
End;

Procedure SetMouseHorz; assembler;
Asm
 mov ax, 7
 mov cx, min
 mov dx, max
 int 33h
End;

End.
И вот сам проект:
Код:
Uses CRT,GRAPH,Menus;
Var
   gd,gm:Integer;
   X:TMouseState;
   P1,P2,P3:TPoint;
   S:String;
Begin
     gd:=Detect;
     InitGraph(gd,gm,'c:\bp\bgi\');
     P1.x:=200;P1.y:=150;
     P2.x:=200;P2.y:=200;
     P3.x:=200;P3.y:=250;
     SetMouseVert(0,480);
     SetMouseHorz(0,640);
     ShowMouse;
     DrawMenu('1. New Game','2. Settings','3. Exit',P1,P2,P3,X);
     {CloseGraph;
     InitGraph(gd,gm,'c:\bp\bgi\'); }
     X.But:=0;
     ShowMouse;
     ClearDevice;
     DrawMenu('1. C++','2. C#','3. Java',P1,P2,P3,X);
End.
В таковом случае программа вылетает, не выполняя вот этот участок:
Код:
DrawMenu('1. C++','2. C#','3. Java',P1,P2,P3,X)
С чем это может быть связано?
_-Re@l-_ вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
непонятки gling Microsoft Office Excel 8 05.01.2011 21:25
непонятки с if mrgrudge PHP 2 05.10.2010 12:01
Непонятки в делфи Aleksey1989 Помощь студентам 4 17.09.2010 13:54
Непонятки с меню shark2010 Паскаль, Turbo Pascal, PascalABC.NET 2 17.09.2010 10:38
Непонятки с условием L3zh1Y Помощь студентам 4 11.06.2010 08:25