#include Postado Agosto 25, 2009 Denunciar Share Postado Agosto 25, 2009 #include "ptoc.h" /*#include "Crt.h"*/ struct registro { varying_string<3> matricula; varying_string<10> nascimento; varying_string<60> nome; varying_string<12> rg; varying_string<14> cpf; varying_string<60> endereco; varying_string<60> bairro; varying_string<60> cidade; varying_string<2> estado; varying_string<60> cep; varying_string<1> sexo; varying_string<14> fone; varying_string<14> fax; varying_string<14> cel; }; struct estoque { /*produto: string[3];*/ varying_string<60> descricao; /*detalhe:string[60];*/ varying_string<4> unidade; /*grupo:string[60]; //sub_grupo:string[60]; //tipo:string[60]; //aliquotas_icms:string[60]; //preco_de_venda:string[60]; //deis:string[60]; //dias30:string[10];*/ varying_string<10> valor; /*//pgtos2:string[10]; //valor2:string[10];*/ }; varying_string<80> mais; text trabalho; string texto,x; registro reg; estoque rec; string execucao; varying_string<10> usuario; varying_string<10> senha; char p,dd; string s,z; integer linha, coluna, cor; integer erro,aux,col,lin,ql,cont; integer opcao,cs,co,cw,tempo,u,m,k,c,men; char tecla,letra,pp,poi; boolean lugar; boolean botao; text cad; string data,caminho; char caractere,concat; text arq; char ponb; string resposta; /* Auxiliar. Controla repetição.*/ string scrip; string scripyt; string a; string b; string i; string d; string e; string f; string upcasestr(string mais) { integer upcaseb; string upcasestr_result; for( upcaseb=1; upcaseb <= length(mais); upcaseb ++) mais[upcaseb]=upcase(mais[upcaseb]); upcasestr_result=mais; return upcasestr_result; } void mestre() \\Estoque entrada trabalhando { clrscr; textcolor(15); textbackground(0); gotoxy(1,1); textcolor (white); textbackground(blue); output << "AMAURI"; textbackground(green); output << " A L I N H A D Ã O P N E U S & A C" << NL; output << "" << NL; output << "Digite Código do Produto :" << NL; input >> data >> NL; caminho=string("CL ")+data+".txt"; assign(trabalho,caminho); rewrite(trabalho); /*write(' Informe produto :'); readln (rec.produto); writeln (trabalho, rec.produto);*/ output << "" << NL; output << "+-----------------------------------+" << NL; output << " Informe descrição :"; input >> rec.descricao >> NL; trabalho << rec.descricao << NL; output << "" << NL; /*writeln('+-----------------------------------+'); write (' Informe detalhe: '); readln (rec.detalhe); writeln (trabalho, rec.detalhe);*/ output << "+-----------------------------------+" << NL; output << " Informe unidade : "; input >> rec.unidade >> NL; trabalho << rec.unidade << NL; output << "+-----------------------------------+" << NL; /*write (' Informe grupo: '); readln (rec.grupo); writeln (trabalho, rec.grupo); writeln('+-----------------------------------+'); write (' Informe sub_grupo: '); readln (rec.sub_grupo); writeln (trabalho, rec.sub_grupo); writeln('+-----------------------------------+'); write (' Informe tipo: '); readln (rec.tipo); writeln (trabalho, rec.tipo); writeln('+-----------------------------------+'); write (' Informe aliquotas_icms: '); readln (rec.aliquotas_icms); writeln (trabalho, rec.aliquotas_icms); writeln('+-----------------------------------+'); write (' Informe preco_de_venda: '); readln (rec.preco_de_venda); writeln (trabalho, rec.preco_de_venda); writeln('+-----------------------------------+'); write (' Informe deis: '); readln (rec.deis); writeln (trabalho, rec.deis); writeln('+-----------------------------------+'); write (' Informe dias30: '); readln (rec.dias30); writeln (trabalho, rec.dias30); writeln('+-----------------------------------+');*/ output << "Informe valor: "; input >> rec.valor >> NL; trabalho << rec.valor << NL; /*writeln('+-----------------------------------+'); write('Informe pgtos2: '); readln (rec.pgtos2); writeln (trabalho, rec.pgtos2); writeln('+-----------------------------------+'); write('Informe valor2: '); readln (rec.valor2); writeln (trabalho, rec.valor2);*/ append(trabalho); /*grava registro após o último registro do arquivo*/ textcolor(15); textbackground (lightgray + black); output << "" << NL; close(trabalho); clrscr; textcolor (white); textbackground(green+3); output << "SEJA BEM VINDO "; textbackground(blue); output << upcasestr(mais) << NL; textbackground(green); gotoxy(1,2); output << " A L I N H A D Ã O P N E U S & A C" << NL; textbackground (black); /*loop de repeticao para voltar ao menu com a flag*/ textbackground (black); textcolor(15); gotoxy (15,4); output << "+-------------------------------------------------+" << NL; gotoxy (15,5); output << "| Digite a Opcao |" << NL; gotoxy (15,6); output << "+-------------------------------------------------+" << NL; gotoxy (15,7); output << "| 1 - Fixa | | 3 - ESTOQUE |" << NL; gotoxy (15,8); output << "+--------------------------------------------------" << NL; gotoxy (15,9); output << "| 2 - Cliente | | 4 - Produtos |" << NL; gotoxy (15,10); output << "+-------------------------------------------------+" << NL; gotoxy (15,11); output << "| Ctrl + C -saida |" << NL; gotoxy (15,12); output << "+-------------------------------------------------+" << NL; gotoxy (1,56); } void gravar() /*inicia procedure de gravação*/ { boolean loop; clrscr; output << "Digite o Registro exemplo 01 a 999" << NL; input >> data >> NL; caminho=string("CA ")+data+".txt"; assign(trabalho,caminho); rewrite(trabalho); do { clrscr; textcolor(15); textbackground(0); gotoxy(1,1); textcolor (white); textbackground(blue); output << "AMAURI"; textbackground(green); output << " A L I N H A D Ã O P N E U S & A C" << NL; output << "" << NL; output << " Informe Matricula: "; input >> reg.matricula >> NL; trabalho << reg.matricula << NL; output << "" << NL; output << "+-----------------------------------+" << NL; output << " Informe Data de Nascimento: "; input >> reg.nascimento >> NL; trabalho << reg.nascimento << NL; output << "" << NL; output << "+-----------------------------------+" << NL; output << " Informe Nome: "; input >> reg.nome >> NL; trabalho << reg.nome << NL; output << "+-----------------------------------+" << NL; output << " Informe RG: "; input >> reg.rg >> NL; trabalho << reg.rg << NL; output << "+-----------------------------------+" << NL; output << " Informe CPF: "; input >> reg.cpf >> NL; trabalho << reg.cpf << NL; output << "+-----------------------------------+" << NL; output << " Informe Endereço: "; input >> reg.endereco >> NL; trabalho << reg.endereco << NL; output << "+-----------------------------------+" << NL; output << " Informe Bairro: "; input >> reg.bairro >> NL; trabalho << reg.bairro << NL; output << "+-----------------------------------+" << NL; output << " Informe Cidade: "; input >> reg.cidade >> NL; trabalho << reg.cidade << NL; output << "+-----------------------------------+" << NL; output << " Informe Estado: "; input >> reg.estado >> NL; trabalho << reg.estado << NL; output << "+-----------------------------------+" << NL; output << " Informe CEP: "; input >> reg.cep >> NL; trabalho << reg.cep << NL; output << "+-----------------------------------+" << NL; output << " Informe Sexo: "; input >> reg.sexo >> NL; while ((reg.sexo != 'f' ) && (reg.sexo != 'm')) { textbackground(11); textcolor(blue+blink); output << "" << NL; output << "****Valor Invalido. Favor digitar um valor valido (f ou m).****" << NL; textcolor(15); textbackground(0); output << "+-----------------------------------+" << NL; output << " Informe Sexo: "; input >> reg.sexo >> NL; } trabalho << reg.sexo << NL; textcolor(0); textbackground(green); output << "+-----------------------------------+" << NL; output << "Informe Telefone: "; input >> reg.fone >> NL; trabalho << reg.fone << NL; output << "+-----------------------------------+" << NL; output << "Informe Fax: "; input >> reg.fax >> NL; trabalho << reg.fax << NL; output << "+-----------------------------------+" << NL; output << "Informe Celular: "; input >> reg.cel >> NL; trabalho << reg.cel << NL; append(trabalho); /*grava registro após o último registro do arquivo*/ textcolor(15); textbackground(0); output << "" << NL; output << "Abrir nova matrícula (S\\sim) ou (N\\não) " << NL; input >> execucao >> NL; if ((execucao == 's') || (execucao == 'S')) { continue_; } else if ((execucao == 'n') || (execucao == 'N')) { flush(); } loop = true; while (loop) { if ((execucao != 's') && (execucao != 'S') && (execucao != 'n') && (execucao != 'N')) { gotoxy (1,25); output << ">>> Opcao invalida. Digite (S/N) <<<" << NL; gotoxy (1,24); input >> execucao >> NL; } else { loop = false; } } } while (!((execucao == 'n') || (execucao == 'N'))); close(trabalho); textbackground (lightgray + black); clrscr; textcolor (white); textbackground(green+3); output << "SEJA BEM VINDO "; textbackground(blue); output << upcasestr(mais) << NL; textbackground(green); gotoxy(1,2); output << " A L I N H A D Ã O P N E U S & A C" << NL; textbackground (black); textcolor(15); gotoxy (15,4); output << "+-------------------------------------------------+" << NL; gotoxy (15,5); output << "| Digite a Opcao |" << NL; gotoxy (15,6); output << "+-------------------------------------------------+" << NL; gotoxy (15,7); output << "| 1 - Fixa | | 3 - ESTOQUE |" << NL; gotoxy (15,8); output << "+--------------------------------------------------" << NL; gotoxy (15,9); output << "| 2 - Cliente | | 4 - Produtos |" << NL; gotoxy (15,10); output << "+-------------------------------------------------+" << NL; gotoxy (15,11); output << "| Ctrl + C -saida |" << NL; gotoxy (15,12); output << "+-------------------------------------------------+" << NL; gotoxy (1,65); } void leitura() /*abrir programa para leitura*/ { clrscr; output << "Digite o Codigo" << NL; input >> data >> NL; caminho=string("CA ")+data+".txt"; assign(trabalho,caminho); reset(trabalho); /*posiciona na primeira linha*/ while (! eof(trabalho)) { /*$i-*/ textcolor(15); textbackground(black); output << "" << NL; output << "" << NL; trabalho >> reg.matricula >> NL; output << "Matricula:" << reg.matricula << NL; trabalho >> reg.nascimento >> NL; output << "nacimento:" << reg.nascimento << NL; trabalho >> reg.nome >> NL; output << "Nome.....:" << reg.nome << NL; trabalho >> reg.rg >> NL; output << "RG.......:" << reg.rg << NL; trabalho >> reg.cpf >> NL; output << "CPF......:" << reg.cpf << NL; trabalho >> reg.endereco >> NL; output << "Endereco.:" << reg.endereco << NL; trabalho >> reg.bairro >> NL; output << "Bairro.....:" << reg.bairro << NL; trabalho >> reg.cidade >> NL; output << "Cidade.....:" << reg.cidade << NL; trabalho >> reg.estado >> NL; output << "Estado.....:" << reg.estado << NL; trabalho >> reg.cep >> NL; output << "CEP.....:" << reg.cep << NL; trabalho >> reg.sexo >> NL; output << "Sexo.....:" << reg.sexo << NL; trabalho >> reg.fone >> NL; output << "Telefone.:" << reg.fone << NL; trabalho >> reg.fone >> NL; output << "Fax......:" << reg.fone << NL; trabalho >> reg.fone >> NL; output << "cel......:" << reg.fone << NL; } close(trabalho); output << "" << NL; output << "Aperte qualquer tecla para continuar." << NL; /*fecha o arquivo para a leitura*/ readkey(); textbackground(lightgray + black); clrscr; textcolor (white); textbackground(green+3); output << "SEJA BEM VINDO "; textbackground(blue); output << upcasestr(mais) << NL; textbackground(green); gotoxy(1,2); output << " A L I N H A D Ã O P N E U S & A C" << NL; textbackground (black); /*loop de repeticao para voltar ao menu com a flag*/ textbackground (black); textcolor(15); gotoxy (15,4); output << "+-------------------------------------------------+" << NL; gotoxy (15,5); output << "| Digite a Opcao |" << NL; gotoxy (15,6); output << "+-------------------------------------------------+" << NL; gotoxy (15,7); output << "| 1 - Fixa | | 3 - ESTOQUE |" << NL; gotoxy (15,8); output << "+--------------------------------------------------" << NL; gotoxy (15,9); output << "| 2 - Cliente | | 4 - Produtos |" << NL; gotoxy (15,10); output << "+-------------------------------------------------+" << NL; gotoxy (15,11); output << "| Ctrl + C -saida |" << NL; gotoxy (15,12); output << "+-------------------------------------------------+" << NL; gotoxy (1,56); } void alterar() /*alteração do arquivo*/ { boolean loop; clrscr; textcolor(15); textbackground(0); gotoxy(1,1); textcolor (white); textbackground(blue); output << "AMAURI"; textbackground(green); output << " A L I N H A D Ã O P N E U S & A C" << NL; output << "" << NL; output << "Digite Código do Produto :" << NL; input >> data >> NL; caminho=string("CL ")+data+".txt"; assign(trabalho,caminho); reset(trabalho); /*posiciona na primeira linha*/ while (! eof(trabalho)) { /*$i-*/ textcolor(15); textbackground(0); output << "" << NL; output << "" << NL; trabalho >> rec.descricao >> NL; output << "Descrição.: [" << rec.descricao << ']' << NL; trabalho >> rec.unidade >> NL; output << "Unidade...: [" << rec.unidade << ']' << NL; trabalho >> rec.valor >> NL; output << "Valor.....:" << rec.valor << NL; } close(trabalho); output << "" << NL; output << "Aperte qualquer tecla para continuar." << NL; /*fecha o arquivo para a leitura*/ readkey(); textbackground (lightgray + black); clrscr; textcolor (white); textbackground(green+3); output << "SEJA BEM VINDO "; textbackground(blue); output << upcasestr(mais) << NL; textbackground(green); gotoxy(1,2); output << " A L I N H A D Ã O P N E U S & A C" << NL; textbackground (black); /*loop de repeticao para voltar ao menu com a flag*/ textbackground (black); textcolor(15); gotoxy (15,4); output << "+-------------------------------------------------+" << NL; gotoxy (15,5); output << "| Digite a Opcao |" << NL; gotoxy (15,6); output << "+-------------------------------------------------+" << NL; gotoxy (15,7); output << "| 1 - Fixa | | 3 - ESTOQUE |" << NL; gotoxy (15,8); output << "+--------------------------------------------------" << NL; gotoxy (15,9); output << "| 2 - Cliente | | 4 - Produtos |" << NL; gotoxy (15,10); output << "+-------------------------------------------------+" << NL; gotoxy (15,11); output << "| Ctrl + C -saida |" << NL; gotoxy (15,12); output << "+-------------------------------------------------+" << NL; gotoxy (1,56); } void amauri() { real dias,venc,quantia,l; integer erika; boolean amor; boolean love; clrscr; textcolor (white); textbackground(green+3); output << "SEJA BEM VINDO "; textbackground(blue); output << upcasestr(mais) << NL; textbackground(green); gotoxy(1,2); output << " A L I N H A D Ã O P N E U S & A C" << NL; /*loop de repeticao para voltar ao menu com a flag*/ textbackground (black); textcolor(15); gotoxy (15,4); output << "+-------------------------------------------------+" << NL; gotoxy (15,5); output << "| Digite a Opcao |" << NL; gotoxy (15,6); output << "+-------------------------------------------------+" << NL; gotoxy (15,7); output << "| 1 - Fixa | | 3 - ESTOQUE |" << NL; gotoxy (15,8); output << "+--------------------------------------------------" << NL; gotoxy (15,9); output << "| 2 - Cliente | | 4 - Produtos |" << NL; gotoxy (15,10); output << "+-------------------------------------------------+" << NL; gotoxy (15,11); output << "| Ctrl + C -saida |" << NL; gotoxy (15,12); output << "+-------------------------------------------------+" << NL; gotoxy (15,13); while (! (amor || love)) if (keypressed()) \\ Se o usuário pressionou uma tecla (keypressed = TRUE), { \\ é preciso agir de acordo com o comando correspondente. switch (upcase(readkey())) { case '': switch (readkey()) { case '\113': { \\ seta para esquerda K textcolor (white); gotoxy (48,7); output << "ESTOQUE"; gotoxy (48,9); output << "Produtos"; gotoxy (23,9); output << "Cliente"; textcolor (blue+4); gotoxy (23,7); output << "Fixa "; erika=1; } break; case '\115': { \\ seta para direita M textcolor (white); gotoxy (23,7); output << "Fixa "; gotoxy (48,9); output << "Produtos"; gotoxy (23,9); output << "Cliente"; gotoxy (48,7); textcolor (blue+4); output << "ESTOQUE "; erika=3; } break; case '\120': { \\80 P textcolor (white); gotoxy (23,7); output << "Fixa "; gotoxy (23,9); output << "Cliente"; gotoxy (48,7); output << "ESTOQUE"; gotoxy (48,9); textcolor (blue+4); output << "Produtos "; erika=4; } break; case '\73': { /*quit := TRUE; // [esc] */ clrscr; { gotoxy (5,5); output << "Qual o Salario do funcionario ? "; input >> venc >> NL; } quantia=30; { gotoxy (5,5); output << "Quantos Dias o funcionario Falto ? "; input >> dias >> NL; } l=quantia-dias; gotoxy (5,5); output << "O Salario total do Funcionario " << NL; textcolor (lightred); output << " é R$ " << venc/quantia*l << NL; gotoxy (12,6); output << " "; } break; case '\110': { \\ seta para Cima textcolor (white); gotoxy (23,7); output << "Fixa "; gotoxy (48,9); output << "Produtos"; gotoxy (48,7); output << "ESTOQUE"; textcolor (blue+4); gotoxy (23,9); output << "Cliente"; erika=2; } break; } break; case '\15': { \\ [enter] switch (erika) { case 1: gravar(); break; case 2: leitura(); break; case 3: mestre(); break; case 4: alterar(); break; } } break; } } } int main(int argc, const char* argv[]) { pio_initialize(argc, argv); textbackground(black); clrscr; gotoxy(1,1); textcolor (white); textbackground(red); output << " A M A U R I - INFORMATICA ATIBAIA " << NL; gotoxy(68,1); textbackground(black); output << " " << NL; gotoxy(1,2); output << " " << NL; gotoxy(1,3); output << " " << NL; gotoxy(1,4); output << " " << NL; gotoxy(1,4); output << " " << NL; gotoxy(1,5); output << " " << NL; gotoxy( 67,5 ); textcolor(white); output << '\334' << '\334' << '\334' << '\334' << NL; gotoxy( 71,5 ); output << " " << NL; gotoxy( 71,6 );/*VIDEO 2 DO ALINHADÃO*/ output << '\\' << NL; gotoxy( 72,6 ); output << " " << NL; output << " " << '\334' << '\334' << '\334' << '\334' << '\334' << "\\ " << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << NL; output << ' ' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << NL; output << ' ' << '\334' << '\334' << "\\ " << '\334' << '\334' << "\\ " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << "\\ " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << " " << '\334' << '\334' << NL; output << ' ' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << '\334' << '\334' << ' ' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << "\\ " << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << " " << '\334' << '\334' << NL; output << ' ' << '\334' << '\334' << "\\ " << '\334' << '\334' << "\\ " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << "\\ " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << " " << '\334' << '\334' << NL; output << ' ' << '\334' << '\334' << "\\ " << '\334' << '\334' << "\\ " << '\334' << '\334' << '\\' << '\334' << '\334' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << "\\ " << '\334' << '\334' << " " << '\334' << '\334' << '\\' << " " << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << '\\' << " " << '\334' << '\334' << '\\' << ' ' << '\334' << '\334' << " " << '\334' << '\334' << NL; output << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << '\\' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << ' ' << '\334' << '\334' << '\334' << '\334' << " " << '\334' << '\334' << '\334' << '\334' << '\334' << NL; output << " " << NL; output << " " << NL; gotoxy (1,16); output << " " << NL; gotoxy (33,17); output << "P N E U S"; gotoxy (1,18); output << " " << NL; gotoxy (1,19); output << " " << NL; gotoxy (30,20); output << "Versão: 1.1.4 -1"; gotoxy (1,20); output << " " << NL; gotoxy (49,20); output << " "; gotoxy (1,21); output << " " << NL; gotoxy (1,22); output << " " << NL; gotoxy (1,23); output << ' '; gotoxy (2,23); textbackground (lightgray + black); textcolor (black); output << " Usuário[ ] "; textbackground (black); gotoxy (4,24); output << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333'; gotoxy (12,23); input >> usuario; mais=usuario; gotoxy (47,23); textbackground (lightgray + black); textcolor (black); output << " Senha: [ ][ ] "; gotoxy (49,24); output << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333' << '\333'; gotoxy (66,23); input >> s; { if (s!="AMAURI") output << "=> Você digitou uma Senha Erro!" << NL; else p='a'; output << "Correto!" << NL; } { if (s!="amauri") output << "=> Você digitou uma Senha Erro!" << NL; else p='a'; output << "Correto!" << NL; } switch (p) { /*SENHA CORRETA TELA MENU*/ case 'a' : { amauri(); } break; default: { clrscr; textcolor(lightred); output << ' ' << NL; output << ' ' << NL; output << ' ' << NL; output << ' ' << NL; output << " " << '\311' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\273' << NL; output << " " << '\272' << " ESTA COPIA DE PROGRAMA NÃO FOI AUTORIZADA " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " PASSWORD INVALIDO! " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " " << '\272' << NL; output << " " << '\272' << " EMAIL amauri_long@yahoo.com.br " << '\272' << NL; output << " " << '\272' << " TEL (11) 4411-9384 ou CEL (11) XXXX_XXXX " << '\272' << NL; output << " " << '\310' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\315' << '\274' << NL; tempo=9; while (tempo!=0) { delay (1000); gotoxy (30,12); output << "ACESSO NEGADO " << tempo << NL; tempo = tempo - 1; } gotoxy (25,18); output << " Pressione [ENTER] para sair . . ."; } } poi = upcase(readkey()); return EXIT_SUCCESS; } Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 Jonathan Queiroz Postado Agosto 25, 2009 Denunciar Share Postado Agosto 25, 2009 Qual a dúvida ?Sempre que possível, poste um código reduzido que demonstre o problema.Só poste o código completo caso não seja possível resumí-lo ou não saiba exatamente qual o problema.No caso de dúvidas sobre a utilização de algum recurso da linguagem, você pode criar um script para demonstrar isso. Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 #include Postado Agosto 25, 2009 Autor Denunciar Share Postado Agosto 25, 2009 (editado) Como possso compila no Dev-C++ r ? a biblioteca declarada delay e #include "conio.h" o nome é :c:\Dev-CppPortable\App\devcpp\include\ptoc.c ou no bloco de nota salva com este nome ptoc.c para pode declarar delay(1); e clrscr; textcolor(15); textbackground(0); gotoxy(1,1); copie isto e cole no bloco de notas com o nome ptoc.c /* Implementado com pascal * para Miguel/Dev-C++. * * Versión 2.0 Julho de 2009 (br <amauri_long@yahoo.com.br>) * Se adapta el código a ANSI C (la versión anterior contiene * muchos errores debido al uso de características C++). */#include <stdio.h>#include <ctime>#include <stdlib.h>#include <unistd.h>#include <windows.h>#include <string.h>#include <stdarg.h>#include "conio.h"#include <cstdlib>#include <iostream>#ifdef __cplusplusextern "C" {#endif// Declaramos una estructura text_info para almacenar la información// sobre la ventana actual.text_info vActual = {0, 0, 79, 24, WHITE, WHITE, C80, 25, 80, 1, 1};// Reads a string from the console.// cgets reads a string of characters from the console, storing the string // (and the string length) in the location pointed to by str.// cgets reads characters until it encounters a carriage-return/linefeed // (CR/LF) combination, or until the maximum allowable number of characters // have been read. If cgets reads a CR/LF combination, it replaces the // combination with a (null terminator) before storing the string.// Before cgets is called, set str[0] to the maximum length of the string to // be read. On return, str[1] is set to the number of characters actually // read. The characters read start at str[2] and end with a null terminator. // Thus, str must be at least str[0] plus 2 bytes long.char *cgets(char *str){ DWORD longitud = 0; DWORD leidos, modo; GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &modo); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo & !ENABLE_ECHO_INPUT); do { ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &str[2+longitud], 1, &leidos, NULL); if(str[2+longitud] != '\r') putch(str[2+longitud++]); } while(longitud < str[0] && str[2+longitud] != '\r'); str[1] = longitud; str[2+longitud] = 0; SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo); return &str[2]; }void delay(int seconds) { clock_t current, end; current = clock(); end = current + CLOCKS_PER_SEC * seconds; while(current < end) current = clock(); // loop while current not equal end }// Clears to end of line in text window.// clreol clears all characters from the cursor position to the end of the // line within the current text window, without moving the cursor.// Borrar hasta el final de la línea requiere borrar tanto los caracteres// como los atributos.void clreol (){ COORD coord; DWORD escrito; coord.X = vActual.winleft+vActual.curx-1; coord.Y = vActual.wintop+vActual.cury-1; FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), ' ', vActual.screenwidth - vActual.curx + 1, coord, &escrito); FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), vActual.attribute, vActual.screenwidth - vActual.curx + 1, coord, &escrito); gotoxy(vActual.curx, vActual.cury);}// Clears the text-mode window.// clrscr clears the current text window and places the cursor in the upper // left corner (at position 1,1). // La consola en algunos sistemas operativos no está limitada a 80*25// caracteres, como en MSDOS, obtenemos el tamanãoo actual de la consola y la // borramos entera, usando los valores de atributos actuales.void clrscr (){ DWORD escrito; int i; for( i = 0; i < vActual.screenheight; i++) { FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), vActual.attribute, vActual.screenwidth, (COORD) {vActual.winleft, vActual.wintop+i}, &escrito); FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), ' ', vActual.screenwidth, (COORD) {vActual.winleft, vActual.wintop+i}, &escrito); } gotoxy(vActual.curx, vActual.cury);}// Writes formatted output to the screen.// cprintf accepts a series of arguments, applies to each a format specifier // contained in the format string pointed to by format, and outputs the // formatted data directly to the current text window on the screen. There // must be the same number of format specifiers as arguments. // For details details on format specifiers, see printf Format Specifiers.// The string is written either directly to screen memory or by way of a // BIOS call, depending on the value of the global variable _directvideo.// Unlike fprintf and printf, cprintf does not translate linefeed characters // (\n) into carriage-return/linefeed character pairs (\r\n). Tab characters // (specified by \t) are not expanded into spaces.int cprintf(const char *format, ...){ // char *buffer; // this is not "c" (this is c++). char buffer[1024] = { 0 }; va_list p; int n; // buffer = new char[1024]; // this is not "c" (this is c++). // buffer = (char *)malloc(1024); va_start(p, format); n = vsprintf(buffer, format, p); cputs(buffer); // delete[] buffer; // this is not "c" (this is c++). // free( buffer ); // usar si buffer = malloc return n;}// Writes a string to the screen.// cputs writes the null-terminated string str to the current text // window. It does not append a newline character.// The string is written either directly to screen memory or by way of a // BIOS call, depending on the value of the global variable _directvideo. // Unlike puts, cputs does not translate linefeed characters (\n) into // carriage-return/linefeed character pairs (\r\n).int cputs(const char *str) // repasar{ DWORD escritos; int n = 0; int resto = vActual.screenwidth-vActual.curx+1; do { if(strlen(&str[n]) < resto) resto = strlen(&str[n]); gotoxy(vActual.curx, vActual.cury); WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), &str[n], resto, &escritos, NULL); n+=resto; vActual.curx+=resto; if(vActual.curx > vActual.screenwidth) { vActual.curx -= vActual.screenwidth; resto = vActual.screenwidth-vActual.curx+1; vActual.cury++; resto = vActual.screenwidth; if(vActual.cury > vActual.screenheight) { vActual.cury--; movetext(1, 2, vActual.screenwidth, vActual.screenheight, 1, 1); } } } while(str[n]); return strlen(str);}// Scans and formats input from the console.// cscanf scans a series of input fields one character at a time, reading // directly from the console. Then each field is formatted according to a // format specifier passed to cscanf in the format string pointed to by format.// Finally, cscanf stores the formatted input at an address passed to it as // an argument following format, and echoes the input directly to the screen. // There must be the same number of format specifiers and addresses as there // are input fields. // Note: For details on format specifiers, see scanf Format Specifiers.// cscanf might stop scanning a particular field before it reaches the normal // end-of-field (whitespace) character, or it might terminate entirely for a // number of reasons. See scanf for a discussion of possible causes./*int cscanf(char *format, ...){ char *buffer; va_list p; int n; DWORD leidos; buffer = new char[260]; buffer[0] = 255; cgets(buffer); va_start(p, format); printf("#%s#%s#\n", &buffer[2], format); n = sscanf(&buffer[2], format, p); delete[] buffer; return n;}*/// Deletes line in text window.// delline deletes the line containing the cursor and moves all lines below // it one line up. delline operates within the currently active text window.void delline(){ COORD coord; SMALL_RECT origen; SMALL_RECT clip; CHAR_INFO ci; origen.Left = vActual.winleft; origen.Top = vActual.wintop+vActual.cury; origen.Right = vActual.winright; origen.Bottom = vActual.winbottom; coord.X = vActual.winleft; coord.Y = vActual.wintop+vActual.cury-1; clip.Left = vActual.winleft; clip.Top = vActual.wintop; clip.Right = vActual.winright; clip.Bottom = vActual.winbottom; ci.Char.AsciiChar = ' '; ci.Attributes = vActual.attribute; ScrollConsoleScreenBuffer(GetStdHandle(STD_OUTPUT_HANDLE), &origen, &clip, coord, &ci); vActual.curx = 1; gotoxy(vActual.curx, vActual.cury);}// Gets character from keyboard, does not echo to screen.// getch reads a single character directly from the keyboard, without // echoing to the screen.int getch(void){ int car; DWORD leidos, modo; GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &modo); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo & !ENABLE_ECHO_INPUT & !ENABLE_PROCESSED_INPUT); ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &car, 1, &leidos, NULL); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo); return car; }// Gets character from the keyboard, echoes to screen.// getche reads a single character from the keyboard and echoes it to the // current text window using direct video or BIOS.int getche(void){ int car; DWORD leidos, modo; GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &modo); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo & !ENABLE_ECHO_INPUT & !ENABLE_PROCESSED_INPUT); ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &car, 1, &leidos, NULL); putch(car); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo); return car; }// Reads a password.// getpass reads a password from the system console after prompting with // the null-terminated string prompt and disabling the echo. A pointer is // returned to a null-terminated string of up to eight characters (not // counting the null-terminator).char *getpass(const char *prompt){ static char pass[9]; DWORD longitud = 0; DWORD leidos, modo; cputs(prompt); GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &modo); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo & !ENABLE_ECHO_INPUT); do { ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &pass[longitud], 1, &leidos, NULL); if(pass[longitud] != '\r') longitud++; } while(longitud < 8 && pass[longitud] != '\r'); pass[longitud] = 0; SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), modo); return pass; }// Copies text from text mode screen to memory.// gettext stores the contents of an onscreen text rectangle defined by left, // top, right, and bottom into the area of memory pointed to by destin.// All coordinates are absolute screen coordinates not window-relative. The // upper left corner is (1,1). gettext reads the contents of the rectangle // into memory sequentially from left to right and top to bottom.// Each position onscreen takes 2 bytes of memory: The first byte is the // character in the cell and the second is the cell's video attribute. The // space required for a rectangle w columns wide by h rows high is defined as // bytes = (h rows) x (w columns) x 2int _gettext(int left, int top, int right, int bottom, void *destin){ PCHAR_INFO buffer; char *pantalla = (char *)destin; int retval,i; COORD cSize = {1+right-left, 1+bottom-top}; COORD cDest = {0,0}; SMALL_RECT rect = {vActual.winleft+left-1, vActual.wintop+top-1, vActual.winleft+right-1, vActual.wintop+bottom-1}; // buffer = new CHAR_INFO[cSize.X * cSize.Y]; buffer = (PCHAR_INFO)malloc(cSize.X*cSize.Y*sizeof(CHAR_INFO)); retval = ReadConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE), buffer, cSize, cDest, &rect); for( i = 0; i < cSize.X * cSize.Y; i++) { pantalla[2*i] = buffer[i].Char.AsciiChar; pantalla[2*i + 1] = buffer[i].Attributes & 0xff; } // delete[] buffer; free( buffer ); return retval;}// Gets text mode video information.// gettextinfo fills in the text_info structure pointed to by r with the // current text video information.void gettextinfo(struct text_info *r){ CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); *r = vActual;}// Positions cursor in text window.// gotoxy moves the cursor to the given position in the current text window. // If the coordinates are in any way invalid the call to gotoxy is ignored. // An example of this is a call to gotoxy(40,30) when (35,25) is the bottom // right position in the window. Neither argument to gotoxy can be zero.void gotoxy(int x, int y){ COORD c; if(x < 1 || x > vActual.screenwidth || y < 1 || y > vActual.screenheight) return; vActual.curx = x; vActual.cury = y; c.X = vActual.winleft + x - 1; c.Y = vActual.wintop + y - 1; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);}// Selects high-intensity characters.// highvideo selects high-intensity characters by setting the high-intensity // bit of the currently selected foreground color.// This function does not affect any characters currently onscreen, but does // affect those displayed by functions (such as cprintf) that perform direct // video, text mode output after highvideo is called.void highvideo(void){ vActual.attribute |= FOREGROUND_INTENSITY; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), vActual.attribute);}// Funciones no permitidas en Windows://inp//inport//inportb//inpw// Inserts a blank line in the text window.// insline inserts an empty line in the text window at the cursor position // using the current text background color. All lines below the empty one move // down one line, and the bottom line scrolls off the bottom of the window.void insline(void){ COORD coord; SMALL_RECT origen; SMALL_RECT clip; CHAR_INFO ci; origen.Left = vActual.winleft; origen.Top = vActual.wintop+vActual.cury-1; origen.Right = vActual.winright; origen.Bottom = vActual.winbottom; coord.X = vActual.winleft; coord.Y = vActual.wintop+vActual.cury; clip.Left = vActual.winleft; clip.Top = vActual.wintop; clip.Right = vActual.winright; clip.Bottom = vActual.winbottom; ci.Char.AsciiChar = ' '; ci.Attributes = vActual.attribute; ScrollConsoleScreenBuffer(GetStdHandle(STD_OUTPUT_HANDLE), &origen, &clip, coord, &ci); vActual.curx = 1; gotoxy(vActual.curx, vActual.cury);}// Checks for currently available keystrokes.// kbhit checks to see if a keystroke is currently available. Any available // keystrokes can be retrieved with getch or getche.int kbhit(void){ DWORD nEventos; INPUT_RECORD *eventos; DWORD leidos; int retval = 0; int i; GetNumberOfConsoleInputEvents(GetStdHandle(STD_INPUT_HANDLE), &nEventos); // eventos = new INPUT_RECORD[nEventos]; eventos = (INPUT_RECORD *)malloc(nEventos*sizeof(INPUT_RECORD)); PeekConsoleInput(GetStdHandle(STD_INPUT_HANDLE), eventos, nEventos, &leidos); for(i = 0; i < nEventos; i++) if(eventos[i].EventType == KEY_EVENT && eventos[i].Event.KeyEvent.bKeyDown) retval = 1; // delete[] eventos; free( eventos ); return retval;}// Selects low-intensity characters.// lowvideo selects low-intensity characters by clearing the high-intensity // bit of the currently selected foreground color.// This function does not affect any characters currently onscreen. It affects // only those characters displayed by functions that perform text mode, direct // console output after this function is called.void lowvideo(void){ vActual.attribute &= ~FOREGROUND_INTENSITY; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), vActual.attribute);}// Copies text onscreen from one rectangle to another.// movetext copies the contents of the onscreen rectangle defined by left, // top, right, and bottom to a new rectangle of the same dimensions. The new // rectangle's upper left corner is position (destleft, desttop).// All coordinates are absolute screen coordinates. Rectangles that overlap // are moved correctly.// movetext is a text mode function performing direct video output.int movetext(int left, int top, int right, int bottom, int destleft, int desttop){ COORD coord; SMALL_RECT origen; CHAR_INFO ci; origen.Left = vActual.winleft+left-1; origen.Top = vActual.wintop+top-1; origen.Right = vActual.winleft+right-1; origen.Bottom = vActual.wintop+bottom-1; coord.X = vActual.winleft+destleft-1; coord.Y = vActual.wintop+desttop-1; ci.Char.AsciiChar = ' '; ci.Attributes = vActual.attribute; ScrollConsoleScreenBuffer(GetStdHandle(STD_OUTPUT_HANDLE), &origen, NULL, coord, &ci); return 0;}// Selects normal-intensity characters.// normvideo selects normal characters by returning the text attribute // (foreground and background) to the value it had when the program started.// This function does not affect any characters currently on the screen, only // those displayed by functions (such as cprintf) performing direct console // output functions after normvideo is called.void normvideo(void){ vActual.attribute = vActual.normattr; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), vActual.attribute);}// Funciones no permitidas en Windows://outp//outport//outportb//outpw// Outputs character to screen.// putch outputs the character c to the current text window. It is a text mode // function performing direct video output to the console. putch does not // translate linefeed characters (\n) into carriage-return/linefeed pairs.// The string is written either directly to screen memory or by way of a BIOS // call, depending on the value of the global variable _directvideo.int putch(int c){ DWORD escritos; gotoxy(vActual.curx, vActual.cury); WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), (char*)&c, 1, &escritos, NULL); vActual.curx++; if(vActual.curx > vActual.screenwidth) { vActual.curx -= vActual.screenwidth; vActual.cury++; if(vActual.cury > vActual.screenheight) { vActual.cury--; movetext(1, 2, vActual.screenwidth, vActual.screenheight, 1, 1); } } return 0;}// Copies text from memory to the text mode screen.// puttext writes the contents of the memory area pointed to by source out to // the onscreen rectangle defined by left, top, right, and bottom.// All coordinates are absolute screen coordinates, not window-relative. The // upper left corner is (1,1).// puttext places the contents of a memory area into the defined rectangle // sequentially from left to right and top to bottom.// Each position onscreen takes 2 bytes of memory: The first byte is the // character in the cell, and the second is the cell's video attribute. The // space required for a rectangle w columns wide by h rows high is defined as// bytes = (h rows) x (w columns) x 2// puttext is a text mode function performing direct video output.int puttext(int left, int top, int right, int bottom, void *source){ PCHAR_INFO buffer; char *pantalla = (char *)source; int retval,i; COORD cSize = {1+right-left, 1+bottom-top}; COORD cDest = {0,0}; SMALL_RECT rect = {vActual.winleft+left-1, vActual.wintop+top-1, vActual.winleft+right-1, vActual.wintop+bottom-1}; // buffer = new CHAR_INFO[cSize.X * cSize.Y]; buffer = (PCHAR_INFO)malloc(sizeof(CHAR_INFO)*cSize.X * cSize.Y); for( i = 0; i < cSize.X * cSize.Y; i++) { buffer[i].Char.AsciiChar = pantalla[2*i]; buffer[i].Attributes = (WORD)pantalla[2*i + 1]; } retval = WriteConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE), buffer, cSize, cDest, &rect); // delete[] buffer; free(buffer); return retval;}// Selects cursor appearance.// Sets the cursor type to//// _NOCURSOR Turns off the cursor// _NORMALCURSOR Normal underscore cursor// _SOLIDCURSOR Solid block cursorvoid _setcursortype(int cur_t){ CONSOLE_CURSOR_INFO cci; switch(cur_t) { case _NOCURSOR: cci.dwSize = 100; cci.bVisible = FALSE; break; case _SOLIDCURSOR: cci.dwSize = 100; cci.bVisible = TRUE; break; case _NORMALCURSOR: cci.dwSize = 10; cci.bVisible = TRUE; break; } SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);}// Sets text attributes.// textattr lets you set both the foreground and background colors in a // single call. (Normally, you set the attributes with textcolor and // textbackground.)// This function does not affect any characters currently onscreen; it affects // only those characters displayed by functions (such as cprintf) performing // text mode, direct video output after this function is called.// Windows no permite colores parpadeantes (BLINK), en su lugar es posible// usar 16 colores para el fondo, en lugar de los 8 de DOSvoid textattr(int newattr){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), newattr); vActual.attribute = newattr;}// Selects new text background color.// textbackground selects the background color. This function works for // functions that produce output in text mode directly to the screen. // newcolor selects the new background color. You can set newcolor to an // integer from 0 to 7, or to one of the symbolic constants defined in // conio.h. If you use symbolic constants, you must include conio.h.// Once you have called textbackground, all subsequent functions using direct // video output (such as cprintf) will use newcolor. textbackground does not // affect any characters currently onscreen.// En windows se permiten colores del 0 al 15 para el fondo.void textbackground(int newcolor){ CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (csbi.wAttributes & 0x0f) | (newcolor << 4)); vActual.attribute = (csbi.wAttributes & 0x0f) | (newcolor << 4);}// Selects new character color in text mode.// textcolor selects the foreground character color. This function works for // the console output functions. newcolor selects the new foreground color. // You can set newcolor to an integer as given in the table below, or to one // of the symbolic constants defined in conio.h. If you use symbolic constants, // you must include conio.h.// Once you have called textcolor, all subsequent functions using direct video // output (such as cprintf) will use newcolor. textcolor does not affect any // characters currently onscreen.void textcolor(int newcolor){ CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (csbi.wAttributes & 0xf0) | newcolor); vActual.attribute = (csbi.wAttributes & 0xf0) | newcolor;}// Puts screen in text mode.void textmode(int newmode){}// Pushes a character back to the keyboard buffer.// ungetch pushes the character ch back to the console, causing ch to be the // next character read. The ungetch function fails if it is called more than // once before the next read.int ungetch(int ch){ INPUT_RECORD ir[2]; DWORD escritos; ir[0].EventType = KEY_EVENT; ir[0].Event.KeyEvent.bKeyDown = TRUE; ir[0].Event.KeyEvent.wRepeatCount = 1; ir[0].Event.KeyEvent.wVirtualKeyCode = 0; ir[0].Event.KeyEvent.wVirtualScanCode = 0; ir[0].Event.KeyEvent.uChar.AsciiChar = ch; ir[0].Event.KeyEvent.dwControlKeyState = 0; ir[1].EventType = KEY_EVENT; ir[1].Event.KeyEvent.bKeyDown = FALSE; ir[1].Event.KeyEvent.wRepeatCount = 1; ir[1].Event.KeyEvent.wVirtualKeyCode = 0; ir[1].Event.KeyEvent.wVirtualScanCode = 0; ir[1].Event.KeyEvent.uChar.AsciiChar = ch; ir[1].Event.KeyEvent.dwControlKeyState = 0; if(WriteConsoleInput(GetStdHandle(STD_INPUT_HANDLE), ir, 2, &escritos)) return ch; return EOF; }// Gives horizontal cursor position within window.// wherex returns the x-coordinate of the current cursor position (within the // current text window).int wherex(void){ return vActual.curx;}// Gives vertical cursor position within window.// wherey returns the y-coordinate of the current cursor position (within the // current text window).int wherey(void){ return vActual.cury;}// Defines active text mode window.// window defines a text window onscreen. If the coordinates are in any way // invalid, the call to window is ignored.// left and top are the screen coordinates of the upper left corner of the // window.// right and bottom are the screen coordinates of the lower right corner.// The minimum size of the text window is one column by one line. The default // window is full screen, with the coordinates:// 1,1,C,R// where C is the number of columns in the current video mode, and R is the // number of rows.void window(int left, int top, int right, int bottom){ vActual.winleft = left-1; vActual.wintop = top-1; vActual.winright = right-1; vActual.winbottom = bottom-1; vActual.screenheight = 1+bottom-top; vActual.screenwidth = 1+right-left; vActual.curx = 1; vActual.cury = 1; clrscr();}#ifdef __cplusplus}#endif Editado Agosto 26, 2009 por #include Adcionar tag's (Jonathan) Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
#include
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.