⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gprs.c

📁 拨打电话~发信息.基于MINIGUI写的
💻 C
字号:
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<unistd.h>#include<fcntl.h>#include<minigui/common.h>#include<minigui/minigui.h>#include<minigui/gdi.h>#include<minigui/window.h>#include<minigui/control.h>#include<minigui/dti.c>#include<minigui/mgext.h>#define ID_TIMER 1100#define IDC_CALL 1101#define IDC_MESSAGE 1102#define IDC_EXIT 1103#define IDS_NUMBER 1201#define IDS_TEXT 1202#define IDS_SEND 1203#define IDC_NUMBER 2100#define IDC_N1 2101#define IDC_N2 2102#define IDC_N3 2103#define IDC_N4 2104#define IDC_N5 2105#define IDC_N6 2106#define IDC_N7 2107#define IDC_N8 2108#define IDC_N9 2109#define IDC_N10 2110#define IDC_N11 2111#define IDCA_CALL 2112#define IDCH_HOLD 2113#define IDC_N14 2114#define IDC_BACK 2115#define IDC_TIME 2116static char number[30];static char text[1000];static char buffer[30];static void WriteMessage();static void CallTel();static char buf[30];static int s=0,m=0,h=0;static DLGTEMPLATE DlgMessageFiles={   WS_VISIBLE|WS_CAPTION|WS_BORDER,   WS_EX_NONE,   0,0,320,240,   "Message",   0,0,   4,NULL,   0};static CTRLDATA CtrlMessageFiles[]={ {    "static",    WS_VISIBLE|SS_SIMPLE,    10,10,50,30,    IDC_STATIC,     "number",    0  },  {    CTRL_SLEDIT,    WS_VISIBLE|WS_BORDER,    70,10,200,30,    IDS_NUMBER,    "",    0  },  /*{     "staitc",    WS_VISIBLE|SS_SIMPLE,    10,70,40,50,    10000,    "text",    0  },*/  {   CTRL_MLEDIT,   WS_VISIBLE|WS_BORDER|ES_BASELINE|ES_AUTOWRAP,   10,50,300,110,   IDS_TEXT,   "",   0  },  {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     100,180,200,30,     IDS_SEND,     "Send Message",     0  }};static int InitMessageFilesBoxProc(HWND hDlg,int message,WPARAM wParam,LPARAM lParam){         switch(message)       {          case MSG_INITDIALOG://tty_init();                                break;          case MSG_CLOSE:             EndDialog(hDlg,wParam);             break;                             case MSG_COMMAND:                switch(wParam)                      {                       case IDS_SEND:  WriteMessage(hDlg);                                       break;                      }                           }     return DefaultDialogProc(hDlg,message,wParam,lParam);}static void InitMessageFilesBox(HWND hWnd){     DlgMessageFiles.controls=CtrlMessageFiles;     DialogBoxIndirectParam(&DlgMessageFiles,hWnd,InitMessageFilesBoxProc,0L);}static DLGTEMPLATE DlgCallFiles={   WS_VISIBLE|WS_CAPTION|WS_BORDER,   WS_EX_NONE,   0,0,320,240,   "Call",   0,0,   18,NULL,   0};static CTRLDATA CtrlCallFiles[]={ {    "static",    WS_VISIBLE|SS_SIMPLE,    10,10,40,20,    IDC_STATIC,    "Tel",    0  },  {    CTRL_SLEDIT,    WS_VISIBLE|WS_BORDER,    70,10,120,20,    IDC_NUMBER,    "",    0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     10,80,90,25,     IDC_N1,     "1",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     110,80,90,25,     IDC_N2,     "2",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     210,80,90,25,     IDC_N3,     "3",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     10,115,90,25,     IDC_N4,     "4",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     110,115,90,25,     IDC_N5,     "5",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     210,115,90,25,     IDC_N6,     "6",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     10,150,90,25,     IDC_N7,     "7",     0  }, {      "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     110,150,90,25,     IDC_N8,     "8",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     210,150,90,25,     IDC_N9,     "9",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     10,185,90,25,     IDC_N10,     "*",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     210,185,90,25,     IDC_N11,     "#",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     50,40,70,30,     IDCA_CALL,     "CALL",     0  }, {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     150,40,70,30,     IDCH_HOLD,     "HOLD",     0  }, {    "static",    WS_VISIBLE,    240,40,70,30,    IDC_TIME,    "",    0},  {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     110,185,90,25,     IDC_N14,     "0",     0  },  {     "button",     WS_VISIBLE|BS_DEFPUSHBUTTON,     230,10,40,20,     IDC_BACK,     "back",     0  }};static int InitCallFilesBoxProc(HWND hDlg,int message,WPARAM wParam,LPARAM lParam){                                                                                                                                                                                                      switch(message)       {          case MSG_INITDIALOG:               {            /* SetTimer(hDlg,ID_TIMER,58);                              SetWindowText(GetDlgItem(hDlg,IDC_TIME),buf);*/                              break;               }          case MSG_CLOSE:              {                        EndDialog(hDlg,wParam);                        break;              }          case MSG_COMMAND:                switch(wParam)                      {           case IDCA_CALL: //GetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer,20);              {            CallTel(hDlg);                           SetTimer(hDlg,ID_TIMER,58);                           SetWindowText(GetDlgItem(hDlg,IDC_TIME),buf);                           gprs_call(buffer,strlen(buffer));                           break;              }           case IDC_N1:                {strcat(buffer,"1");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;}           case IDC_N2:               { strcat(buffer,"2");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;}           case IDC_N3:                strcat(buffer,"3");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N4:                strcat(buffer,"4");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N5:                strcat(buffer,"5");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N6:                strcat(buffer,"6");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N7:                strcat(buffer,"7");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N8:                strcat(buffer,"8");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N9:                strcat(buffer,"9");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N14:                strcat(buffer,"0");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N10:                strcat(buffer,"*");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;           case IDC_N11:                strcat(buffer,"#");                SetWindowText(GetDlgItem(hDlg,IDC_NUMBER),buffer);                break;                                            case IDCH_HOLD:gprs_hold();                          KillTimer(hDlg,ID_TIMER);                          break;             }break;        case MSG_TIMER:        if(wParam==ID_TIMER)                {                    s++;                    m=s/60;                    h=m/60;                    sprintf(buf,"%02d:%02d:%02d",h,m,s%60);                    SetWindowText(GetDlgItem(hDlg,IDC_TIME),buf);                    UpdateWindow(hDlg,TRUE);                }break;       }     return DefaultDialogProc(hDlg,message,wParam,lParam);                                                                                                 }static void InitCallFilesBox(HWND hWnd){     DlgCallFiles.controls=CtrlCallFiles;     DialogBoxIndirectParam(&DlgCallFiles,hWnd,InitCallFilesBoxProc,0L);}static void CallTel(HWND hDlg){SendMessage(GetDlgItem(hDlg,IDC_NUMBER),MSG_GETTEXT,90,(LPARAM)buffer);  if(strcmp(buffer,"")==0)    {MessageBox(hDlg,"number is null","",MB_OK);}}static void WriteMessage(HWND hDlg){    int len;  SendMessage(GetDlgItem(hDlg,IDS_NUMBER),MSG_GETTEXT,90,(LPARAM)number);    if(strcmp(number,"")==0)    {MessageBox(hDlg,"number is null","",MB_OK);}  SendMessage(GetDlgItem(hDlg,IDS_TEXT),MSG_GETTEXT,90,(LPARAM)text);  len=GetWindowTextLength(GetDlgItem(hDlg,IDS_TEXT));  if(len>500)    {       MessageBox(hDlg,"letter is full,can't send","",MB_OK);    }   msg_send(number,text);      }static int TelphoneWinProc(HWND hWnd,int message,WPARAM wParam,LPARAM lParam){   HDC hdc;   RECT rc;   switch(message)         {            case MSG_CREATE:  tty_init();                              gprs_init();                              CreateWindow( "button",                                            "Call a ring",                                            WS_VISIBLE|BS_DEFPUSHBUTTON|WS_TABSTOP,                                            IDC_CALL,                                            70,20,200,50,                                            hWnd,                                            0);                              CreateWindow( "button",                                            "Send a Message",                                            WS_VISIBLE|BS_DEFPUSHBUTTON|WS_TABSTOP,                                            IDC_MESSAGE,                                            70,90,200,50,                                            hWnd,                                            0);                              CreateWindow( "button",                                            "exit",                                            WS_VISIBLE|BS_DEFPUSHBUTTON|WS_TABSTOP,                                            IDC_EXIT,                                            70,160,200,50,                                            hWnd,                                            0);                                      break;            case MSG_COMMAND:                 switch(wParam)                  {                    case IDC_CALL:                             {                                InitCallFilesBox(hWnd);                                break;                             }                    case IDC_MESSAGE:                             {                                InitMessageFilesBox(hWnd);                               break;                              }                   case IDC_EXIT:                              {                                 DestroyMainWindow(hWnd);                                 PostQuitMessage(hWnd);                                 return 0;                                 break;                              }                                            } break;            case MSG_CLOSE:                                                                                                          DestroyMainWindow(hWnd);                          PostQuitMessage(hWnd);                            return 0;                                                                                  }                                                                                            return DefaultMainWinProc(hWnd,message,wParam,lParam);}int MiniGUIMain(int argc,const char * argv[]){  MSG Msg;  HWND hMainWnd;  MAINWINCREATE CreateInfo;  if(!InitMiniGUIExt())     {          return 2;     } CreateInfo.dwStyle=WS_VISIBLE | WS_BORDER | WS_CAPTION; CreateInfo.dwExStyle=WS_EX_NONE; CreateInfo.spCaption="MOTO"; CreateInfo.hMenu=0; CreateInfo.hCursor=GetSystemCursor(0); CreateInfo.hIcon=0; CreateInfo.MainWindowProc=TelphoneWinProc; CreateInfo.lx=0; CreateInfo.ty=0; CreateInfo.rx=320; CreateInfo.by=240; CreateInfo.iBkColor=COLOR_lightwhite; CreateInfo.dwAddData=0; CreateInfo.hHosting=HWND_DESKTOP; hMainWnd=CreateMainWindow(&CreateInfo); if(hMainWnd==HWND_INVALID)    return -1; ShowWindow(hMainWnd,SW_SHOWNORMAL); while(GetMessage(&Msg,hMainWnd))      {          TranslateMessage(&Msg);          DispatchMessage(&Msg);      }       MiniGUIExtCleanUp();       MainWindowThreadCleanup(hMainWnd);                                                                                                                                                                 return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -