📄 pda_main.c
字号:
#include "sys_headfile.h"
#include <time.h>
#include <minigui/dti.c>
#include "pda_main.h"
#define IDC_EDIT_TIME 0x2001
#define DATE_TIMER 0x3001
#define IDC_MONTHDATE 0x4001
static BITMAP ntb_bmp; //工具栏相关位图
static BITMAP bmp_bkgnd;
//static char system_time[50];
static char* mk_time (char* buff)
{
time_t t;
struct tm * tm;
time (&t);
tm = localtime (&t);
sprintf(buff,"%d年%d月%d日 %d时%d分%d秒",
tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,
tm->tm_hour,tm->tm_min,tm->tm_sec);
return buff;
}
static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
if (nc == IDC_NTB_PHONEBOOK)
{
phoneBookWindows(hwnd);
}
else if(nc == IDC_NTB_CALL)
{
callMainWinCreat(hwnd);
}
}
/*--------工具栏创建函数--------*/
static void create_pdaMain_toolbar (HWND hWnd)
{
HWND ntb;
NTBINFO ntb_info;
NTBITEMINFO ntbii;
gal_pixel pixel;
ntb_info.nr_cells = 6;
ntb_info.w_cell = 37;
ntb_info.h_cell = 37;
ntb_info.nr_cols = 4;
ntb_info.image = &ntb_bmp;
/* 创建工具栏控件 */
ntb = CreateWindow (CTRL_NEWTOOLBAR,
"",
WS_CHILD | WS_VISIBLE,
100,
0, 0, 1024, 0,
hWnd,
(DWORD) &ntb_info);
/* 设置通知回调函数 */
SetNotificationCallback (ntb, my_notif_proc);
/* 设置工具栏控件的背景色,使之和按钮位图背景一致 */
pixel = GetPixelInBitmap (&ntb_bmp, 0, 0);
SetWindowBkColor (ntb, pixel);
InvalidateRect (ntb, NULL, TRUE);
/* 添加两个普通按钮 */
memset (&ntbii, 0, sizeof (ntbii));
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_PHONEBOOK;
ntbii.bmp_cell = 0;
SendMessage(ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_CALL;
ntbii.bmp_cell = 1;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_SMS;
ntbii.bmp_cell = 2;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
/* 添加分隔条 */
ntbii.flags = NTBIF_SEPARATOR;
ntbii.id = 0;
ntbii.bmp_cell = 0;
ntbii.text = NULL;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_AD;
ntbii.bmp_cell = 3;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_MEDIA;
ntbii.bmp_cell = 4;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
ntbii.flags = NTBIF_PUSHBUTTON;
ntbii.id = IDC_NTB_SYSTEM;
ntbii.bmp_cell = 5;
SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);
}
static int PdaMainWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
struct tm* pt;
time_t now_time;
char time_buf[50];
switch (message) {
case MSG_CREATE:
/* 装载工具栏使用的位图对象 */
if (LoadBitmap (HDC_SCREEN, &ntb_bmp, "images//toolbar.jpg"))
return -1;
if(LoadBitmap (HDC_SCREEN, &bmp_bkgnd, "images//main_bg.jpg"))
return -1;
create_pdaMain_toolbar (hWnd);
CreateWindow(CTRL_STATIC,
"",WS_VISIBLE | WS_BORDER,
IDC_EDIT_TIME,
40,40,240,24,
hWnd,
0);
SetTimer(hWnd,DATE_TIMER,100);
break;
case MSG_DESTROY:
UnloadBitmap (&ntb_bmp);
UnloadBitmap (&bmp_bkgnd);
DestroyAllControls (hWnd);
return 0;
case MSG_TIMER:
{
if(wParam== DATE_TIMER)
{
SetDlgItemText(hWnd,IDC_EDIT_TIME,mk_time(time_buf));
}
break;
}
case MSG_ERASEBKGND: //用图片填充背景
{
/* HDC hdc = (HDC)wParam;
BOOL fGetDC = FALSE;
hdc=(HDC)wParam;
if(hdc==0)
{
hdc=GetClientDC(hWnd);
fGetDC=1;
}
FillBoxWithBitmap(hdc,0,0,0,0,&bmp_bkgnd);
if(fGetDC)
ReleaseDC(hdc);
return 0;
*/
/* 用图片填充背景 */
// FillBoxWithBitmap (hdc, rcTemp.left, rcTemp.top, 0, 0, &bmp_bkgnd);
//if (fGetDC)
// ReleaseDC (hdc);
}
break;
case MSG_CLOSE:
KillTimer(hWnd,DATE_TIMER);
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;
}
return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
int MiniGUIMain(int argc,const char* argv[])
{
MSG Msg;
MAINWINCREATE CreateInfo;
//HWND Ophcwd;
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=PdaMainWinProc;
CreateInfo.lx=0;
CreateInfo.ty=0;
CreateInfo.rx=320;
CreateInfo.by=240;
CreateInfo.iBkColor=GetWindowElementColor (BKC_CONTROL_DEF);
CreateInfo.dwAddData=0;
CreateInfo.hHosting=HWND_DESKTOP;
MainWin=CreateMainWindow(&CreateInfo);
ShowWindow(MainWin,SW_SHOWNORMAL);
while(GetMessage(&Msg,MainWin))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainWindowThreadCleanup(MainWin);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -