1. <code id="ya7qu"><span id="ya7qu"><label id="ya7qu"></label></span></code>

    <b id="ya7qu"><bdo id="ya7qu"></bdo></b>
    <wbr id="ya7qu"><optgroup id="ya7qu"><strike id="ya7qu"></strike></optgroup></wbr>
  2. <u id="ya7qu"><bdo id="ya7qu"></bdo></u>
    現(xiàn)在位置:范文先生網(wǎng)>理工論文>計(jì)算機(jī)論文>用C語言實(shí)現(xiàn)按鈕新技術(shù)

    用C語言實(shí)現(xiàn)按鈕新技術(shù)

    時(shí)間:2023-02-20 22:50:13 計(jì)算機(jī)論文 我要投稿
    • 相關(guān)推薦

    用C語言實(shí)現(xiàn)按鈕新技術(shù)

       一、按鈕顯示原理
    按鈕一般有按下和彈起兩種狀態(tài),在3D studio中按鈕也有這兩種狀態(tài),Windows中雖然看到按鈕雖是彈起的,但細(xì)心的用戶不難發(fā)現(xiàn),當(dāng)選中按鈕時(shí),它有短暫的按下狀態(tài)。實(shí)際上,它的原理很簡單,其實(shí)是利用改變按鈕邊框的顏色引起人視覺上的錯(cuò)覺而達(dá)到立體效果,讓人們感到屏幕上真有凸起和凹下的按鈕一樣,如下圖:
    @@T5S11500.GIF;圖1@@
    圖1和圖2給出了按鈕兩種狀態(tài)和圖示,圖1為按鈕彈起時(shí)的狀態(tài)圖,其右邊及下邊的邊框色為黑色(0X00),而左邊及上邊的邊框顏色置為亮白(0x0f),而圖2則恰恰相反,右邊及下邊的邊框色為亮白,左邊及上邊為黑色,它反映了按鈕被按下的狀態(tài)。
    在程序應(yīng)用中,設(shè)置某一按鈕時(shí),顯示圖1的狀態(tài),再選中這個(gè)按鈕時(shí),則顯示出圖2的狀態(tài),經(jīng)過短暫的延時(shí)后,恢復(fù)到圖1的狀態(tài),給用戶的感覺是按鈕被按下后又彈起。在Windows中的按鈕就是這樣的,3D studio中的部分按鈕當(dāng)被選中時(shí),只顯示圖2,這時(shí)用戶可以很清晰地看到凹下的按鈕。
    二、程序?qū)崿F(xiàn)
    主要包括按鈕結(jié)構(gòu)的意義和與它有關(guān)的幾個(gè)函數(shù)。
    1.結(jié)構(gòu)定義typedef struet Button Def{
    short X1;
    short Y1;
    short X2;
    short Y1;
    } button
    (X1,Y1)和(X2,Y2)分別為按鈕左上角和右下角的位置坐標(biāo),用于確定按鈕的位置和大小。
    為了程序需要,須定義幾個(gè)常用的量。
    #define START-X bt→X1
    #define START-Y bt→Y1
    #define END-X bt→X2
    #define END-Y bt→Y2
    #define Grap 1(Grap為按鈕邊框的寬度)
    #define Button White 0x0f
    #define Button Black 0x00
    2.函數(shù)定義
    (1)void Button Define(button *bt,Short X1,Short Y,short X2,short Y2)該函數(shù)用于定義一個(gè)名為bt的按鈕的大小和位置,其左上角及右下角坐標(biāo)為(X1,Y1),(X2,Y2)。
    START-X=X1;
    START-Y=Y1;
    END-X=X2;
    END-Y=Y2;
    (2)Void Release Button(button *bt)
    該函數(shù)顯示按鈕彈起時(shí)的狀態(tài)。
    (3)Put Down Button(button *bt)該函數(shù)顯示按鈕按下時(shí)的狀態(tài)。
    下面列出了以上函數(shù)用于定義按鈕,顯示按鈕彈起,按下狀態(tài)的程序,這個(gè)程序在屏幕上顯示7個(gè)按鈕,按下1~7個(gè)數(shù)字后就彈起某個(gè)按鈕,非常方便,需要彈起某個(gè)數(shù)字就按哪個(gè)數(shù)字,特別需要指出的是,當(dāng)Gsap大一些時(shí),每個(gè)按鈕,就如同鍵盤上的鍵一樣,立體感很強(qiáng),有興趣的讀者可以實(shí)踐操作一下,并把這種簡明易懂的技術(shù)用之于工作,以提高工作效率。
    button.c
    #include<graphics.h>
    #include<conio.h>
    #include<alloc.h>
    #include<stdio.h>
    #include<process.h>
    #include"button.h"
    #define START-X bt->x1
    #define START-Y bt->y1
    #define END-X bt->x2
    #define END-Y bt->y2
    #define Grap 1
    #defile ScreenBkColor 2
    #define release-color 7
    #define put-color 3
    #define ButtonWhite 0x0f
    #define ButtonBlack 0x00
    #define delay 50000
    #define dis 10
    void ButtonDefine (button *bt.shout.short.short.short);
    void ReleaseButton(button *bt);
    void PutDownButton(button *bt);
    void delay-time(long int);
    main()
    {
    int gdriver=DETECT.gmode=VGAHI:
    button *but,*but1.*but2. *bt,*but3,*but4,*but5,*but6,*but7;
    int ch;
    initgraph(&gdriver,&gmode,"d:\tc");
    setcolor(ScreenBkColor);
    setbkcolor(2);
    clrscr();
    ButtonDefine(but,50,50,600,400);
    putDownButton(but);
    ButtonDefine(but1,150,200,200,250);
    ButtonDefine(but2,200+dis,200,250+dis,250);
    ButtonDefine(but3,250+2*dis,200,300+2*dis,250);
    ButtonDefine(but4,300+3*dis,200,350+3*dis,250);
    ButtonDefine(but5,350+4*dis,200,400+4*dis,250);
    ButtonDefine(but6,400+5*dis,200,450+5*dis,250);
    ButtonDefine(but7,450+6*dis,200,500+6*dis,250);
    while(ch!=27)
    {
    switch(ch) }
    case'1':
    ReleaseButton(but1);break;
    case'2':
    ReleaseButton(but2);break;
    case'3':
    ReleaseButton(but3);break;
    case'4':
    ReleaseButton(but4);break;
    case'5':
    ReleaseButton(but5);break;
    case'6':
    ReleaseButton(but6);break;
    case'7':
    ReleaseButton(but7);break;
    }
    ch=getch();
    if(ch==27)
    break;
    switch(ch)
    {
    case'1':
    P

    utDownButton(but1);break;
    case'2':
    PutDownButton(but2);break;
    case'3':
    PutDownButton(but3);break;
    case'4':
    PutDownButton(but4);break;
    case'5':
    PutDownButton(but5);break;
    case'6':
    PutDownButton(but6);break;
    case'7':
    PutDownButton(but7);break;
    }
    delay-time(delay);
    }
    closegraph():
    return 0;
    }
    void ButtonDefine(button *bt.short x1,short y1,short x2,short y2)
    {
    START-X=x1;
    START-Y=y1;
    END-X=x2;
    END-Y=y2;
    }
    void ReleaseButton(button *bt)
    {
    int i,j;
    setcolor(7);
    setfillstyle(1,7);
    bar(START-X,START-Y,END-X,END-Y);
    setcolor(Button White);
    setfillstyle(1,7);
    bar(START-X+Grap,START-Y+Grap,END-X-Grap,END-Y-Grap);
    setcolor(15);
    for(j=0;j<=Grap;j++)
    {
    line(START-X,j+START-Y,END-X-j,j+STAT-Y);
    }
    for(i=0,i<=Grap;j++)
    {
    line(START-X+i,START-Y+Grap,START-X+i,END-Y-i);
    }
    setcolor(ButtonBlack);
    for(j=0;j<Grap;j++)
    }
    line(END-X,j+END-Y-Grap,START-X+Grap-j,j+END-Y-Grap);
    }
    for(i=0,i<Grap;i++)
    {
    line(i+END-X+Grap,END-Y-Grap,i+END+X-Grap,START-Y+Grap-i);
    }
    return;
    }
    void PutDownButton(button *bt)
    }
    int i,j;
    setcolor(put-color);
    setfillstyle(1,put-color);
    bar(START-X+Grap,START-Y+Grap,END-X-Grap,END-Y-Grap);
    setcolor(ButtonBlack);
    for(j=0;j<=Grap;j++)
    {
    line(START-X,j+START-Y,END-X-j,j+START-Y);
    ;}
    for (i=0;i<Garp;i++)
    {
    line (START-X+i,START-Y+Grap,START-X+i,END-Y-i);
    setcolor(15);
    for(j=0,j<=Grap;j++)
    {
    line(END-X,j+END-Y-Grap,START-X+Grap-j,j+END-Y-Grap);
    }
    for(i=0;i<=Grap;i++)
    {
    line(i+END-X-Grap,END-Y-Grap,i+END-X-Grap,START-Y+Grap-i);
    }
    }
    void delay-time(long int i)
    {
    i=0;
    while(i<=delay)
    i++;
    }
    button.h
    typedef struct ButtonDef
    { short x1;
    short y1;
    short x2;
    short y2;
    }button;


    【用C語言實(shí)現(xiàn)按鈕新技術(shù)】相關(guān)文章:

    用C語言實(shí)現(xiàn)CRC校驗(yàn)計(jì)算08-06

    C語言實(shí)現(xiàn)串行通信接口程序08-06

    用Verilog HDL實(shí)現(xiàn)I2C總線功能08-06

    用TMS320C54X實(shí)現(xiàn)Vertibi譯碼器08-06

    用P89C664實(shí)現(xiàn)I2C總線大批量數(shù)據(jù)的自動(dòng)存儲(chǔ)08-06

    用Borland C++3.1實(shí)現(xiàn)外設(shè)與Windows應(yīng)用程序?qū)崟r(shí)通信08-06

    用AT89C2051實(shí)現(xiàn)電話遠(yuǎn)程控制家用電器08-06

    用TL16C752B實(shí)現(xiàn)DSP和PC機(jī)的串行通信08-06

    在C 中實(shí)現(xiàn)JAVA的存儲(chǔ)管理機(jī)制08-09

    国产福利萌白酱精品tv一区_日韩亚洲中字无码一区二区三区_亚洲欧洲高清无码在线_全黄无码免费一级毛片
    1. <code id="ya7qu"><span id="ya7qu"><label id="ya7qu"></label></span></code>

      <b id="ya7qu"><bdo id="ya7qu"></bdo></b>
      <wbr id="ya7qu"><optgroup id="ya7qu"><strike id="ya7qu"></strike></optgroup></wbr>
    2. <u id="ya7qu"><bdo id="ya7qu"></bdo></u>
      中文字幕欧美亚日 | 色婷婷亚洲中文字幕的 | 日本免费线上A∨ | 在线欧美视频一区 | 在线香蕉y亚洲视频 | 亚洲国内精品自在自线国产精品 |