📄 addressbook.cpp
字号:
/*******************************************************
* MYCPLUS Sample Code - http://www.mycplus.com *
* *
* This code is made available as a service to our *
* visitors and is provided strictly for the *
* purpose of illustration. *
* *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/
//Address Book Program by
//Manoj M
//manoj.exotic@gmail.com
#include <fstream.h>
#include <graphics.h>
#include <conio.h>
#include <mouseptr.h>
#include <stdlib.h>
#include <stdio.h>
#include <process.h>
#include <string.h>
#include <ctype.h>
#include "final\head.cpp"
fstream adb;
int button, x, y;
struct CURSOR
{
int x1;
int x2;
int y;
};
struct node
{
char ch;
node *next;
}*first = NULL, *temp;
void refreshbox()
{
hidemouseptr();
setfillstyle(1, 15);
bar(10, 25, getmaxx(), 459);
showmouseptr();
}
class menubutton
{
int x1, y1, x2, y2;
char caption[25];
public:
int flag;
menubutton(int a1, int b1, int a2, int b2, char cap[25])
{
x1 = a1; x2 = a2;
y1 = b1; y2 = b2;
strcpy(caption, cap);
flag=0;
}
void draw()
{
hidemouseptr();
setfillstyle(1, 15);
bar(x1, y1, x2, y2);
setcolor(0);
rectangle(x1, y1, x2, y2);
setcolor(1);
outtextxy(x1+10, y1+8, caption);
showmouseptr();
}
void onover()
{
hidemouseptr();
setfillstyle(1, 1);
bar(x1+2, y1+2, x2-2, y2-2);
setcolor(14);
outtextxy(x1+10, y1+8, caption);
showmouseptr();
}
int check()
{
getmousepos(&button, &x, &y);
int val;
val = x>x1 && x<x2 && y>y1 && y<y2;
return val;
}
};
void drawinterface()
{
setfillstyle(1, 15);
bar(0, 0, getmaxx(), getmaxx());
setfillstyle(1, 1);
bar(0, 460, getmaxx(), getmaxy());
setfillstyle(1, 2);
bar(0, 460, 60, getmaxy());
setcolor(0);
outtextxy(8, 466, "Start");
setcolor(15);
outtextxy(10, 467, "Start");
}
void initialize()
{
int gd=DETECT, gm;
initgraph(&gd, &gm, "");
initmouse();
}
void draw3dbox(int x1, int y1, int x2, int y2)
{
hidemouseptr();
setcolor(7);
line(x1, y1, x2, y1);
line(x1, y1, x1, y2);
setcolor(0);
line(x1, y2, x2, y2);
line(x1, y2+1, x2, y2+1);
line(x2, y1, x2, y2);
line(x2+1, y1, x2+1, y2);
showmouseptr();
}
void displaychar(int x, int y, char ch)
{
char str[2];
str[0]=ch;
str[1]=0;
outtextxy(x, y, str);
}
void entertext(int x1, int y1, int x2, int y2, node *string)
{
int flag=1;
char ch;
setcolor(0);
rectangle(x1, y1, x2, y2);
int tx, ty;
int tm, cm;
tx = x1+5;
ty = y1+10;
CURSOR cursor;
cursor.x1 = x1+5;
cursor.x2 = x1+10;
cursor.y = y1+18;
setcolor(0);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
do
{
setcolor(0);
rectangle(x1, y1, x2, y2);
ch = getch();
//***************************************************************************
if (ch>=33 && ch<=126 && !(ty>=y2-10))
{
if ( !(ty>=y2-20 && tx>=x2-25) )
{
node *newlink = new node;
newlink = NULL;
newlink->ch = ch;
newlink->next=NULL;
if (first==NULL)
{
first=newlink;
}
else
{
temp = first;
while (temp->next!=NULL)
temp=temp->next;
temp->next=newlink;
}
setcolor(15);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
setcolor(0);
displaychar(tx, ty, ch);
tx+=8;
tm = tx;
cursor.x1+=8;
cursor.x2+=8;
cm = cursor.x1;
if (tx>=x2-15)
{
tm=tx;
tx=x1+5;
ty+=8;
cm = cursor.x1;
cursor.x1 = x1+5;
cursor.x2 = x1+10;
cursor.y += 8 ;
}
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
}
}
//***************************************************************************
if (ch==8)
{
node *temp = first;
node *ptr = temp;
while (temp->next!=NULL)
{
ptr=temp;
temp=temp->next;
ch = temp->ch;
}
if (ptr==temp)
first=NULL;
setcolor(15);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
ptr->next=NULL;
displaychar(tx, ty, temp->ch);
tx-=8;
cursor.x1-=8;
cursor.x2-=8;
displaychar(tx, ty, temp->ch);
if (tx<x1+5)
{
tx=tm-8;
ty-=8;
cursor.x1-=8;
cursor.x2-=8;
flag=0;
}
if (flag==0)
{
cursor.x1 = cm-8;
cursor.x2 = cm;
cursor.y -= 8;
flag=1;
}
if (ty<y1+10)
{
tx = x1+5;
ty = y1+10;
cursor.x1 = x1+5;
cursor.x2 = x1+10;
cursor.y = y1+18;
}
displaychar(tx, ty, temp->ch);
setcolor(0);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
}
//***************************************************************************
if (ch==13)
{
setcolor(15);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
tx = x1+5;
ty+=8;
cursor.x1 = x1+5;
cursor.x2 = x1+10;
cursor.y += 8;
setcolor(0);
line(cursor.x1, cursor.y, cursor.x2, cursor.y);
node *newlink = new node;
newlink = NULL;
newlink->ch = 32;
newlink->next=NULL;
if (first==NULL)
{
first=newlink;
}
else
{
temp = first;
while (temp->next!=NULL)
temp=temp->next;
temp->next=newlink;
}
}
}while (ch!=27);
string=first;
first = string;
}
void enterlinetext(int x1, int y1, int x2, char *string, int opt=0)
{
/*
OPTION USE
0 Files
1 Name
2 Numbers
3 Email
4 Address
*/
char *perm = NULL;
char ch, sub[2];
int y2 = y1+25;
int tx, ty;
tx = x1+5;
ty = y1+8;
perm = string;
sub[1] = 0;
CURSOR cursor;
cursor.x1 = x1+5;
cursor.x2 = x1+10;
cursor.y = y2-8;
setcolor(0);
rectangle( x1, y1, x2, y2);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
*string =0;
do
{
ch = getch();
sub[0] = ch;
if ( ( isalpha(ch) || isdigit(ch) || ch =='.' || ch =='_' || ch =='\\'
|| ch ==':' ) && cursor.x2<x2-10 && opt==0)
{
*string++ = ch;
*string = 0;
setcolor(0);
outtextxy(tx, ty, perm);
setcolor(15);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
cursor.x1+=8;
cursor.x2+=8;
setcolor(0);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
}
if ( (isalpha(ch) || ch =='.' || ch ==' ') && cursor.x2<x2-10 && opt==1)
{
*string++ = ch;
*string = 0;
setcolor(0);
outtextxy(tx, ty, perm);
setcolor(15);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
cursor.x1+=8;
cursor.x2+=8;
setcolor(0);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
}
if ( isdigit(ch) && cursor.x2<x2-10 && opt==2)
{
*string++ = ch;
*string = 0;
setcolor(0);
outtextxy(tx, ty, perm);
setcolor(15);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
cursor.x1+=8;
cursor.x2+=8;
setcolor(0);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
}
if ( (isalpha(ch) || isdigit(ch) || ch =='.' || ch =='_' || ch=='@')
&& cursor.x2<x2-10 && opt==3)
{
*string++ = ch;
*string = 0;
setcolor(0);
outtextxy(tx, ty, perm);
setcolor(15);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
cursor.x1+=8;
cursor.x2+=8;
setcolor(0);
line( cursor.x1, cursor.y, cursor.x2, cursor.y);
}
if ( ( isalpha(ch) || isdigit(ch) || ch =='.' || ch =='-' || ch ==','
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -