📄 desktop.c
字号:
/*************************************************************** DeskTop of ARM300-S created by zhang kaohua 2004,3,22 edited by ZOU JIAN GUO 2004-4-22 ****************************************************************/#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include "windows.h"#include "wintern.h"#include "wintools.h"#include "device.h"#define APPCLASS "test"int run_cmd(int cmd);int creat_button(HWND hwnd);LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wp, LPARAM lp);HWND CreateAppWindow(void);int retval=0;extern MWIMAGEHDR image_car8;extern MWIMAGEHDR image_penguin;extern MWIMAGEHDR image_microwin;/******************************************************************************/int RegisterAppClass(void){ WNDCLASS wc; wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = 0; wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/ wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/ wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPCLASS; return RegisterClass( &wc);}/******************************************************************************/HWND CreateAppWindow(void){ HWND hwnd; int width, height; RECT r; static int nextid = 0; GetWindowRect(GetDesktopWindow(), &r); width=320; height=240; hwnd = CreateWindowEx(WS_EX_LAYERED, APPCLASS, "NETARM3000 www.up-tech.com", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, width, height, NULL, (HMENU)++nextid, NULL, NULL); return hwnd;}/******************************************************************************/LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp){ PAINTSTRUCT ps; HWND sibwp; HDC hdcMem=NULL; HDC hdc=NULL; HBITMAP hbmp, hbmpOrg; HBRUSH hbr; RECT rc; int ret; //get the value of function system() extern int mwpaintSerial; MwRegisterButtonControl(NULL); MwRegisterListboxControl(NULL); switch(msg) { case WM_ERASEBKGND: return 1; case WM_PAINT: mwforceNCpaint = TRUE; // repaint lower windows before alpha blending this window ++hwnd->unmapcount; //tricky don't clip this window SendMessage(rootwp, WM_PAINT, 0, 0); for(sibwp=hwnd->siblings; sibwp; sibwp=sibwp->siblings) //???? SendMessage(sibwp, WM_PAINT, 0, 0); --hwnd->unmapcount; // then queue repaint for higher windows for(sibwp=hwnd->parent->children; sibwp != hwnd; sibwp=sibwp->siblings) // don't paint if already painted by above code if(sibwp->paintSerial != mwpaintSerial) PostMessage(sibwp, WM_PAINT, 0, 0); // now paint this window offscreen and blend with screen hdc=BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); // redirect painting to offscreen dc hdcMem = CreateCompatibleDC(ps.hdc); hbmp = CreateCompatibleBitmap(hdcMem, rc.right, rc.bottom); hbmpOrg = SelectObject(hdcMem, hbmp); // paint window to offscreen hbr = (HBRUSH)GetClassLong(hwnd, GCL_HBRBACKGROUND); FillRect(hdcMem, &rc, hbr); SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT)); SetBkMode(hdcMem, TRANSPARENT); DeleteObject(SelectObject(hdcMem, hbmpOrg)); DeleteDC(hdcMem); EndPaint(hwnd, &ps); creat_button(hwnd); break; case WM_COMMAND: ret=run_cmd(LOWORD(wp)); if(ret==0) exit(0); else exit(1); break; default: return DefWindowProc( hwnd, msg, wp, lp); } return( 0);}/******************************************************************************/int creat_button(HWND hwnd){ int mode=WS_CHILD | WS_VISIBLE | WS_BORDER; CreateWindowEx(0L, "BUTTON", "DRAW", mode, 20, 145, 60, 20, hwnd, (HMENU)1, NULL, NULL); CreateWindowEx(0L, "BUTTON", "TPDRAW",mode, 90, 145, 60, 20, hwnd, (HMENU)2, NULL, NULL); CreateWindowEx(0L, "BUTTON", "EVENT", mode, 160, 145, 60, 20, hwnd, (HMENU)3, NULL, NULL); CreateWindowEx(0L, "BUTTON", "MINE", mode, 230, 145, 60, 20, hwnd, (HMENU)4, NULL, NULL); CreateWindowEx(0L, "BUTTON", "AD", mode, 20, 170, 60, 20, hwnd, (HMENU)5, NULL, NULL); CreateWindowEx(0L, "BUTTON", "MP3PLAY", mode, 90, 170, 60, 20, hwnd, (HMENU)6, NULL, NULL); CreateWindowEx(0L, "BUTTON", "WAVPLAY",mode, 160, 170, 60, 20, hwnd, (HMENU)7, NULL, NULL); CreateWindowEx(0L, "BUTTON","Motor",mode, 230, 170, 60, 20, hwnd, (HMENU)8, NULL, NULL); CreateWindowEx(0L, "BUTTON", "HTTPD",mode, 20, 195, 60, 20, hwnd, (HMENU)9, NULL, NULL); CreateWindowEx(0L, "BUTTON", "LED",mode, 90, 195, 60, 20, hwnd, (HMENU)10, NULL, NULL); CreateWindowEx(0L, "BUTTON", "FONT",mode, 160, 195, 60, 20, hwnd, (HMENU)11, NULL, NULL); CreateWindowEx(0L, "BUTTON", "QUIT",mode, 230, 195, 60, 20, hwnd, (HMENU)12, NULL, NULL); return 0; } /******************************************************************************/int run_cmd(int cmd){ int ret=0; //get the value of function system() switch(cmd){ case 1: ret=system("/mnt/yaffs/mw/demodraw"); SendMessage(rootwp, WM_PAINT, 0, 0); break; case 2: ret=system("/mnt/yaffs/mw/demotpdraw"); break; case 3: ret=system("/mnt/yaffs/mw/demoevent"); break; case 4: ret=system("/mnt/yaffs/mw/mine"); break; case 5: ret=system("/mnt/yaffs/exp/acq"); break; case 6: ret=system("/mnt/yaffs/sound/madplay /mnt/yaffs/sound/1.mp3"); break; case 7: ret=system("/mnt/yaffs/sound/wavplay /mnt/yaffs/sound/1.wav"); break; case 8: ret=system("/mnt/yaffs/exp/motor"); break; case 9: ret=system("cd /mnt/yaffs/web; /mnt/yaffs/web/httpd; cd .."); break; case 10: ret=system("/mnt/yaffs/exp/led"); sleep(2); ret=system("/mnt/yaffs/exp/led 12345678"); sleep(2); ret=system("/mnt/yaffs/exp/led fedcba"); break; case 11: ret=system("cd /mnt/yaffs/font; /mnt/yaffs/font/demofont;cd .."); break; case 12: ret=1; break; default: break; } retval=ret; return ret;}/******************************************************************************/int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ MSG msg; HWND hwnd; mwERASEMOVE = FALSE; RegisterAppClass(); MwSetDesktopWallpaper(&image_microwin); UpdateWindow(GetDesktopWindow()); hwnd=CreateAppWindow(); ShowWindow(hwnd,SW_SHOWMAXIMIZED); while( GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } DestroyWindow(hwnd); DestroyWindow(GetDesktopWindow()); return retval;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -