liuweiele 发表于 2010-7-30 21:20:16

## 基于ARM的 多功能科学计算器 (支持多进制四则混合运算,三角函数,统计函数) ##

其它功能后续增加......

liuweiele 发表于 2010-7-30 21:20:55

ADS下的工程源码:

点击此处下载 ourdev_571978.rar(文件大小:151K) (原文件名:Calculator.rar)

liuweiele 发表于 2010-7-30 21:23:24

程序在S3C2450平台运行效果:

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571979.jpg
(原文件名:照片 3030.jpg)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571980.jpg
(原文件名:照片 3031.jpg)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571981.jpg
(原文件名:照片 3032.jpg)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571982.jpg
(原文件名:照片 3033.jpg)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571983.jpg
(原文件名:照片 3034.jpg)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571984.jpg
(原文件名:照片 3035.jpg)

liuweiele 发表于 2010-7-30 21:24:55

在google计算器上的验证结果:

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571987.JPG
(原文件名:图像1.JPG)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571988.JPG
(原文件名:图像2.JPG)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571989.JPG
(原文件名:图像3.JPG)

http://cache.amobbs.com/bbs_upload782111/files_31/ourdev_571990.JPG
(原文件名:图像4.JPG)

esdart 发表于 2010-7-30 21:28:06

wei哥的作品一定要收藏。哈哈。

liuweiele 发表于 2010-7-31 09:37:11

直接输入表达式,计算结果.

eworker 发表于 2010-7-31 09:49:36

用什么操作系统?

liuweiele 发表于 2010-7-31 11:04:08

回复【6楼】eworker
用什么操作系统?
-----------------------------------------------------------------------

业余开发的开放式多进程操作系统

liuweiele 发表于 2010-7-31 21:25:57

新增加的支持角度和弧度三角函数

http://cache.amobbs.com/bbs_upload782111/files_32/ourdev_572187.jpg
(原文件名:照片 3037.jpg)

http://cache.amobbs.com/bbs_upload782111/files_32/ourdev_572188.jpg
(原文件名:照片 3038.jpg)

liuweiele 发表于 2010-8-3 14:43:47

新的UI代码:
/*============================================================================*/

#define        IDC_NULL        0x0000

#define        IDC_0                0x1000
#define        IDC_1                0x1001
#define        IDC_2                0x1002
#define        IDC_3                0x1003
#define        IDC_4                0x1004
#define        IDC_5                0x1005
#define        IDC_6                0x1006
#define        IDC_7                0x1007
#define        IDC_8                0x1008
#define        IDC_9                0x1009
#define        IDC_A                0x100a
#define        IDC_B                0x100b
#define        IDC_C                0x100c
#define        IDC_D                0x100d
#define        IDC_E                0x100e
#define        IDC_F                0x100f

#define        IDC_ADD                0x1100
#define        IDC_SUB                0x1101
#define        IDC_MUL                0x1102
#define        IDC_DIV                0x1103
#define        IDC_DOT                0x1104
#define        IDC_EQU                0x1105
#define        IDC_LBR                0x1106
#define        IDC_BACK        0x1107
#define        IDC_RBR                0x1108
#define        IDC_CLR                0x1109
#define        IDC_XOR                0x110a
#define        IDC_SEM                0x110b
#define        IDC_COM                0x110c


#define        IDC_SIN                0x1200
#define        IDC_ASIN        0x1201
#define        IDC_COS                0x1202
#define        IDC_ACOS        0x1203
#define        IDC_TAN                0x1204
#define        IDC_ATAN        0x1205
#define        IDC_LOG                0x1206
#define        IDC_SQRT        0x1207
#define        IDC_SUM                0x1208
#define        IDC_AVE                0x1209
#define        IDC_SUR                0x120a

#define        IDC_BIN                0x1300
#define        IDC_OCT                0x1301
#define        IDC_DEC                0x1302
#define        IDC_HEX                0x1303

#define        IDC_ANGLE        0x1400
#define        IDC_RADIAN        0x1401

#define        IDC_MODE_GROUP                0x2000
#define        IDC_TRIFUN_GROUP        0x2001


/*============================================================================*/

char        *mode_text={

        "二进制",
        "八进制",
        "十进制",
        "十六进制",
       
};

U16        mode_id={

        IDC_BIN,
        IDC_OCT,
        IDC_DEC,
        IDC_HEX,

};

char        *tri_fun_text={
        "角度",
        "弧度",
};

U16        tri_fun_id={
        IDC_ANGLE,
        IDC_RADIAN,
};

char *btn_text={

        "0",        "1",        "2",        "3",        "%",        "CE",        "sin",        "asin",
        "4",        "5",        "6",        "7",        "/",        "<-",        "cos",        "acos",
        "8",        "9",        "A",        "B",        "*",        "^",        "tan",        "atan",
        "C",        "D",        "E",        "F",        "-",        ";",        "log",        "sum",
        ".",        ",",        "(",        ")",        "+",        "=",        "sqrt",        "ave"
       
};

U16        btn_id={

IDC_0,                IDC_1,                IDC_2,                IDC_3,                IDC_SUR,        IDC_CLR,        IDC_SIN,        IDC_ASIN,
IDC_4,                IDC_5,                IDC_6,                IDC_7,                IDC_DIV,        IDC_BACK,        IDC_COS,        IDC_ACOS,
IDC_8,                IDC_9,                IDC_A,                IDC_B,                IDC_MUL,        IDC_XOR,        IDC_TAN,        IDC_ATAN,
IDC_C,                IDC_D,                IDC_E,                IDC_F,                IDC_SUB,        IDC_SEM,        IDC_LOG,        IDC_SUM,
IDC_DOT,        IDC_COM,        IDC_LBR,        IDC_RBR,        IDC_ADD,        IDC_EQU,        IDC_SQRT,        IDC_AVE,

};



char output,input;

static        RESULT        WinProc(HWND hwnd,U32 msg,WPARAM wParam,LPARAM lParam)
{
        int i,x,y;
        RECT rc,*m_rc;
        char buf;
        ////
       
        switch(msg)
        {
       
                case        MSG_CREATE:
               
                                input        =0;
                                output        =0;
                                jiao                 =TRUE;
                                jin                =10;
                               
                                m_rc        =MemAlloc(sizeof(RECT)*40);
                               
                                GetClientRect(hwnd,&rc);
                               
                                x=4;
                                y=48;
                               
                                CreateWindow("groupbox",hwnd,x,y,rc.dx>>1,44,0,0,IDC_MODE_GROUP,"进制");
                                SetWindowColor(GetWindowItem(hwnd,IDC_MODE_GROUP),RGB(0,0,0),RGB_TRANS,GetWindowBkColor(hwnd));
                               
                                GetMatrixRectangle(m_rc,2,12,(rc.dx>>1)-2*2,44-12,2,2,2,1);
                               
                                for(i=0;i<4;i++)
                                {                                       
                                        CreateWindow("radiobutton",GetWindowItem(hwnd,IDC_MODE_GROUP),m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,0,0,mode_id,mode_text);
       
                                        if(mode_id==IDC_DEC)
                                        {
                                                HWND wnd;
                                               
                                                wnd        =GetWindowItem(hwnd,IDC_MODE_GROUP);
                                                wnd        =GetWindowItem(wnd,IDC_DEC);
                                                SendMessage(wnd,MSG_SETVALUE,1,0);
                                       
                                        }
                                }
                                ////
                               
                                x=(rc.dx>>1)+8;
                               
                                CreateWindow("groupbox",hwnd,x,y,(rc.dx>>1)-8*2,28,0,0,IDC_TRIFUN_GROUP,"三角函数");
                                SetWindowColor(GetWindowItem(hwnd,IDC_TRIFUN_GROUP),RGB(0,0,0),RGB_TRANS,GetWindowBkColor(hwnd));
                               
                                GetMatrixRectangle(m_rc,2,12,(rc.dx>>1)-8*2-2*2,28-12,2,1,2,1);
                                for(i=0;i<2;i++)
                                {
                                        CreateWindow("radiobutton",GetWindowItem(hwnd,IDC_TRIFUN_GROUP),m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,0,0,tri_fun_id,tri_fun_text);
                                        if(tri_fun_id==IDC_ANGLE)
                                        {
                                                HWND wnd;
                                               
                                                wnd        =GetWindowItem(hwnd,IDC_TRIFUN_GROUP);
                                                wnd        =GetWindowItem(wnd,IDC_ANGLE);
                                                SendMessage(wnd,MSG_SETVALUE,1,0);
                                       
                                        }

                                }
                                       
                                ////
                               
                                x=0;
                                y+=48;
                                GetMatrixRectangle(m_rc,x,y,rc.dx,rc.dy-y,8,5,4,4);
                               
                                for(i=0;i<40;i++)
                                {
                                        CreateWindow("button",hwnd,m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,0,0,btn_id,btn_text);
                                       
                                }
                               
                                MemFree(m_rc);
                                break;
                                ////
                               
                case        MSG_COMMAND:
                                {
                                        U16        id,code;
                                        HWND wnd;
                                       
                                        code        =HIWORD(wParam);
                                        id                =LOWORD(wParam);
                                                       
                                        if(code==BN_CLICKED)
                                        {
                                               
                                                switch(id)
                                                {

                                                        case        IDC_BIN:
                                                                        jin        =2;
                                                                        break;
                                                                        ////
                                                        case        IDC_OCT:
                                                                        jin        =8;
                                                                        break;
                                                                        ////
                                                        case        IDC_DEC:
                                                                        jin        =10;                                                       
                                                                        break;
                                                                        ////
                                                        case        IDC_HEX:
                                                                        jin        =16;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_ANGLE:
                                                                        jiao =TRUE;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_RADIAN:
                                                                        jiao =FALSE;
                                                                        break;
                                                                        ////
                                                       
                                                        case        IDC_CLR:
                                                                        input        =0;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_BACK:
                                                                        output        =0;
                                                                        str_back(input);
                                                                        //StrPrintf(output,"%s",input);
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_EQU:
                                                                       
                                                                        OnEql(output,input);
                                                                        break;
                                                                        ////
                                               
                                                        default:
                                                       
                                                                        if(jin==2)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_2:
                                                                                        case        IDC_3:
                                                                                        case        IDC_4:
                                                                                        case        IDC_5:
                                                                                        case        IDC_6:
                                                                                        case        IDC_7:
                                                                                        case        IDC_8:
                                                                                        case        IDC_9:
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowCaption(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==8)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_8:
                                                                                        case        IDC_9:
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowCaption(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==10)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowCaption(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==16)
                                                                        {
                                                                                wnd        =GetWindowItem(hwnd,id);
                                                                                str_add(input,GetWindowCaption(wnd));
                                                                                output        =0;
                                                                                break;
                                                                                /////
                                                                               
                                                                        }
                                                                       
                                                                       
                                                }
                                       
                                               
                                                InvalidateRect(hwnd,0,0);
                                        }
                                }
               
                                break;
                                /////
                               
                case        MSG_PAINT:
                                {
                                        HDC hdc;
                                       
                                       
                                        hdc=BeginPaint(hwnd);
                                        if(hdc)
                                        {
                                                GetClientRect(hwnd,&rc);
                                                //Label(hdc,4,4,rc.dx-4*2,40,RGB_TRANS,RGB(0,0,0),RGB(20,80,80),RIGHT,0);
                                                FillSunkRectangle(hdc,4,4,rc.dx-4*2,40,RGB(10,10,40));
                                                DrawText(hdc,4,4+00,rc.dx-4*2,20,RGB(000,255,255),RGB_TRANS,LEFT,input);
                                                DrawText(hdc,4,4+20,rc.dx-4*2,20,RGB(000,255,000),RGB_TRANS,CENTER,output);

                                        }
                                       
                                        EndPaint(hwnd,hdc);
                                }
                                break;
                                ////
                               
                default:
                return        DefaultWindowProc(hwnd,msg,wParam,lParam);
        }
               
}

/*============================================================================*/
/*============================================================================*/

void        main(void)
{
        HWND hwnd;
        HANDLE hTimer0;
        ////
       
        hwnd        =CreateMainWindow(        120,40,320,240,
                                                                RGB(200,160,96),
                                                                WS_CAPTION|WS_BORDER_DUAL,
                                                                0,
                                                                WinProc,
                                                                (char*)__Name);
                                                               
        ShowWindow(hwnd,SW_SHOW);
        hTimer0=SetTimer(hwnd,0x3000,500,0);
        WindowMessageLoop(hwnd);               
       
        KillTimer(hTimer0);
        DestroyMainWindow(hwnd);
       
        }

tom919 发表于 2010-8-31 11:32:35

又出新作,谢谢lz分享!^_^

clever0725 发表于 2010-8-31 19:06:49

恩 不错 比android的计算器功能多

liuweiele 发表于 2010-9-13 19:45:00

秀图:
http://cache.amobbs.com/bbs_upload782111/files_33/ourdev_582750Z2ZLC1.JPG
(原文件名:DSC_0998.JPG)

ElecBear 发表于 2010-9-13 20:36:37

崇拜一下!

rlogin 发表于 2010-9-13 22:02:58

牛逼

liuweiele 发表于 2010-10-15 12:15:19

实际上只是一个:"函数解析运算器"

liuweiele 发表于 2010-10-20 19:31:59

最新版本(界面美化,全部由GDI绘图完成)源码:


/*============================================================================*/

#define        IDC_NULL        0x0000

#define        IDC_0                0x1000
#define        IDC_1                0x1001
#define        IDC_2                0x1002
#define        IDC_3                0x1003
#define        IDC_4                0x1004
#define        IDC_5                0x1005
#define        IDC_6                0x1006
#define        IDC_7                0x1007
#define        IDC_8                0x1008
#define        IDC_9                0x1009
#define        IDC_A                0x100a
#define        IDC_B                0x100b
#define        IDC_C                0x100c
#define        IDC_D                0x100d
#define        IDC_E                0x100e
#define        IDC_F                0x100f

#define        IDC_ADD                0x1100
#define        IDC_SUB                0x1101
#define        IDC_MUL                0x1102
#define        IDC_DIV                0x1103
#define        IDC_DOT                0x1104
#define        IDC_EQU                0x1105
#define        IDC_LBR                0x1106
#define        IDC_BACK        0x1107
#define        IDC_RBR                0x1108
#define        IDC_CLR                0x1109
#define        IDC_XOR                0x110a
#define        IDC_SEM                0x110b
#define        IDC_COM                0x110c


#define        IDC_SIN                0x1200
#define        IDC_ASIN        0x1201
#define        IDC_COS                0x1202
#define        IDC_ACOS        0x1203
#define        IDC_TAN                0x1204
#define        IDC_ATAN        0x1205
#define        IDC_LOG                0x1206
#define        IDC_SQRT        0x1207
#define        IDC_SUM                0x1208
#define        IDC_AVE                0x1209
#define        IDC_SUR                0x120a

#define        IDC_BIN                0x1300
#define        IDC_OCT                0x1301
#define        IDC_DEC                0x1302
#define        IDC_HEX                0x1303

#define        IDC_ANGLE        0x1400
#define        IDC_RADIAN        0x1401

#define        IDC_MODE_GROUP                0x2000
#define        IDC_TRIFUN_GROUP        0x2001


/*============================================================================*/

char        *mode_text={

        "二进制",
        "八进制",
        "十进制",
        "十六进制",
       
};

U16        mode_id={

        IDC_BIN,
        IDC_OCT,
        IDC_DEC,
        IDC_HEX,

};

char        *tri_fun_text={
        "角度",
        "弧度",
};

U16        tri_fun_id={
        IDC_ANGLE,
        IDC_RADIAN,
};

char *btn_text={

        "0",        "1",        "2",        "3",        "%",        "CE",        "sin",        "asin",
        "4",        "5",        "6",        "7",        "/",        "<-",        "cos",        "acos",
        "8",        "9",        "A",        "B",        "*",        "^",        "tan",        "atan",
        "C",        "D",        "E",        "F",        "-",        ";",        "log",        "sum",
        ".",        ",",        "(",        ")",        "+",        "=",        "sqrt",        "ave"
       
};

U16        btn_id={

IDC_0,                IDC_1,                IDC_2,                IDC_3,                IDC_SUR,        IDC_CLR,        IDC_SIN,        IDC_ASIN,
IDC_4,                IDC_5,                IDC_6,                IDC_7,                IDC_DIV,        IDC_BACK,        IDC_COS,        IDC_ACOS,
IDC_8,                IDC_9,                IDC_A,                IDC_B,                IDC_MUL,        IDC_XOR,        IDC_TAN,        IDC_ATAN,
IDC_C,                IDC_D,                IDC_E,                IDC_F,                IDC_SUB,        IDC_SEM,        IDC_LOG,        IDC_SUM,
IDC_DOT,        IDC_COM,        IDC_LBR,        IDC_RBR,        IDC_ADD,        IDC_EQU,        IDC_SQRT,        IDC_AVE,

};



char output,input;

static        RESULT        WinProc(HWND hwnd,U32 msg,WPARAM wParam,LPARAM lParam)
{
        int i,x,y;
        RECT rc,*m_rc;
        char buf;
        ////
       
        switch(msg)
        {
       
                case        WM_CREATE:
               
                                input        =0;
                                output        =0;
                                jiao                 =TRUE;
                                jin                =10;
                               
                                m_rc        =MemAlloc(sizeof(RECT)*40);
                               
                                GetClientRect(hwnd,&rc);
                               
                                x=4;
                                y=56;
                               
                                CreateWindow("groupbox","进制",WS_CHILDWINDOW,x,y,rc.dx>>1,48,hwnd,IDC_MODE_GROUP,hInst,NULL);
                                SetWindowColor(GetWindowItem(hwnd,IDC_MODE_GROUP),RGB(0,0,0),RGB_TRANS,GetWindowBkColor(hwnd));
                               
                                GetClientRect(GetWindowItem(hwnd,IDC_MODE_GROUP),&rc);
                                GetMatrixRectangle(m_rc,0,0,rc.dx,rc.dy,2,2,2,1);
                               
                                for(i=0;i<4;i++)
                                {                                       
                                        CreateWindow("radiobutton",mode_text,WS_CHILDWINDOW,m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,GetWindowItem(hwnd,IDC_MODE_GROUP),mode_id,hInst,NULL);
       
                                        if(mode_id==IDC_DEC)
                                        {
                                                HWND wnd;
                                               
                                                wnd        =GetWindowItem(hwnd,IDC_MODE_GROUP);
                                                wnd        =GetWindowItem(wnd,IDC_DEC);
                                                SendMessage(wnd,WM_SETVALUE,1,0);
                                       
                                        }
                                }
                                ////
                               
                                GetClientRect(hwnd,&rc);
                                x=(rc.dx>>1)+8;
                               
                                CreateWindow("groupbox","三角函数",WS_CHILDWINDOW,x,y,(rc.dx>>1)-8*2,32,hwnd,IDC_TRIFUN_GROUP,hInst,NULL);
                                SetWindowColor(GetWindowItem(hwnd,IDC_TRIFUN_GROUP),RGB(0,0,0),RGB_TRANS,GetWindowBkColor(hwnd));
                               
                                GetClientRect(GetWindowItem(hwnd,IDC_TRIFUN_GROUP),&rc);
                                GetMatrixRectangle(m_rc,0,0,rc.dx,rc.dy,2,1,2,1);
                                for(i=0;i<2;i++)
                                {
                                        CreateWindow("radiobutton",tri_fun_text,WS_CHILDWINDOW,m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,GetWindowItem(hwnd,IDC_TRIFUN_GROUP),tri_fun_id,hInst,NULL);
                                        if(tri_fun_id==IDC_ANGLE)
                                        {
                                                HWND wnd;
                                               
                                                wnd        =GetWindowItem(hwnd,IDC_TRIFUN_GROUP);
                                                wnd        =GetWindowItem(wnd,IDC_ANGLE);
                                                SendMessage(wnd,WM_SETVALUE,1,0);
                                       
                                        }

                                }
                                       
                                ////
                               
                                x=0;
                                y+=50;
                                GetClientRect(hwnd,&rc);
                                GetMatrixRectangle(m_rc,x,y,rc.dx,rc.dy-y,8,5,4,4);
                               
                                for(i=0;i<40;i++)
                                {
                                        CreateWindow("button",btn_text,WS_CHILDWINDOW|WS_OWNERDRAW,m_rc.x,m_rc.y,m_rc.dx,m_rc.dy,hwnd,btn_id,hInst,NULL);
                                        switch(btn_id)
                                        {
                                                case        IDC_0:
                                                case        IDC_1:
                                                case        IDC_2:
                                                case        IDC_3:
                                                case        IDC_4:
                                                case        IDC_5:
                                                case        IDC_6:
                                                case        IDC_7:
                                                case        IDC_8:
                                                case        IDC_9:
                                                case        IDC_A:
                                                case        IDC_B:
                                                case        IDC_C:
                                                case        IDC_D:
                                                case        IDC_E:
                                                case        IDC_F:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(20,128,200));
                                                                break;
                                                                ////
                                                               
                                                case        IDC_SIN:
                                                case        IDC_ASIN:
                                                case        IDC_COS:
                                                case        IDC_ACOS:
                                                case        IDC_TAN:
                                                case        IDC_ATAN:
                                                case        IDC_LOG:
                                                case        IDC_SUM:
                                                case        IDC_SQRT:
                                                case        IDC_AVE:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(240,128,20));
                                                                break;
                                                                ////
                                                               
                                                case        IDC_SUR:
                                                case        IDC_DIV:
                                                case        IDC_MUL:
                                                case        IDC_SUB:
                                                case        IDC_ADD:
                                                case        IDC_XOR:
                                                case        IDC_SEM:
                                                case        IDC_DOT:
                                                case        IDC_COM:
                                                case        IDC_LBR:
                                                case        IDC_RBR:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(200,20,128));
                                                                break;
                                                                ////
                                               
                                                case        IDC_EQU:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(20,200,20));
                                                                break;
                                                                ////
                                                               
                                                case        IDC_CLR:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(200,20,20));
                                                                break;
                                                                ////
                                                                       
                                                case        IDC_BACK:
                                                                SetWindowLong(GetWindowItem(hwnd,btn_id),GWL_BKCOLOR,RGB(200,200,20));
                                                                break;
                                                                ////
                                                                       
                               
                                        }
                                       
                                        UpdateWindow(GetWindowItem(hwnd,btn_id));
                                       
                                }
                               
                                MemFree(m_rc);
                                break;
                                ////////
                               
                case        WM_COMMAND:
                                {
                                        U16        id,code;
                                        HWND wnd;
                                       
                                        code        =HIWORD(wParam);
                                        id                =LOWORD(wParam);
                                                       
                                        if(code==BN_CLICKED)
                                        {
                                               
                                                switch(id)
                                                {

                                                        case        IDC_BIN:
                                                                        jin        =2;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                        case        IDC_OCT:
                                                                        jin        =8;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                        case        IDC_DEC:
                                                                        jin        =10;
                                                                        output        =0;                                                       
                                                                        break;
                                                                        ////
                                                        case        IDC_HEX:
                                                                        jin        =16;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_ANGLE:
                                                                        jiao =TRUE;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_RADIAN:
                                                                        jiao =FALSE;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                       
                                                        case        IDC_CLR:
                                                                        input        =0;
                                                                        output        =0;
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_BACK:
                                                                        output        =0;
                                                                        str_back(input);
                                                                        //StrPrintf(output,"%s",input);
                                                                        break;
                                                                        ////
                                                                       
                                                        case        IDC_EQU:
                                                                       
                                                                        OnEql(output,input);
                                                                        break;
                                                                        ////
                                               
                                                        default:
                                                       
                                                                        if(jin==2)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_2:
                                                                                        case        IDC_3:
                                                                                        case        IDC_4:
                                                                                        case        IDC_5:
                                                                                        case        IDC_6:
                                                                                        case        IDC_7:
                                                                                        case        IDC_8:
                                                                                        case        IDC_9:
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowText(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==8)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_8:
                                                                                        case        IDC_9:
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowText(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==10)
                                                                        {
                                                                                switch(id)
                                                                                {
                                                                                        case        IDC_A:
                                                                                        case        IDC_B:
                                                                                        case        IDC_C:
                                                                                        case        IDC_D:
                                                                                        case        IDC_E:
                                                                                        case        IDC_F:
                                                                                                       
                                                                                                        break;
                                                                                                        ////
                                                                                        default:
                                                                                                        wnd        =GetWindowItem(hwnd,id);
                                                                                                        str_add(input,GetWindowText(wnd));
                                                                                                        output        =0;
                                                                                                        break;
                                                                                                        /////

                                                                                       
                                                                                }
                                                                        }
                                                                       
                                                                        if(jin==16)
                                                                        {
                                                                                wnd        =GetWindowItem(hwnd,id);
                                                                                str_add(input,GetWindowText(wnd));
                                                                                output        =0;
                                                                                break;
                                                                                /////
                                                                               
                                                                        }
                                                                       
                                                                       
                                                }
                                       
                                               
                                                InvalidateRect(hwnd,0,0);
                                        }
                                }
               
                                break;
                                /////////
                                                       
                case        WM_DRAWITEM:
                                {       
                                        DRAWITEMSTRUCT *item;
                                        int x,y;
                                       
                                        item=(void*)lParam;

                               
                                        switch(item->ID)
                                        {
                                       
                                                case        IDC_0:
                                                case        IDC_1:
                                                case        IDC_2:
                                                case        IDC_3:
                                                case        IDC_4:
                                                case        IDC_5:
                                                case        IDC_6:
                                                case        IDC_7:
                                                case        IDC_8:
                                                case        IDC_9:
                                                case        IDC_A:
                                                case        IDC_B:
                                                case        IDC_C:
                                                case        IDC_D:
                                                case        IDC_E:
                                                case        IDC_F:
                                                case        IDC_SUR:
                                                case        IDC_CLR:
                                                case        IDC_SIN:
                                                case        IDC_ASIN:
                                                case        IDC_DIV:
                                                case        IDC_BACK:
                                                case        IDC_COS:
                                                case        IDC_ACOS:
                                                case        IDC_MUL:
                                                case        IDC_XOR:
                                                case        IDC_TAN:
                                                case        IDC_ATAN:
                                                case        IDC_SUB:
                                                case        IDC_SEM:
                                                case        IDC_LOG:
                                                case        IDC_SUM:
                                                case        IDC_DOT:
                                                case        IDC_COM:
                                                case        IDC_LBR:
                                                case        IDC_RBR:
                                                case        IDC_ADD:
                                                case        IDC_EQU:
                                                case        IDC_SQRT:
                                                case        IDC_AVE:
                                               
                                                SetFontSize(item->hDC,16,0);
                                                FillRectangle(item->hDC,0,0,item->rc.dx,item->rc.dy,GetWindowLong(hwnd,GWL_BKCOLOR));
                                               
                                                if(GetWindowLong(item->hwnd,GWL_STYLE)&BS_PUSHED)
                                                {
                                                       
                                                        FillRectangle(item->hDC,0+2,0+2,item->rc.dx-2,item->rc.dy-2,~GetWindowLong(item->hwnd,GWL_BKCOLOR));
                                                        Rectangle(item->hDC,0+2,0+2,item->rc.dx-2,item->rc.dy-2,~GetWindowLong(item->hwnd,GWL_BDCOLOR));
                                                       
                                                        DrawText(item->hDC,0+2,0+2,item->rc.dx-2,item->rc.dy-2,~GetWindowLong(item->hwnd,GWL_FRCOLOR),RGB_TRANS,CENTER,GetWindowText(item->hwnd));
                                                       
                                                }
                                                else
                                                {
                                                       
                                                        FillRectangle(item->hDC,0+3,0+3,item->rc.dx-3,item->rc.dy-3,GetWindowLong(item->hwnd,GWL_BDCOLOR));
                                                        //FillRectangle(item->hDC,0+0,0+0,item->rc.dx-3,item->rc.dy-3,GetWindowLong(item->hwnd,GWL_BKCOLOR));
                                                        VGradientRectangle(item->hDC,0+0,0+0,item->rc.dx-3,item->rc.dy-3,RGB(240,240,240),GetWindowLong(item->hwnd,GWL_BKCOLOR));
               
                                                        DrawText(item->hDC,0,0,item->rc.dx-3,item->rc.dy-3,GetWindowLong(item->hwnd,GWL_FRCOLOR),RGB_TRANS,CENTER,GetWindowText(item->hwnd));
                                                       
                                                }
                                                break;
                                                ///////
                                               
                                                default:
                                                                return DefWindowProc(hwnd,msg,wParam,lParam);
                                        }
                                }
                                break;
                                ////////
                                       
                case        WM_PAINT:
                                {
                                        HDC hdc;
                                       
                                       
                                        hdc=BeginPaint(hwnd);
                                        if(hdc)
                                        {
                                                GetClientRect(hwnd,&rc);
                                                //Label(hdc,6,4,rc.dx-4*2,40,RGB_TRANS,RGB(0,0,0),RGB(20,80,80),RIGHT,0);
                                                SunkRectangle(hdc,6,4,rc.dx-4*2,48,RGB(10,10,40));
                                                VGradientRectangle(hdc,6+2,4+2,rc.dx-4*2-2*2-1,48-2*2,RGB(0,132,96),RGB(128,220,180));
                                                ////
                                               
                                                SetFontSize(hdc,16,0);
                                                DrawText(hdc,6,4+00,rc.dx-4*2,24,RGB(000,000,000),RGB_TRANS,LEFT,input);
                                                SetFontSize(hdc,24,0);
                                                DrawText(hdc,6,4+20,rc.dx-4*2,24,RGB(200,000,000),RGB_TRANS,CENTER,output);
                                                ////
                                               
                                                switch(jin)
                                                {
                                                        case        2:
                                                                        SetFontSize(hdc,12,0);
                                                                        DrawText(hdc,6,4+48-16,32,16,RGB(200,000,000),RGB_TRANS,CENTER,"BIN");
                                                                        break;
                                                                        ////
                                               
                                                        case        8:
                                                                        SetFontSize(hdc,12,0);
                                                                        DrawText(hdc,6,4+48-16,32,16,RGB(200,000,000),RGB_TRANS,CENTER,"OCT");
                                                                        break;
                                                                        ////
                                               
                                                        case        10:
                                                                        SetFontSize(hdc,12,0);
                                                                        DrawText(hdc,6,4+48-16,32,16,RGB(200,000,000),RGB_TRANS,CENTER,"DEC");
                                                                        break;
                                                                        ////
                                               
                                                        case        16:
                                                                        SetFontSize(hdc,12,0);
                                                                        DrawText(hdc,6,4+48-16,32,16,RGB(200,000,000),RGB_TRANS,CENTER,"HEX");
                                                                        break;
                                                                        ////
                                               
                                                }
                                                ////
                                        }
                                       
                                        EndPaint(hwnd,hdc);
                                }
                                break;
                                ////
                               
                default:
                return        DefWindowProc(hwnd,msg,wParam,lParam);
        }
               
}

/*============================================================================*/
/*============================================================================*/

int        WinMain(HANDLE hInstance,void *argv)
{
        HWND hwnd;
        MSG msg;
        WNDCLASS wcls;
        ////
       
        hInst                =hInstance;
       
        __rt_lib_init(0,0);
       

        wcls.lpClassName        =(char*)__Name;
        wcls.hInstance                =hInstance;
        wcls.Style                        =0;
        wcls.lpfnProc                =WinProc;
        wcls.hIcon                        =0;
        wcls.hIconSm                =0;
        wcls.hCursor                =0;
        wcls.BkColor                =RGB(128,128,144);
       
       
        hwnd        =CreateWindow(        &wcls,(char*)__Name,WS_OVERLAPPEDWINDOW,
                                                        120,40,380,320,
                                                        NULL,NULL,hInst,NULL);
                                                               
        ShowWindow(hwnd,SW_SHOW);
       
        while(GetMessage(&msg,hwnd))
        {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
        }       
       
}

liuweiele 发表于 2010-10-20 19:33:06

美化后的界面:

http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_591537TZD740.JPG
(原文件名:DSC_1316.JPG)

http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_591538BTMUUS.JPG
(原文件名:DSC_1320.JPG)

it1988 发表于 2010-12-26 00:35:13

神呐,崇拜ING...

longfeiyu 发表于 2010-12-26 15:12:33

呵呵,谢谢

wwwdege 发表于 2010-12-26 17:21:27

mark
页: [1]
查看完整版本: ## 基于ARM的 多功能科学计算器 (支持多进制四则混合运算,三角函数,统计函数) ##