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

📄 answering.c

📁 minigui PDA系统 可实现手机功能
💻 C
字号:
#include <stdio.h>
#include <string.h>

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>

#include "tel.h"
#include "call_time.h"

#define  IDC_ABUTTON_CANCEL      0x1072
#define  IDC_ATIMER              0x1083

//static BITMAP bmp_bkgnd;

FILE *RDfp;
int timecount; 

static int AnsweringDialogProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int hour = 0;
    int minite = 0;
    int second = 0;
     
    switch (message) {
        case MSG_CREATE:
        	  CreateWindow(CTRL_BUTTON,
        	               "挂断",WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, 
        	               IDC_ABUTTON_CANCEL, 
        	               180,42,60,25, 
        	               hWnd, 
        	               0);         
	          printf("%d\n",RDfp = fopen("data/record.txt","a+"));
        	  fread(&RD, sizeof(_RECORD), 1, RDfp);
        	  fclose(RDfp);
        	  strcpy(call_time,"00:00:00");
        	  SetTimer(hWnd, IDC_ATIMER, 100);                                	   
            break;
                        
        case MSG_COMMAND:
        	  switch(wParam)
            {
                case IDC_ABUTTON_CANCEL:
                	  gprs_hold();
                	  
                	  CALL_ANS = 0;
                	  
                	  KillTimer(hWnd, IDC_ATIMER);
			  printf("hold\n");
                	  printf("%d \n",CALL_NOCARRIER);
          	        if(CALL_NOCARRIER == 1)        
                        RD.dial_time += timecount;
                    if(CALL_NOCARRIER == 2)         
                        RD.ans_time += timecount;
                    RD.total_time += timecount;          
                    RD.last_time = timecount; 
          	        printf("%d %d %d %d\n",RD.total_time,RD.dial_time,RD.ans_time,RD.last_time);
          	        printf("%d\n",RDfp = fopen("data/record.txt","w"));
                    fwrite(&RD, sizeof(_RECORD), 1, RDfp);
                    fclose(RDfp);
                    timecount = 0;
				
                    DestroyMainWindow (hWnd);
                    PostQuitMessage (hWnd);
                	  break;    	
            }
            return 0;
                   	
        case MSG_PAINT:
            //printf ("BeginPaint.\n");
            hdc = BeginPaint (hWnd);
            
            TextOut(hdc,60,5,"通话");
            TextOut(hdc,60,22,call_time);

            EndPaint (hWnd, hdc);
           // printf ("EndPaint.\n");
            return 0;
            
       /* case MSG_ERASEBKGND:
            hdc = GetClientDC (hWnd);
            FillBoxWithBitmap (hdc,0, 0, 320, 200, &bmp_bkgnd); 
            ReleaseDC (hdc);
            return 0;*/
            	
        case MSG_RING_HOLD1:
        	  {
        	  	CALL_ANS = 0;
        	  	
				
        	  	KillTimer(hWnd, IDC_ATIMER);
        	  	
              RD.dial_time += timecount;
              RD.total_time += timecount;          
              RD.last_time = timecount; 
    	        
    	        printf("%d\n",RDfp = fopen("data/record.txt","w"));
              fwrite(&RD, sizeof(_RECORD), 1, RDfp);
              fclose(RDfp);
              timecount = 0;      
        	  	DestroyMainWindow (hWnd);
              PostQuitMessage (hWnd);
        	  } 
        	  return 0;
        
        case MSG_RING_HOLD2:
        	  {
        	  	CALL_ANS = 0;
        	  	
        	  	KillTimer(hWnd, IDC_ATIMER);
        	  	       
              RD.ans_time += timecount;
              RD.total_time += timecount;          
              RD.last_time = timecount; 
    	        
    	        printf("%d\n",RDfp = fopen("data/record.txt","w"));
              fwrite(&RD, sizeof(_RECORD), 1, RDfp);
              fclose(RDfp);
              timecount = 0;
        	  	DestroyMainWindow (hWnd);
              PostQuitMessage (hWnd);
        	  }
        	  return 0;
        	  	     
        case MSG_TIMER:
        	  if( wParam == IDC_ATIMER )
        	  {
        	  		timecount++;
	              hour=timecount/3600;
  	            minite=(timecount%3600)/60;
	              second=((timecount%3600)%60);
	              sprintf(call_time,"%02d:%02d:%02d",hour,minite,second);
	              printf("call_time = %s",call_time);
	              UpdateWindow(hWnd,1);
        	  }  
        	  return 0;
        	      
        case MSG_CLOSE:
        	  //UnloadBitmap(&bmp_bkgnd);
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
            return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

int AnsweringDialog(HWND hwnd)
{
    MSG Msg;
    HWND hAnswerWnd;
    MAINWINCREATE CreateInfo;

    CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER ; 
    CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.spCaption = "";
    CreateInfo.hMenu = 0;
    CreateInfo.hCursor = GetSystemCursor(0);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = AnsweringDialogProc;
    CreateInfo.lx = 5;
    CreateInfo.ty = 140;
    CreateInfo.rx = 315;
    CreateInfo.by = 215;
    CreateInfo.iBkColor = COLOR_lightwhite;
    CreateInfo.dwAddData = 0;
    CreateInfo.hHosting = HWND_DESKTOP;
    
    //LoadBitmap (HDC_SCREEN, &bmp_bkgnd, "bkgnd.jpg");
    
    hAnswerWnd = CreateMainWindow (&CreateInfo);
    hAnswering = hAnswerWnd;
    if (hAnswerWnd == HWND_INVALID)
        return -1;

    ShowWindow(hAnswerWnd, SW_SHOWNORMAL);

    while (GetMessage(&Msg, hAnswerWnd)) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    MainWindowThreadCleanup (hAnswerWnd);

    return 0;
}

⌨️ 快捷键说明

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