readmessage.c

来自「minigui PDA系统 可实现手机功能」· C语言 代码 · 共 317 行

C
317
字号
#ifndef _READMSG_C
#define _READMSG_C
#include "msgCom.h"

#include "message.h"
#include "fileMessage.h"
#include "../mybuttonreg.h"
#include "../telbook/telbook.h"
#include "../tel/call_time.h"

#define  IDC_RM_MLEDIT              0x5000
#define  IDC_RM_BUT_REPLY        0x5001
#define  IDC_RM_BUT_RECALL      0x5002
#define  IDC_RM_BUT_RETURN	    0x5003
#define  IDC_RM_BUT_NUM	    0x5004
#define  IDC_RM_BUT_SEND         0X5005


static BITMAP reply_pushed;
static BITMAP reply_unpushed;
static BITMAP reply_mousemove;

static BITMAP recall_pushed;
static BITMAP recall_unpushed;
static BITMAP recall_mousemove;

static BITMAP getnum_pushed;
static BITMAP getnum_unpushed;
static BITMAP getnum_mousemove;

static BITMAP resend_pushed;
static BITMAP resend_unpushed;
static BITMAP resend_mousemove;

static BITMAP Rreturn_pushed;
static BITMAP Rreturn_unpushed;
static BITMAP Rreturn_mousemove;

BITMAP jpg_bkgnd_RM;

HWND RMhWnd;
HWND 	hCtrl_reply;
HWND 	hCtrl_recall;
HWND 	hCtrl_getnum;
HWND 	hCtrl_resend;
HWND 	hCtrl_Rreturn;


////////////////////////////读信息////////////////////////////////////
static void emLoadBitmap()
{
	LoadBitmap (HDC_SCREEN, &reply_pushed, "image/button/msg_reply_pushed.jpg");
       LoadBitmap (HDC_SCREEN, &reply_unpushed, "image/button/msg_reply_unpushed.jpg");
       LoadBitmap (HDC_SCREEN, &reply_mousemove, "image/button/msg_reply_mousemove.jpg");	

	LoadBitmap (HDC_SCREEN, &recall_pushed, "image/button/msg_recall_pushed.jpg");
       LoadBitmap (HDC_SCREEN, &recall_unpushed, "image/button/msg_recall_unpushed.jpg");
       LoadBitmap (HDC_SCREEN, &recall_mousemove, "image/button/msg_recall_mousemove.jpg");

	LoadBitmap (HDC_SCREEN, &getnum_pushed, "image/button/msg_getnum_pushed.jpg");
       LoadBitmap (HDC_SCREEN, &getnum_unpushed, "image/button/msg_getnum_unpushed.jpg");
       LoadBitmap (HDC_SCREEN, &getnum_mousemove, "image/button/msg_getnum_mousemove.jpg");	

	LoadBitmap (HDC_SCREEN, &resend_pushed, "image/button/msg_resend_pushed.jpg");
       LoadBitmap (HDC_SCREEN, &resend_unpushed, "image/button/msg_resend_unpushed.jpg");
       LoadBitmap (HDC_SCREEN, &resend_mousemove, "image/button/msg_resend_mousemove.jpg");	

	LoadBitmap (HDC_SCREEN, &Rreturn_pushed, "image/button/msg_return_pushed.jpg");
       LoadBitmap (HDC_SCREEN, &Rreturn_unpushed, "image/button/msg_return_unpushed.jpg");
       LoadBitmap (HDC_SCREEN, &Rreturn_mousemove, "image/button/msg_return_mousemove.jpg");	
}
static void emUnLoadBitmap()
{
	 UnloadBitmap (&reply_pushed);
        UnloadBitmap (&reply_unpushed);
        UnloadBitmap (&reply_mousemove);

	 UnloadBitmap (&recall_pushed);
        UnloadBitmap (&recall_unpushed);
        UnloadBitmap (&recall_mousemove);

	 UnloadBitmap (&getnum_pushed);
        UnloadBitmap (&getnum_unpushed);
        UnloadBitmap (&getnum_mousemove);

	 UnloadBitmap (&resend_pushed);
        UnloadBitmap (&resend_unpushed);
        UnloadBitmap (&resend_mousemove);

	 UnloadBitmap (&Rreturn_pushed);
        UnloadBitmap (&Rreturn_unpushed);
        UnloadBitmap (&Rreturn_mousemove);
}
static void rm_notify_proc (HWND hwnd, int id, int nc, DWORD add_data)
{		
	if ( hwnd == hCtrl_reply&& nc == MYBUTTON_PUSHED)
	{		
		SetWindowAdditionalData(hwnd, (DWORD)&reply_pushed);
	}
	if ( hwnd == hCtrl_reply && nc == MYBUTTON_UNPUSHED)
	{
		SetWindowAdditionalData(hwnd, (DWORD)&reply_unpushed);
		SendNotifyMessage(RMhWnd,IDC_RM_BUT_REPLY ,0,0);
	}
	if( hwnd == hCtrl_reply && nc == MYBUTTON_MOUSEMOVE)
	{	
		SetWindowAdditionalData(hwnd, (DWORD)&reply_mousemove);
	}
//-----------------------------------------------------------
	if ( hwnd == hCtrl_recall&& nc == MYBUTTON_PUSHED)
	{		
		SetWindowAdditionalData(hwnd, (DWORD)&recall_pushed);
	}
	if ( hwnd == hCtrl_recall&& nc == MYBUTTON_UNPUSHED)
	{
		SetWindowAdditionalData(hwnd, (DWORD)&recall_unpushed);
		SendNotifyMessage(RMhWnd,IDC_RM_BUT_RECALL,0,0);
	}
	if( hwnd == hCtrl_recall&& nc == MYBUTTON_MOUSEMOVE)
	{	
		SetWindowAdditionalData(hwnd, (DWORD)&recall_mousemove );
	}
//-----------------------------------------------------------------------	
	if ( hwnd == hCtrl_getnum&& nc == MYBUTTON_PUSHED)
	{		
		SetWindowAdditionalData(hwnd, (DWORD)&getnum_pushed);
	}
	if ( hwnd == hCtrl_getnum&& nc == MYBUTTON_UNPUSHED)
	{
		SetWindowAdditionalData(hwnd, (DWORD)&getnum_unpushed);
		SendNotifyMessage(RMhWnd,IDC_RM_BUT_NUM,0,0);
	}
	if( hwnd == hCtrl_getnum && nc == MYBUTTON_MOUSEMOVE)
	{	
		SetWindowAdditionalData(hwnd, (DWORD)&getnum_mousemove );
	}
//---------------------------------------------------------------------------
	if ( hwnd == hCtrl_resend&& nc == MYBUTTON_PUSHED)
	{		
		SetWindowAdditionalData(hwnd, (DWORD)&resend_pushed);
	}
	if ( hwnd == hCtrl_resend&& nc == MYBUTTON_UNPUSHED)
	{
		SetWindowAdditionalData(hwnd, (DWORD)&resend_unpushed);
		SendNotifyMessage(RMhWnd,IDC_RM_BUT_SEND,0,0);
	}
	if( hwnd == hCtrl_resend && nc == MYBUTTON_MOUSEMOVE)
	{	
		SetWindowAdditionalData(hwnd, (DWORD)&resend_mousemove );
	}
//---------------------------------------------------------------------------
	if ( hwnd == hCtrl_Rreturn&& nc == MYBUTTON_PUSHED)
	{		
		SetWindowAdditionalData(hwnd, (DWORD)&Rreturn_pushed);
	}
	if ( hwnd == hCtrl_Rreturn&& nc == MYBUTTON_UNPUSHED)
	{
		SetWindowAdditionalData(hwnd, (DWORD)&Rreturn_unpushed);
		SendNotifyMessage(RMhWnd,MSG_CLOSE,0,0);
	}
	if( hwnd == hCtrl_Rreturn && nc == MYBUTTON_MOUSEMOVE)
	{	
		SetWindowAdditionalData(hwnd, (DWORD)&Rreturn_mousemove );
	}
//---------------------------------------------------------------------------
	InvalidateRect (hwnd, NULL, TRUE);
}
/////////////////////

static int ReadMSGProc(HWND RMhWnd, int message, WPARAM wParam, LPARAM lParam)
{
	    HDC hdc = (HDC)wParam;
	    const RECT* clip = (const RECT*) lParam;
	    BOOL fGetDC = FALSE;
	    RECT rcTemp;
    switch(message)
    {
        case MSG_CREATE:
		emLoadBitmap();
            /* CreateWindow (CTRL_MLEDIT,
                    "",WS_CHILD |WS_BORDER | WS_VISIBLE | WS_VSCROLL | ES_AUTOWRAP | ES_BASELINE|ES_READONLY ,
                    IDC_RM_MLEDIT,20,30,180,110,RMhWnd,0); */
       	CreateWindowEx (CTRL_MLEDIT,
                    "",WS_CHILD |WS_BORDER | WS_VISIBLE | WS_VSCROLL | ES_AUTOWRAP | ES_BASELINE|ES_READONLY ,WS_EX_TRANSPARENT,
                    IDC_RM_MLEDIT,20,30,180,110,RMhWnd,0); 

		hCtrl_reply = CreateWindowEx(CTRL_MYBUTTON, 
										"回复",WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT,IDC_RM_BUT_REPLY, 220,30,60,28, RMhWnd, (DWORD)&reply_unpushed);
		hCtrl_recall = CreateWindowEx(CTRL_MYBUTTON, 
										"回电",WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT,IDC_RM_BUT_RECALL, 220,80,60,28, RMhWnd, (DWORD)&recall_unpushed);
	       hCtrl_resend = CreateWindowEx(CTRL_MYBUTTON, 
										"转发",WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT,IDC_RM_BUT_SEND, 118,148,80,28, RMhWnd, (DWORD)&resend_unpushed);
		hCtrl_getnum = CreateWindowEx(CTRL_MYBUTTON, 
										"提取号码",WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT,IDC_RM_BUT_NUM, 18,148,80,28, RMhWnd, (DWORD)&getnum_unpushed);	      
              hCtrl_Rreturn= CreateWindowEx(CTRL_MYBUTTON, 
										"返回",WS_VISIBLE | WS_CHILD, WS_EX_TRANSPARENT,IDC_RM_BUT_RETURN, 218,148,80,28, RMhWnd,(DWORD)&Rreturn_unpushed);

			SetNotificationCallback ( hCtrl_reply, rm_notify_proc );
			SetNotificationCallback ( hCtrl_recall, rm_notify_proc );
			SetNotificationCallback ( hCtrl_resend, rm_notify_proc );
			SetNotificationCallback ( hCtrl_getnum, rm_notify_proc );
			SetNotificationCallback ( hCtrl_Rreturn, rm_notify_proc );
			////////////////////////////////////////////////////////////////
			 GetMsgFp=fopen("data/GetMsg.txt","r");
			 while(GetMsgIndex+1)
			 	{
        		 	 	fread(&GetMsgTxt,sizeof(msg),1,GetMsgFp);
					 GetMsgIndex--;
			 	}
			         SetWindowText(GetDlgItem(RMhWnd,IDC_RM_MLEDIT),GetMsgTxt.txt);
					 printf ("%s\n",GetMsgTxt.number);
					 printf ("%s\n",GetMsgTxt.time);
					 printf ("%s\n",GetMsgTxt.txt);
			fclose (GetMsgFp);
			//////////////////////////////////////////////////////////////////////
             return 0;
			case MSG_MOUSEMOVE:
				SetWindowAdditionalData( hCtrl_reply, (DWORD)&reply_unpushed );
				InvalidateRect (hCtrl_reply, NULL, TRUE);
				SetWindowAdditionalData( hCtrl_recall, (DWORD)&recall_unpushed );
				InvalidateRect (hCtrl_recall, NULL, TRUE);
				SetWindowAdditionalData( hCtrl_resend, (DWORD)&resend_unpushed );
				InvalidateRect (hCtrl_resend, NULL, TRUE);
				SetWindowAdditionalData( hCtrl_getnum, (DWORD)&getnum_unpushed );
				InvalidateRect (hCtrl_getnum, NULL, TRUE);
				SetWindowAdditionalData( hCtrl_Rreturn, (DWORD)&Rreturn_unpushed );
				InvalidateRect (hCtrl_Rreturn, NULL, TRUE);	
				break;
		case MSG_ERASEBKGND:
	    		if (hdc == 0) {
				hdc = GetClientDC (RMhWnd);
				fGetDC = TRUE;
	 		   }       
		    
	    		if (clip) {
				rcTemp = *clip;
				ScreenToClient (RMhWnd, &rcTemp.left, &rcTemp.top);
				ScreenToClient (RMhWnd, &rcTemp.right, &rcTemp.bottom);
				IncludeClipRect (hdc, &rcTemp);
	    		}

//	  		  FillBoxWithBitmap (hdc, rcTemp.left, rcTemp.top, 0, 0, &jpg_bkgnd_RM);
			FillBoxWithBitmap (hdc, 0, 0, 320, 192, &jpg_bkgnd_RM );
	    		if (fGetDC)
				ReleaseDC (hdc);
	 		   return 0;
                 case IDC_RM_BUT_REPLY: 
				 newmsflag = 1;
				 NewMSG(RMhWnd);

                 	     return 0;	     
                 case IDC_RM_BUT_RECALL: 
				 strcpy ( buffernum, &GetMsgTxt.number[3]);
				 printf ("buffernum%s\n",buffernum);
				DialDialog(RMhWnd);
                 	     return 0;
                 case IDC_RM_BUT_SEND: 
				newmsflag = 5;
				NewMSG(RMhWnd);
                 	     return 0;	
                 case IDC_RM_BUT_NUM: 
			strcpy(tem_num, &GetMsgTxt.number[3]);
            	  	  addItem(RMhWnd);
                 	     return 0;	
   	
         case MSG_DESTROY:
        	   DestroyAllControls(RMhWnd);
             return 0; 
        case MSG_CLOSE:
	      emUnLoadBitmap();
             DestroyMainWindow(RMhWnd);
             PostQuitMessage(RMhWnd);
             return 0;
    }
    return DefaultMainWinProc(RMhWnd,message,wParam,lParam);
}
//^^^^^^^^^^^^^^^^^^^读信息^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

int  ReadMSG(HWND hWnd)
{
    MSG Msg;
    MAINWINCREATE CreateInfo;

    RegisterMyButtonControl ();
    CreateInfo.dwStyle=WS_VISIBLE | WS_BORDER | WS_CAPTION;
    CreateInfo.dwExStyle=WS_EX_NONE;
    CreateInfo.spCaption="读信息";
    CreateInfo.hMenu=0;
    CreateInfo.hCursor=GetSystemCursor(IDC_ARROW);
    CreateInfo.hIcon=0;
    CreateInfo.MainWindowProc=ReadMSGProc;
    CreateInfo.lx=0;
    CreateInfo.ty=0;
    CreateInfo.rx=320;
    CreateInfo.by=216;
    CreateInfo.iBkColor=GetWindowElementColor (BKC_CONTROL_DEF);
    CreateInfo.dwAddData=0;
    CreateInfo.hHosting=hWnd;
    LoadBitmap (HDC_SCREEN, &jpg_bkgnd_RM, "./image/background/bkgnd29.jpg");
    RMhWnd=CreateMainWindow(&CreateInfo); 
    ShowWindow(RMhWnd,SW_SHOWNORMAL);
    while(GetMessage(&Msg,RMhWnd)) 
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    MainWindowThreadCleanup(RMhWnd);
    UnloadBitmap (&jpg_bkgnd_RM);
    UnregisterMyButtonControl ();
    return 0;    
}

#endif

//////////////////////读信息//////////////////////////////////////////////////

⌨️ 快捷键说明

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