controlpanel.c

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

C
236
字号
#include "msgCom.h"#include "controlpanel.h"#include "panels.h"#include "fileMessage.h"#include "../gprs/gprs.h"static BITMAP jpg_bkgnd;static int myLoadBitmap (BITMAP* bm, const char* filename){    char full_path [MAX_PATH + 1];#ifndef _PASS#define _PASS    strcpy (full_path, "./image/messagepanel/");    strcat (full_path, filename);#endif    return LoadBitmap (HDC_SCREEN, bm, full_path);}static char *xmBmpName[]={"GetMSG.png","SendMSG.png","EditMSG.png","NewMSG.png","DELETE.png" ,"LogOut.png" };static char *xmTitle[]={"收信箱","发信箱","草稿箱","新信息","删除","返回"};static XMBUTTON xmButton [BTM_NUM];static int WhichBox(int x,int y){  int i;  for (i=0;i<BTM_NUM;i++)  {    if ((x>xmButton[i].x)&&(x<xmButton[i].x+xmButton[i].w)        &&(y>xmButton[i].y)&&(y<xmButton[i].y+xmButton[i].h))      return i;  }  return -1;}static int changeMode(HWND hWnd,int x,int y,int mode){  int btm=WhichBox(x,y);  int i;  RECT rect;  static int lastbtm=-1;  static int lastmode=BTM_FLAT;  if ((btm==lastbtm)&&(mode==lastmode))    return btm;  for (i=0;i<BTM_NUM;i++)  {    if(xmButton[i].mode==BTM_FLAT) continue;    xmButton[i].mode=BTM_FLAT;    rect.left=xmButton[i].x;    rect.right=xmButton[i].x+xmButton[i].w;    rect.top=xmButton[i].y;    rect.bottom=xmButton[i].y+xmButton[i].h;    InvalidateRect(hWnd,&rect,FALSE);  }  if (btm!=-1)  {    xmButton[btm].mode=mode;    rect.left=xmButton[btm].x;    rect.right=xmButton[btm].x+xmButton[btm].w;    rect.top=xmButton[btm].y;    rect.bottom=xmButton[btm].y+xmButton[btm].h;    InvalidateRect(hWnd,&rect,FALSE);  }  if(btm!=lastbtm)    InvalidateRect(hWnd,&rect,FALSE);  lastbtm = btm;  lastmode = mode;  return btm;}//////////////////////////////int LogOut(HWND hWnd){ //           if(MessageBox(hWnd,"确实要退出吗?","短信面板",MB_YESNO|MB_ICONQUESTION)==IDYES) //           {                int i;                for(i=0;i<BTM_NUM;i++)                UnloadBitmap(&(xmButton[i].bitmap));                DestroyMainWindow (hWnd);                PostQuitMessage (hWnd);                return 0; //           }}static int ControlPanelWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    static int lastdown=-1;    switch (message)    {      case MSG_CREATE:      {      }      break;      case MSG_LBUTTONDOWN:      {        lastdown = changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_DOWN );      }      break;                                                                  //      case MSG_LBUTTONUP:      {        int up = changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_FLAT );        if(up==-1) break;        if(up==lastdown)        {            OpenPanel(hWnd,up);        }      }      break;                                                                  //      case MSG_MOUSEMOVE:      {        changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_UP );      }      break;      case MSG_PAINT:      {        HDC hdc;        RECT rc;//,rect;        int i;        hdc = BeginPaint (hWnd);        GetWindowRect(hWnd,&rc);	FillBoxWithBitmap (hdc,0, 0, 320, 192, &jpg_bkgnd);                  //////////////////////////////////////        for(i=0;i<BTM_NUM;i++)        {          if(xmButton[i].mode == BTM_UP)            Draw3DUpThickFrame (hdc, xmButton[i].x,  xmButton[i].y ,                  xmButton[i].x+xmButton[i].w,xmButton[i].y+xmButton[i].h,                  PIXEL_black);///////////////////////////PIXEL_lightwhite          else  if(xmButton[i].mode == BTM_DOWN)            Draw3DDownThickFrame (hdc, xmButton[i].x,  xmButton[i].y ,                  xmButton[i].x+xmButton[i].w,xmButton[i].y+xmButton[i].h,                  PIXEL_black);/////////////////////////////PIXEL_lightwhite          FillBoxWithBitmap (hdc, xmButton[i].x+xmButton[i].bmpx,                                xmButton[i].y+xmButton[i].bmpy,                                0, 0, &xmButton[i].bitmap);//////////////////////////////////////////////////	  SetBkMode(hdc, BM_TRANSPARENT);	  SetTextColor(hdc, PIXEL_green);///////////////////////////////////////////////////          TextOut(hdc,xmButton[i].x+xmButton[i].titlex,xmButton[i].y+xmButton[i].titley,                  xmButton[i].title);        }        EndPaint (hWnd,hdc);      }      return 0;      case MSG_CLOSE:      {		LogOut(hWnd);        return 0;      }    }    return DefaultMainWinProc (hWnd, message, wParam, lParam);}static void InitControlPanelInfo (PMAINWINCREATE pCreateInfo, HWND hWnd){    pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER |                         WS_VISIBLE ;    pCreateInfo->dwExStyle =  WS_EX_IMECOMPOSE;;    pCreateInfo->spCaption = "短信面板";    pCreateInfo->hMenu = 0;    pCreateInfo->hCursor = GetSystemCursor(0);    pCreateInfo->hIcon = 0;    pCreateInfo->MainWindowProc = ControlPanelWinProc;    pCreateInfo->lx = 0;    pCreateInfo->ty = 0;    pCreateInfo->rx = 320;    pCreateInfo->by = 216;    pCreateInfo->iBkColor = PIXEL_lightwhite;    pCreateInfo->dwAddData = (DWORD)0;    pCreateInfo->hHosting = hWnd;}static void initBTMs(void){    int i,j;    for(i=0;i<BTM_NUM;i++)    {      xmButton[i].x=18+(i%3)*105;//170 +       xmButton[i].y=18 + ((int)(i/3))*85;      xmButton[i].h=75;      xmButton[i].w=67;      xmButton[i].bmpx=10;      xmButton[i].bmpy=5;      strcpy(xmButton[i].title,xmTitle[i]);      j=strlen(xmButton[i].title);      xmButton[i].titlex=(8-j)*5;      xmButton[i].titley=55;      myLoadBitmap (&(xmButton[i].bitmap),xmBmpName [i]);    }}int  ControlPanel(HWND hWnd){    MSG Msg;    MAINWINCREATE CreateInfo;    initBTMs();    InitControlPanelInfo (&CreateInfo, hWnd);	//tty_writecmd("AT+CMGF=1", strlen("AT+CMGF=1"));	LoadBitmap (HDC_SCREEN, &jpg_bkgnd, "./image/background/bkgnd29.jpg");	    hMainWnd = CreateMainWindow (&CreateInfo);    if (hMainWnd == HWND_INVALID)        return 0;    while( GetMessage(&Msg, hMainWnd) )    {        TranslateMessage(&Msg);        DispatchMessage(&Msg);    }    MainWindowThreadCleanup(hMainWnd);    return 0;}

⌨️ 快捷键说明

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