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

📄 main.c.bak

📁 基于minigui的手机程序开发 实现电话拨打功能
💻 BAK
字号:
#include <minigui/common.h> //包含Minigui常用的宏及数据类型的定义
#include <minigui/minigui.h>//包含全局的和通用的接口函数
#include <minigui/gdi.h>//包含对图形的接口声明
#include <minigui/window.h>//包含和窗口有关的宏、数据类型、数据结构的定义以及函数的声明
#include <minigui/control.h>//包含内建控件的接口定义
#include <string.h>
#define IDC_BUTTON1 101
#define IDC_BUTTON2 102
#define IDC_BUTTON3 103
#define IDC_BUTTON4 104
#define IDC_BUTTON5 105
#define IDC_BUTTON6 106
#define IDC_BUTTON7 107
#define IDC_BUTTON8 108
#define IDC_BUTTON9 109
#define IDC_BUTTON10 110
#define IDC_BUTTON11 111
#define IDC_BUTTON12 112
#define IDC_BUTTON13 113
#define IDC_BUTTON14 114
#define IDC_BUTTON15 115
#define IDC_BUTTON16 116
#define IDC_SLEDIT 117
static BITMAP bmp0;
static BITMAP bmp001;
static BITMAP bmp002;
static BITMAP bmp003;
static BITMAP bmp004;
static BITMAP bmp005;
static BITMAP bmp006;
static BITMAP bmp007;
static BITMAP bmp008;
static BITMAP bmp009;
static BITMAP bmpc;
static BITMAP bmpjing;
static BITMAP bmpxing;
static BITMAP bmpda;
static BITMAP bmpgua;
static BITMAP bmplist;
#include "comm.h"
void gprs_read()
{ 
  char call[100]; 
  char callNumber[50];
  char *p;
  GPRSSTOP=1;
  p=call;
  int len,i,len2;
  while(GPRSSTOP==1)
	{
     tty_read(call,1);
	 if(strcmp(call,"R")==0)//来电话处理 /*处理来电RING+CLIP:"0146290800"
   	    {
			tty_read(call,4);
			if(strcmp(call,"RING")==0)
			{	    
				    tty_read(call,50);
					len=strlen(call);
					
					for(i=0;i<=len;i++,p++)
						{
						 if(call[i]=='\"')
							{
							 strcpy(callNumber,++p);
							 len2=strlen(callNumber);
							 callNumber[len2-1]='\0';//去掉电话号的最后的"
							 break;
							}
						}
			 
					haveCallWindow(callNumber);
			}
   	    }
   	      
   	  if(strcmp(call,"N")==0)//呼叫建立失败处理 
		{
				      tty_read(call,10);
					if(strcmp(call,"NO CARRIER")==0)
						{
					     MessageBox(hwnd_CallWin,"呼叫建立失败!请重试!","呼叫建立失败",MB_OK);
					
						}

	    }
	  if(strcmp(call,"O")==0)//通话已建立
		{
	     tty_read(call,2);
		if(strcmp(call,"OK")==0)
			{
		     //计时窗口
		     timeWindow(callNumber);//计时窗口
			}
	 
	    }

	 usleep(300000);
	}

}
static int HelloWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{     HWND hwnd_SLEDIT;
			HWND hdc;
			char buff[50]={'\0'};
			char *pb;
			pb=&buff[0];
			int num=0;
			char c;
      switch (message) {
			case MSG_CREATE:            

				 hwnd_SLEDIT=CreateWindow (CTRL_SLEDIT, 
         "",
         WS_VISIBLE | ES_LEFT|WS_BORDER,                            				
				 IDC_SLEDIT,
				 50, 15, 200, 25, 
				 hWnd,
				 0);
				 
				 CreateWindow (CTRL_BUTTON, //打
         "",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                       				
				 IDC_BUTTON1,
				 10, 50, 60, 30, 
				 hWnd,
				 (DWORD)&bmpda);
				 
			   CreateWindow (CTRL_BUTTON, //数字1
         " ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                           				
				 IDC_BUTTON2,
				 95, 50, 50, 30, 
				 hWnd,
				 (DWORD)&bmp001);
	
				 CreateWindow (CTRL_BUTTON, //2
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                           				
				 IDC_BUTTON3,
				 155, 50, 50, 30, 
				 hWnd,
				 (DWORD)&bmp002);
				 
				 CreateWindow (CTRL_BUTTON, //3
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                            				
				 IDC_BUTTON4,
				 215, 50, 50, 30, 
				 hWnd,
				 (DWORD)&bmp003);
				 
				 CreateWindow (CTRL_BUTTON, //list
         " ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                       				
				 IDC_BUTTON5,
				 10, 90, 60, 30, 
				 hWnd,
				 (DWORD)&bmplist);
				 
			   CreateWindow (CTRL_BUTTON, //4
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                          				
				 IDC_BUTTON6,
				 95, 90, 50, 30, 
				 hWnd,
				 (DWORD)&bmp004);
				 
				 CreateWindow (CTRL_BUTTON, //5
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                           				
				 IDC_BUTTON7,
				 155, 90, 50, 30, 
				 hWnd,
				 (DWORD)&bmp005);
				 
				 CreateWindow (CTRL_BUTTON, //6
         "  ",
       BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                        				
				 IDC_BUTTON8,
				 215, 90, 50, 30, 
				 hWnd,
				 (DWORD)&bmp006);
				 
				 CreateWindow (CTRL_BUTTON, //c
         " ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                        				
				 IDC_BUTTON9,
				 10, 130, 60, 30, 
				 hWnd,
				 (DWORD)&bmpc);
				 
			   CreateWindow (CTRL_BUTTON, //7
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                    				
				 IDC_BUTTON10,
				 95, 130, 50, 30, 
				 hWnd,
				 (DWORD)&bmp007);
				 
				 CreateWindow (CTRL_BUTTON, //8
         " ",
        BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                           				
				 IDC_BUTTON11,
				 155, 130, 50, 30, 
				 hWnd,
				 (DWORD)&bmp008);
				 
				 CreateWindow (CTRL_BUTTON,//9 
         "  ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                               				
				 IDC_BUTTON12,
				 215, 130, 50, 30, 
				 hWnd,
				(DWORD)&bmp009);
				 
				 CreateWindow (CTRL_BUTTON, //挂
         "",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                       				
				 IDC_BUTTON13,
				 10, 170, 60, 30, 
				 hWnd,
				 (DWORD)&bmpgua);
				 
			   CreateWindow (CTRL_BUTTON, //xing
         " ",
         BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                            				
				 IDC_BUTTON14,
				 95, 170, 50, 30, 
				 hWnd,
				 (DWORD)&bmpxing);
				 
				 CreateWindow (CTRL_BUTTON,//数字0
			   " ",
			   BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,
			   IDC_BUTTON15,
			   155, 170, 50, 30,
			   hWnd, 
			   (DWORD)&bmp0);
				 
				 CreateWindow (CTRL_BUTTON, //jing
         "  ",
     BS_PUSHBUTTON | BS_BITMAP| WS_VISIBLE,                         				
				 IDC_BUTTON16,
				 215, 170, 50, 30, 
				 hWnd,
				 (DWORD)&bmpjing);

			   break;
		case MSG_PAINT:
			   	break;
			   
			case MSG_COMMAND:
		  	switch(wParam)
		  	{
		  		case IDC_BUTTON2:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"1");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON3:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"2");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON4:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"3");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON5:
		  				{list();
		  					break;
		  					}
		  			case IDC_BUTTON6:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"4");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON7:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"5");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON8:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"6");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON9:
		  			{
		  		    GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				num=strlen(buff);
		  				buff[num-1]='\0';
		  			  SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		
		  			}
		  			break;
		  			
		  			case IDC_BUTTON10:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"7");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON11:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"8");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON12:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"9");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON13:
		  			{
		  		    gprs_hold();
		  				break;
		  			}
		  			case IDC_BUTTON14:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"*");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON15:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"0");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  			case IDC_BUTTON16:
		  			{
		  				GetWindowText (GetDlgItem(hWnd,IDC_SLEDIT),buff,50);
		  				printf("%s\n",buff);
		  				strcat(buff,"#");
		  				SetWindowText(GetDlgItem(hWnd,IDC_SLEDIT),buff);
		  				break;
		  			}
		  		case IDC_BUTTON1://da
		  			{
		  
					
			
				  GetWindowText(hwnd_SLEDIT, buff,50);
				  gprs_call(buff,strlen(buff));//打电话

				  break;
		  					
		  			}
		  		
        }      	
		  break;
      
      case MSG_CLOSE:
      			UnloadBitmap (&bmp0);
      			UnloadBitmap (&bmp001);
      			UnloadBitmap (&bmp002);
      			UnloadBitmap (&bmp003);
      			UnloadBitmap (&bmp004);
      			UnloadBitmap (&bmp005);
      			UnloadBitmap (&bmp006);
      			UnloadBitmap (&bmp007);
      			UnloadBitmap (&bmp008);
      			UnloadBitmap (&bmp008);
      			UnloadBitmap (&bmpda);
      			UnloadBitmap (&bmpgua);
      			UnloadBitmap (&bmpxing);
      			UnloadBitmap (&bmpc);
      			UnloadBitmap (&bmplist);
      			
						DestroyMainWindow (hWnd);//摧毁主窗口
            PostQuitMessage (hWnd);//发送MSG_QUIT消息
            return 0;
    }
    return DefaultMainWinProc(hWnd, message, wParam, lParam);//默认消息处理
}

int MiniGUIMain (int argc, const char* argv[])
{	  pthread_t th_b;
    MSG Msg; //定义消息变量
    HWND hMainWnd; //定义句柄
    MAINWINCREATE CreateInfo;//定义窗口信息的结构体变量 CreateInfo
    CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;//窗口风格
    CreateInfo.dwExStyle = WS_EX_NONE;//窗口的附加风格
    CreateInfo.spCaption = "电话键盘";//窗口的标题
    CreateInfo.hMenu = 0;//窗口上的菜单句柄
    CreateInfo.hCursor = GetSystemCursor(0);//在窗口中所使用的鼠标光标句柄
    CreateInfo.hIcon = 0;//程序的图标
    CreateInfo.MainWindowProc = HelloWinProc;//该窗口的消息处理函数指针
    CreateInfo.lx = 0;//窗口左上角相对屏幕的绝对横坐标,以象素点表示
    CreateInfo.ty = 0;//窗口左上角相对屏幕的绝对纵坐标,以象素点表示
    CreateInfo.rx = 320;//窗口右下角相对屏幕的绝对横坐标,以象素点表示
    CreateInfo.by = 240;//窗口右下角相对屏幕的绝对纵坐标,以象素点表示
    CreateInfo.iBkColor = COLOR_black;//窗口背景颜色
    CreateInfo.dwAddData = 0;//附带给窗口的一个 32 位值
    CreateInfo.hHosting = HWND_DESKTOP;  //窗口消息队列的托管窗口
   if (LoadBitmap (HDC_SCREEN, &bmp0, "0.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmp001, "001.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp002, "002.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp003, "003.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp004, "004.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp005, "005.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp006, "006.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp007, "007.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp008, "008.jpg"))//加载位图,在创建窗口之前创建
    return 1;
     if (LoadBitmap (HDC_SCREEN, &bmp009, "009.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmpc, "c.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmpxing, "xing.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmpjing, "jing.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmpda, "da.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmpgua, "gua.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    if (LoadBitmap (HDC_SCREEN, &bmplist, "list.jpg"))//加载位图,在创建窗口之前创建
    return 1;
    hMainWnd = CreateMainWindow (&CreateInfo); //创建窗口 
    if (hMainWnd == HWND_INVALID)
        return -1;
    ShowWindow(hMainWnd, SW_SHOWNORMAL);//显示窗口
    tty_init();//初始化串口
     gprs_init();//初始化gprs
	   pthread_create(&th_b, NULL, gprs_read, 0);
	 tty_end();
    while (GetMessage(&Msg, hMainWnd)) {//从消息队列中获得消息
        TranslateMessage(&Msg);//翻译消息
        DispatchMessage(&Msg);//发送消息
    }
    MainWindowThreadCleanup (hMainWnd);//释放资源
    return 0;
}


⌨️ 快捷键说明

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