Geri git   Van.GEN.TR Forum | Yerel Van Forumu > Bilgisayar > Programlama > Pascal

Cevapla
 
Konu Araçları Stil
Alt 24/04/07, 01:07   #1
gokhanaygun
Tuğgeneral
 
gokhanaygun - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Apr 2007
Bulunduğu yer: VAN
Yaş: 36
Mesajlar: 924
Tecrübe Puanı: 26 gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold gokhanaygun is a splendid one to behold
Standart görsel menu

{

-------------------------------------------------------------------------

Pascal code for creating a menu-bar

(Probably not the most optimied thing around, but it does the job)
All code by me except the Save_Screen/Restore_Screen and
HideCursor/ShowCursor procedures that I found in SWAG.
This thing can off course be expanded to include shortcuts to menus and
so on, use your imagination!

Needed files:
menuunit.pas - menu-system unit
menusys.pas - example program

-------------------------------------------------------------------------

(c) Anders Gardebring 27/1 1997

Contact me at:

Email: khaan@algonet.se
www: [Bu Adresi (link) Görme Yetkiniz Yok BEDAVA'ya Üye Ol Sitemizden Faydalan....]

-------------------------------------------------------------------------

This code is almost Public Domain.
It may be freely copied, altered and included in any program of
any kind as long as credit is given to the author.

This program is used to create a menu like the ones you can find in
MS-DOS editor, or Turbo Pascal.

See menusys.pas for an example program!

-------------------------------------------------------------------------

}

unit menuunit;
interface
uses crt;

const MaxHead = 10; {Max number of mainmenus}
MaxSub = 20; {Max number of submenus}

{ End of constant declarations ---------------------------------}

var Loop, Loop2 : Byte;
ch : char;
TmpStr : String;


MenuText : Array [1..MaxHead, 1..MaxSub] of String [40];
{Text in menus}

HeadPos : Array [1..MaxHead] of Byte;
{X-Position of the different main-menus}

MenuPos_X, {x and}
MenuPos_Y : Byte; {y position for the menu}

Activated_Main, {Activated Main-menu}
Activated_Sub : Byte; {Activated sub-menu}

C_MenuBack,
C_MenuText,
C_Disabled,
C_HighBack,
C_HighText,
C_HighDisabled: Byte; {Colors for the menu system}
Max_X, Max_Rows: Byte;
Selected_Main,
Selected_Sub: Byte; {Used to detect activated menu}


Buffer : Array[1..4000] of Byte;
{Used for Save_Screen and Restore_Screen}

{ End of variable declarations ---------------------------------}
Procedure HideCursor;
Procedure ShowCursor;
Procedure Save_Screen; {Save Text Screen}
Procedure Restore_Screen; {Restore Text Screen}
Procedure Draw_Box (x1, y1, x2, y2: Byte);
Procedure Draw_Shadow_Box (x1, y1, x2, y2: Byte);
Procedure Start_Menu_Sys;
Procedure Add_Menu (Txt: String; Head, Sub: Byte); {Add a menu}
Procedure Bottom_Bar (Txt: String);
Procedure Reset_Menu;
Procedure Create_Menu (x, y, MenuLen: Byte);
function Selected (head, sub: Byte): Boolean;
Procedure Clear_Selected;



implementation

Procedure Clear_Selected;
Begin
Selected_Main := 0;
Selected_Sub := 0;

End;

function Selected (head, sub: Byte): Boolean;
{Used to determine which menu has been selected, see
menusys.pas}
Begin
Selected := False;
If (Selected_Main = head) And (Selected_Sub = sub) Then
Selected := True;
End; {selected}


Procedure HideCursor; Assembler;
Asm
mov ax, 0100h
mov cx, 2607h
int 10h
end; {HideCursor}

Procedure ShowCursor; Assembler;
Asm
mov ax, 0100h
mov cx, 0506h
int 10h
end; {ShowCursor}


Procedure Save_Screen; {Save Text Screen}
begin
Move(Mem[$B800:0000],Buffer,4000);
end; {Save_Screen}

Procedure Restore_Screen; {Restore Text Screen}
begin
Move(Buffer,Mem[$B800:0000],4000);
end; {Restore_Screen}


Procedure Draw_Box (x1, y1, x2, y2: Byte); {Draw a box with current colors}
var D_Loop, D_Loop2: Byte;
Begin

Window (x1, y1, x2, y2); {Fix the background of the box}
ClrScr;
Window (1, 1, 80, 25);

{Draw Lines at the corners of the box:}

For D_Loop := x1 + 1 to x2 - 1 do
Begin
GotoXy (D_Loop, y1);
Write ('Ä');
GotoXy (D_Loop, y2);
Write ('Ä');
End;

For D_Loop := y1 + 1 to y2 - 1 do
Begin
GotoXy (x1, D_Loop);
Write ('³');
GotoXy (x2, D_Loop);
Write ('³');
End;

GotoXy (x1, y1);
Write ('Ú');
GotoXy (x2, y1);
Write ('¿');
GotoXy (x1, y2);
Write ('À');
GotoXy (x2, y2);
Write ('Ù');

End; {Draw_Box}

Procedure Draw_Shadow_Box (x1, y1, x2, y2: Byte);
{Draw a box with a shadow}
Begin
Draw_Box (x1, y1, x2, y2);
TextColor (0);
For Loop := y1 + 1 to y2 do
Begin
GotoXy (x2 + 1, Loop);
Write ('ÛÛ');
End;
For Loop := x1 + 2 to x2 + 2 do
Begin
GotoXy (Loop, y2 + 1);
Write ('Û');
End;
End; {Draw_Shadow_Box}

Procedure Draw_Sub_Menu (Number: Byte); {Draw a submenu}

Procedure Draw_Sub_Text; {Print menu text}
Begin

For Loop := 1 to Max_Rows do
Begin
TextColor (C_MenuText);
TextBackGround (C_MenuBack);
If (Loop = Activated_Sub) and (Number = Activated_Main) Then
Begin
TextColor (C_HighText);
TextBackGround (C_HighBack);
GotoXy (MenuPos_X + HeadPos [Number] - 1, MenuPos_Y + Loop + 1);
TmpStr := '';
For Loop2 := 1 to Max_X + 2 do
TmpStr := TmpStr + ' ';
Write (TmpStr);
End;
GotoXy (MenuPos_X + HeadPos [Number], MenuPos_Y + Loop + 1);

If MenuText [Number, Loop + 1] <> '-' Then
{Is current menu a separator?}
Begin {No, it ain't}
Write (MenuText [Number, Loop + 1]);
End
Else {Current menu is a separator}
Begin

TmpStr := '';
For Loop2 := 1 to Max_x + 2 do
TmpStr := TmpStr + 'Ä';

TmpStr := 'Ã' + TmpStr + '´';
GotoXy (MenuPos_X + HeadPos [Number] - 2, MenuPos_Y + Loop + 1);

Write (TmpStr);
end;
End;
TextColor (C_MenuText);
TextBackGround (C_MenuBack);
End; {Draw_Sub_Text}



Begin
TextBackGround (C_MenuBack); {Set colors}
TextColor (C_MenuText);

Max_X := 0;
Max_Rows := 0;
{Get number of rows in this submenu:}

For Loop := 1 to MaxSub do
If MenuText [Number, Loop] <> '' Then
Inc (Max_Rows);
{Calculate the longest string in this menu:}
For Loop := 1 to Max_Rows do
Begin
If Length (MenuText [Number, Loop]) >Max_X Then
Max_X := Length (MenuText [Number, Loop]);
End;


{Draw a box for this submenu}
Draw_Shadow_Box (MenuPos_X + HeadPos [Number] - 2, MenuPos_y + 1,
MenuPos_X + HeadPos [Number] + 1 + Max_X, MenuPos_y + 1 + Max_Rows);

Draw_Sub_Text; {Print text for this submenu}

End; {Draw_Sub_Menu}


Procedure Draw_Menu_Bar (x, y: Byte); {Draw the mainmenu}
Var Pos: Byte;

Begin
TextBackGround (c_MenuBack); {Set colors}
TextColor (c_MenuText);

MenuPos_X := x;
MenuPos_Y := y;

GotoXy (x, y);
Write (' ');
pos := 2;
For Loop := 1 to MaxHead do
Begin
If MenuText [Loop, 1] <> '' Then
Begin
Write (MenuText [Loop, 1], ' ');
HeadPos [Loop] := Pos;
Inc (Pos, Length (MenuText [Loop, 1]) + 2);
End;
End;
End; {Draw_Menu_Bar}



Procedure Create_Menu (x, y, MenuLen: Byte); {Create a new menu from
specified values at
position x, y}
Begin

Window (x, y, x+ MenuLen, y);
TextBackGround (C_MenuBack);
ClrScr;
Window (1, 1, 80, 25);

Draw_Menu_Bar (x, y);

End; {Create_Menu}

Procedure Reset_Menu; {Clear all menu values}

Begin
Activated_Main := 0;
Activated_Sub := 0;
MenuPos_X := 0;
MenuPos_Y := 0;

For Loop := 1 to MaxHead do
Begin
HeadPos [Loop] := 0;
For Loop2 := 1 to MaxSub do
MenuText [Loop, Loop2] := '';
End;
End; {Reset_Menu}


Procedure Add_Menu (Txt: String; Head, Sub: Byte); {Add a menu}
Begin
MenuText [Head, Sub] := Txt;
End; {Add_Menu}


Procedure Bottom_Bar (Txt: String);
Begin
TextBackGround (C_MenuBack);
Window (1, 25, 80, 25);
ClrScr;
TextColor (C_MenuText);
Write (' ' + Txt);
Window (1, 1, 80, 25);

End; {Bottom_Bar}


Procedure Start_Menu_Sys;

Procedure Do_Menu;
Begin
Draw_Sub_Menu (Activated_Main);
End; {Do_Menu}

Procedure Do_Menu2;
Begin
Save_Screen;
TextBackGround (C_HighBack);
TextColor (C_HighText);
GotoXy (MenuPos_X + HeadPos [Activated_Main] - 1, MenuPos_Y);
Write (' ' + MenuText [Activated_Main, 1] + ' ');

Do_Menu
End; {Do_Menu2}

Begin
Activated_Main := 1; {Standard menu selected at menu startup}
Activated_Sub := 1;

Do_Menu2;
Selected_Main := 0;
Selected_Sub :=0;

Repeat
ch := ReadKey;

If ch = #13 Then
Begin
Selected_Main := Activated_Main;
Selected_Sub := Activated_Sub + 1;
End;

If ch = #0 Then {Right button pressed}
Begin
ch := ReadKey;
If ch = #77 Then
Begin
Restore_Screen;
Inc (Activated_Main);
If MenuText [Activated_Main, 1] = '' Then Dec (Activated_Main);
Activated_Sub := 1;
Do_Menu2;
End;
If ch = #75 Then {Left button pressed}
Begin
Restore_Screen;
Dec (Activated_Main);
If Activated_Main = 0 Then Activated_Main := 1;
Activated_Sub := 1;
Do_Menu2;
End;

If ch = #72 Then {Up key pressed}
Begin
Dec (Activated_Sub);
If MenuText [Activated_Main, Activated_Sub + 1] = '-' Then Dec(Activated_Sub);
If MenuText [Activated_Main, Activated_Sub] = '' Then Activated_Sub := Max_Rows - 1;
Do_Menu;
End;

If ch = #80 Then {Down key pressed}
Begin
Inc (Activated_Sub);
If MenuText [Activated_Main, Activated_Sub + 1] = '-' Then Inc(Activated_Sub);
If MenuText [Activated_Main, Activated_Sub + 1] = '' Then Activated_Sub := 1;
Do_Menu;
End;
End;
Until (ch = #27) or (ch = #13);
Restore_Screen;
End;


begin

end.
gokhanaygun isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 187
Alt 20/06/08, 15:19   #2
firari
Mareşal
 
firari - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Sep 2007
Mesajlar: 5.835
Tecrübe Puanı: 104 firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute firari has a reputation beyond repute
Standart

Paylaşım için tşkler…
__________________



firari isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 613
Takımınız:
Alt 30/06/08, 01:59   #3
Mattet
Cumhurbaşkanı
 
Mattet - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: May 2008
Bulunduğu yer: van
Mesajlar: 7.027
Tecrübe Puanı: 48 Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute Mattet has a reputation beyond repute
Standart

teŞekkÜrler PaylaŞim İİÇİn
__________________





Düşmeden Bulutlarda Koşmam GereK !
Mattet isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 866
Alt 31/07/08, 15:36   #4
Neutralizer
Yasaklı kullanıcı
 
Neutralizer - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Jan 2008
Bulunduğu yer: İstediğin yerden
Mesajlar: 1.883
Tecrübe Puanı: 0 Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute Neutralizer has a reputation beyond repute
Standart

paylaşım için tşkrlr
Neutralizer isimli Üye şimdilik offline konumundadır   Alıntı ile Cevapla
Konu Sayısı: 316
Takımınız:
Cevapla


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 

Yetkileriniz
Yeni Mesaj yazma yetkiniz Aktif değil dir.
Mesajlara Cevap verme yetkiniz aktif değil dir.
Eklenti ekleme yetkiniz Aktif değil dir.
Kendi Mesajınızı değiştirme yetkiniz Aktif değildir dir.

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-KodlarıKapalı
Gitmek istediğiniz klasörü seçiniz


Bütün Zaman Ayarları WEZ +3 olarak düzenlenmiştir. Şu Anki Saat: 16:20 .


Powered by vBulletin
Copyright © 2000-2007 Jelsoft Enterprises Limited.
Sitemap
6, 5, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15, 113, 16, 17, 18, 19, 81, 20, 27, 22, 23, 24, 25, 26, 48, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 136, 40, 58, 45, 42, 44, 46, 47, 53, 54, 55, 56, 57, 59, 60, 70, 61, 62, 63, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 77, 78, 79, 80, 82, 83, 96, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 98, 97, 100, 101, 102, 103, 106, 104, 105, 112, 109, 108, 107, 110, 111, 114, 115, 118, 116, 117, 119, 148, 154, 124, 165, 122, 120, 123, 121, 150, 153, 125, 128, 129, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 151, 149, 202, 175, 164, 152, 167, 155, 156, 157, 158, 159, 160, 161, 162, 163, 195, 169, 166, 168, 170, 171, 172, 199, 174, 173, 196, 200, 176, 177, 180, 178, 179, 182, 189, 187, 184, 186, 191, 192, 193, 194, 197, 198, 201, 203, 229, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 236, 231, 232, 233, 234, 235, 237, 240, 239, 241, 243, 242, 244,