📄 work.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mgext.h>#include <minigui/filedlg.h>#define IDC_ICONVIEW 100#define IDC_BUTTON 200#define IDC_NEXT 101#define IDC_PRIVIOUS 102 #define IDC_OPEN 103#define IDC_BIG 300#define IDC_SMALL 301typedef struct tagFILEITEM{int i;char name[NAME_MAX];struct tagFILEITEM* previous; struct tagFILEITEM* next; }FILEITEM;static HWND hIconView;static BITMAP myicons [128];static int xx;HWND hdc=0;static float rate=1;static BITMAP bmp[2],mybmp;static HWND hIconView;static const char* filename = "res/myopen.gif";static const char* filename1 = "res/bk.gif";ANIMATION* anim,anim3,anim4;static struct toolbar_items{ int id; char* name;} toolbar_items [] ={ {IDC_BIG,"big"}, {IDC_SMALL,"small"}};static char* iconfiles[5] ={ "res/acroread.png", "res/icons.png","res/bk.jpg","res/next.jpg","res/next.jpg" };static const char* iconlabels[2] ={ "acroread", "icons" };static CTRLDATA CtrlBook[] ={ { CTRL_ICONVIEW, WS_BORDER | WS_CHILD | WS_VISIBLE |WS_HSCROLL|WS_EX_TRANSPARENT, 100, 120, 480, 210, IDC_ICONVIEW, "", 0 },{ CTRL_BUTTON , WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP | BS_BITMAP, 360, 330, 50, 30, IDC_NEXT, "NEXT", (DWORD)&myicons[126] }, { CTRL_BUTTON, WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP | BS_BITMAP,//WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 310, 330, 50, 30, IDC_PRIVIOUS, "PRI", &myicons[124] },{ CTRL_BUTTON, WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP | BS_BITMAP, 260, 330, 50, 30, IDC_OPEN, "OPEN", &myicons[127] }};static DLGTEMPLATE DlgIcon ={ WS_BORDER , WS_EX_NONE, 0, 0, 640, 480, "!!!!", 0, 0, TABLESIZE(CtrlBook), CtrlBook, &myicons[2]};static BOOL IsSupport (const char *filename){ char *extend,*temp; extend = rindex(filename,'.'); if (extend ==NULL) return FALSE; extend++; temp = extend; while (*temp) { *temp = tolower(*temp); temp++; } if(#ifdef _JPG_FILE_SUPPORT !strncmp(extend,"JPG",3) ||#endif#ifdef _GIF_FILE_SUPPORT !strncmp(extend,"gif",3) ||#endif#ifdef _PCX_FILE_SUPPORT !strncmp(extend,"pcx",3) ||#endif#ifdef _LBM_FILE_SUPPORT !strncmp(extend,"lbm",3) ||#endif#ifdef _TGA_FILE_SUPPORT !strncmp(extend,"tga",3) ||#endif#ifdef _PNG_FILE_SUPPORT !strncmp(extend,"png",3) ||#endif !strncmp(extend,"bmp",3) ) return TRUE; return FALSE;} static void ReleaseList(FILEITEM *head){ FILEITEM *temp; while(head) { temp = head->next; free (head); head = temp; }}static int showmyWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ RECT rect; GetClientRect(hWnd,&rect); int count; static int iStart = 0; static int iStartPos = 0; static int x=0,y=0; int max_x,max_y; FILEDLGDATA myWinFileData; switch (message) { case MSG_CREATE: { HWND hTool; DWORD WdHt = MAKELONG (16, 22); hTool= CreateWindow ("toolbar", " ", WS_CHILD | WS_VISIBLE , 0, 1, 1, 45, 15, hWnd, WdHt); int m; char chtmp[MAX_PATH+1]; TOOLBARITEMINFO pData; strcpy (chtmp, "res/"); for (m= 0; m< 2; m++) { pData.id = toolbar_items[m].id; //fprintf(stderr,"inittoolbar%d",toolbar_items[m].id); pData.insPos = m+ 1; sprintf (pData.NBmpPath, "%s%s%s", chtmp, toolbar_items [m].name, "1.bmp");#if 0 pData.HBmpPath [0] = '\0'; pData.DBmpPath [0] = '\0';#else sprintf (pData.HBmpPath, "%s%s%s", chtmp, toolbar_items [m].name, "2.bmp"); sprintf (pData.DBmpPath, "%s%s%s", chtmp, toolbar_items [m].name, "3.bmp");#endif SendMessage (hTool, TBM_ADDITEM, 0, (LPARAM)&pData); } while(myicons[xx].bmWidth*rate>640) rate=rate/2; hdc = BeginPaint (hWnd); max_x = GetGDCapability(hdc,GDCAP_MAXX); max_y = GetGDCapability(hdc,GDCAP_MAXY); x = (max_x - myicons[xx].bmWidth*rate)/2; y = (max_y - myicons[xx].bmHeight*rate)/2; FillBoxWithBitmap(hdc,x,y,myicons[xx].bmWidth*rate, myicons[xx].bmHeight*rate,&myicons[xx]); EndPaint (hWnd, hdc); } case MSG_COMMAND: //switch(wParam) //return -1; switch(HIWORD(wParam)){ case IDC_BIG: { if(hdc!=0) { InvalidateRect(hWnd,&rect,TRUE); hdc=BeginPaint(hWnd); (rate<4)? (rate*=1.2 ): (rate=1 ); while(myicons[xx].bmWidth*rate>640) rate=rate/1.2; max_x = GetGDCapability(hdc,GDCAP_MAXX); max_y = GetGDCapability(hdc,GDCAP_MAXY); x = (max_x - myicons[xx].bmWidth*rate)/2; y = (max_y - myicons[xx].bmHeight*rate)/2; FillBoxWithBitmap(hdc,x,y,myicons[xx].bmWidth*rate, myicons[xx].bmHeight*rate,&myicons[xx]); EndPaint(hWnd,hdc); } } break; case IDC_SMALL: { if( hdc!=0) { InvalidateRect(hWnd,&rect,TRUE); hdc=BeginPaint(hWnd); (rate>0.25)? (rate/=1.2 ): (rate=1 ); while(myicons[xx].bmWidth*rate>640) rate=rate/2; max_x = GetGDCapability(hdc,GDCAP_MAXX); max_y = GetGDCapability(hdc,GDCAP_MAXY); x = (max_x - myicons[xx].bmWidth*rate)/2; y = (max_y - myicons[xx].bmHeight*rate)/2; FillBoxWithBitmap(hdc,x,y,myicons[xx].bmWidth*rate, myicons[xx].bmHeight*rate,&myicons[xx]); EndPaint(hWnd,hdc); } return 0; } } break; //////////////////////////////////////////////////////////////// case MSG_RBUTTONDOWN: DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; case MSG_CLOSE: DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc(hWnd, message, wParam, lParam);}static FILEITEM * findmatchfile(FILEDLGDATA *one, FILEITEM **cur ){ struct dirent *pDir; DIR *dir; struct stat ftype; char fullpath [PATH_MAX + NAME_MAX + 1]; FILEITEM *head = NULL; FILEITEM *temp = NULL; dir = opendir (one->filepath); while ( (pDir = readdir ( dir )) != NULL ) { strncpy (fullpath, one->filepath, PATH_MAX); if ( fullpath[ strlen(fullpath) - 1 ] != '/' ) strcat (fullpath, "/"); strcat (fullpath, pDir->d_name); if (lstat (fullpath, &ftype) < 0 ){ Ping(); continue; } if ( S_ISREG(ftype.st_mode) && IsSupport(pDir->d_name) ) { if( temp == NULL ) { temp = (FILEITEM *) malloc(sizeof(FILEITEM)); temp->previous = NULL; temp->next = NULL; strcpy ( temp->name, fullpath); head = temp; } else { temp->next = (FILEITEM *) malloc(sizeof(FILEITEM)); temp->next->previous = temp; temp->next->next = NULL; temp = temp->next; strcpy ( temp->name, fullpath); } /*indicate current file pointer*/ if ( !strcmp( pDir->d_name, one->filename ) ) *cur = temp; } } closedir(dir); return head;}int showmy(int ss,HWND hDlg){ xx=ss; MSG Msg; HWND hMainWnd; MAINWINCREATE CreateInfo;#ifdef _MGRM_PROCESSES JoinLayer(NAME_DEF_LAYER , "loadbmp" , 0 , 0);#endif CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER|WS_HSCROLL|WS_VSCROLL; CreateInfo.dwExStyle = WS_EX_NONE | WS_EX_IMECOMPOSE; CreateInfo.spCaption = "Load and display a bitmap"; CreateInfo.hMenu = 0; CreateInfo.hCursor = GetSystemCursor(0); CreateInfo.hIcon = 0; CreateInfo.MainWindowProc = showmyWinProc; CreateInfo.lx = 0; CreateInfo.ty =0; CreateInfo.rx = 640; CreateInfo.by = 480; CreateInfo.iBkColor =0XECECEC; CreateInfo.dwAddData = 0; CreateInfo.hHosting = hDlg; hMainWnd = CreateMainWindow (&CreateInfo); if (hMainWnd == HWND_INVALID)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -