| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 935 人关注过本帖, 1 人收藏
标题:[求助]有难题!!!!有求于大虾们!!!!
只看楼主 加入收藏
lcyyy
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2004-6-9
收藏(1)
 问题点数:0 回复次数:4 
[求助]有难题!!!!有求于大虾们!!!!

用TC写出一个中文窗口式菜单

~~~~~

[此贴子已经被作者于2004-06-12 00:15:59编辑过]

搜索更多相关主题的帖子: 难题 有求于 
2004-06-11 23:49
xyx
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2004-6-9
收藏
得分:0 

回啊,我也想看看答案啊~~谢谢啦~~


我是菜鸟我要拼!!!!!
2004-06-14 22:48
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 

#include "stdio.h" #include "stdlib.h" #include "graphics.h" #include "dos.h"

#define LEFTBTN 1

FILE *fp;

void Quit(); void MainMenu(); void InitGra(void); void PutCC16(int x, int y, int, int Color, char *Str); void PrsBox(int x, int y, int l, int h); void Box(int x, int y, int l, int h); int InitMouse(); void ErrMsg(); void ShowMouse(); void HideMouse(); void ReadMouse(int *f, int *x, int *y); int MsInBox(int x1, int y1, int x2, int y2, int x, int y); void OpenLIB();

int main() { InitGra(); OpenLIB(); MainMenu(); Quit(); return 0; }

void Quit() { closegraph(); fcloseall(); exit(0); }

void MainMenu() { int x1, y1, l, h, x2; int Button, x, y, Choice; char *Tit = "用鼠标选择菜单"; char *Mmu[] = {"绘制新图", "编辑旧图", "图形输出", "退出系统"}; x1 = 190; y1 = 240; x2 = 350; l = 100; h = 32; setfillstyle(1, 7); bar(140, 30, 500, 460); setcolor(14); rectangle(140, 30, 500, 460); setfillstyle(1, 9); bar(215,100, 430,147); PutCC16(250, 116, 4, 15, Tit); Box(x1, y1, l, h); PutCC16(x1+15, y1+8, 2, 1, Mmu[0]);

Box(x2, y1, l, h); PutCC16(x2+15, y1+8, 2, 1, Mmu[1]); Box(x1, y1+100, l, h); PutCC16(x1+15, y1+108, 2, 1, Mmu[2]); Box(x2, y1+100, l, h); PutCC16(x2+15, y1+108, 2, 1, Mmu[3]); if (! InitMouse()) ErrMsg();

ShowMouse(); for (;;) { Button = 0; while (Button != LEFTBTN) ReadMouse(&Button, &x, &y);

HideMouse(); if (MsInBox(x1, y1, x1+l, y1+h, x, y)) { PrsBox(x1, y1, l, h); Choice = 1; break; } if (MsInBox(x2, y1, x2+l, y1+h, x, y)) { PrsBox(x2, y1, l, h); Choice = 2; break; } if (MsInBox(x1, y1+100, x1+l, y1+100+h, x, y)) { PrsBox(x1, y1+100, l, h); Choice = 3; break; } if (MsInBox(x2, y1+100, x2+l, y1+100+h, x, y)) { PrsBox(x2, y1+100, l, h); Choice = 4; break; } } switch(Choice) { case 1: break; case 2: break; case 3: break; case 4: Quit(); } }

void InitGra(void) { int GraphDrive = DETECT, GraphMode; registerbgidriver(EGAVGA_driver); initgraph(&GraphDrive, &GraphMode, ""); }

void PutCC16(int x, int y, int z, int Color, char *Str)

{ unsigned Zcode, Bcode; int i, j, k, Rec; long Len; char Buf[32]; while (*Str)

{ if ((*Str & 0x80) && (*(Str+1) &0x80)) { Zcode = (*Str-0xa1) & 0x07f; /* 区码 */ Bcode = (*(Str+1)-0xa1) & 0x07f; /* 位码 */ Rec = Zcode*94+Bcode; /* 记录号 */ Len = Rec*32L; /* 在字库中位置 */ fseek(fp, Len, SEEK_SET); fread (Buf, 1, 32, fp); /* 32字节 */ for (i = 0; i < 16; i++) for (j = 0; j < 2; j++) for (k = 0; k < 8; k++) if (Buf[i*2+j] >> (7-k) & 1) putpixel(x+j*8+k, y+i, Color); x = x+16+z; Str += 2; } } return; }

void PrsBox(int x, int y, int l, int h) { void *Buf1, *Buf2; Buf1 = malloc(imagesize(x, y, x+l, y+h)); Buf2 = malloc(imagesize(x+4, y+4, x+l-4, y+h-4)); getimage(x, y, x+l, y+h, Buf1); getimage(x+4, y+4, x+l-4, y+h-4, Buf2); setfillstyle(1, 7); bar(x, y, x+l, y+h); putimage(x+4, y+4, Buf2, COPY_PUT); delay(100); putimage(x, y, Buf1, COPY_PUT); delay(100); free(Buf1); free(Buf2); }

void Box(int x, int y, int l, int h) { setcolor(0); rectangle(x-1, y-1, x+l+1, y+h+1); setfillstyle(1, 8); bar(x, y, x+l, y+h); setfillstyle(1, 7); bar(x+2, y+2, x+l-2, y+h-2); setcolor(15); line(x, y, x+l, y); line(x, y, x, y+h); line(x+1, y+1, x+l-1, y+1); line(x+1, y+1, x+1, y+h-1); }

int InitMouse() { union REGS Inr, Outr; Inr.x.ax = 0; int86(0x33, &Inr, &Outr); return Outr.x.ax; }

void ShowMouse() { union REGS Inr; Inr.x.ax = 1; int86(0x33, &Inr, &Inr); }

void HideMouse() { union REGS Inr; Inr.x.ax = 2; int86(0x33, &Inr, &Inr); }

void ReadMouse(int *f, int *x, int *y)

{ union REGS Inr, Outr; Inr.x.ax = 3; int86(0x33, &Inr, &Outr); *f = Outr.x.bx; *x = Outr.x.cx; *y = Outr.x.dx; }

int MsInBox(int x1, int y1, int x2, int y2, int x, int y) { return((x >= x1 && x <= x2 && y >= y1 && y <= y2) ? 1 : 0); }

void OpenLIB()

{ fp = fopen("c:\\ucdos\\hzk16", "rb"); //ucdos hzk16点阵字库放置目录 }

void ErrMsg() { printf("No Mouse Error!"); getch(); Quit(); } 


九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2004-06-14 23:55
xyx
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2004-6-9
收藏
得分:0 
嗯,水平不足,完全不懂,不过楼主没提出问题,我还是过两年再来看吧~~~

我是菜鸟我要拼!!!!!
2004-06-16 10:32
lcyyy
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2004-6-9
收藏
得分:0 

哈,大部分是看不懂的,因为老师出的这道题根本就是超出了我们所学的范围(这可是真话),大部函数都还不知道是什么...............所以.......................

而且这个程序在TC2.0中运行不了,要在TC4.5才可以运行.........


2004-06-16 18:25
快速回复:[求助]有难题!!!!有求于大虾们!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011985 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved