|
楼主 |
发表于 2007-4-22 00:44:36
|
显示全部楼层
- #include <stdio.h>
- #include <minigui/common.h>
- #include <minigui/minigui.h>
- #include <minigui/gdi.h>
- #include <minigui/window.h>
- #include <minigui/control.h>
- #define IDTIMER 0
- #define IDC_DISP1 1000
- #define ID_OK 1001
- #define ID_CANCEL 1002
- static DLGTEMPLATE MyDlg =
- { WS_VISIBLE | WS_BORDER,
- WS_EX_NONE,
- 512, 0, 128 ,480,
- "",
- 0, 0,
- 3,
- NULL,
- 0
- };
- static CTRLDATA CtrlInitData [] =
- {
-
- { "button",
- WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON,
- 20, 50, 80,25,
- ID_OK,
- "开始扫描",
- 0,
- WS_EX_NONE,
- },
- { "button",
- WS_VISIBLE | WS_TABSTOP,
- 20, 100, 80 ,25,
- ID_CANCEL,
- "停止扫描",
- 0,
- WS_EX_NONE,
- },
- { "static",
- WS_VISIBLE | SS_SIMPLE,
- 10, 300, 110 ,16,
- IDC_DISP1,
- "欢迎使用MiniGUI" ,
- 0,
- WS_EX_NONE
- }
- };
- static int MyDlgProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
- {
- HWND hWnd;
- switch (message)
- {
- case MSG_INITDIALOG:
- return 1;
- case MSG_COMMAND:
- switch (wParam)
- {
-
- case ID_OK:
- SetTimer(hDlg, IDTIMER, 100);
- break;
-
-
- case ID_CANCEL:
- KillTimer(hDlg, IDTIMER);
- break;
- case MSG_TIMER:
- // PostMessage(GetParent, MSG_TIMER,0L, (LPARAM)IDTIMER);
- // PostMessage(GetParent(), MSG_ERASEBKGND,0L, (LPARAM)IDTIMER);
- // PostMessage(GetParent(HWND hWnd), MSG_ERASEBKGND,0L, 0L);
- // PostMessage(GetMainWindowHandle(HWND hWnd), MSG_ERASEBKGND,0L, 0L);
-
- PostMessage(GetMainWindowHandle(GetParent()), MSG_ERASEBKGND,0L, 0L);
- /* 各种表达方式都试过了,还是不成功 */
- default:
- break;
- }
- break;
-
- default:
- return DefaultDialogProc(hDlg, message, wParam, lParam);
- }
- return 0;
- }
- static void InitDialogBox(HWND hWnd)
- { MyDlg.controls = CtrlInitData;
- DialogBoxIndirectParam(&MyDlg, hWnd, MyDlgProc, 0L);
- }
- static int WinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
- {
- HDC hdc;
- static BITMAP s_bmp;
- static char bmpno[] = "00.jpg";
- RECT rc = {0,0,512,480};
- switch (message) {
- case MSG_CREATE:
- LoadBitmapFromFile(HDC_SCREEN, &s_bmp, bmpno);
- hdc = BeginPaint (hWnd);
- FillBoxWithBitmap (hdc, 0, 0, 512, 480, &s_bmp);
- EndPaint(hWnd, hdc);
- InitDialogBox(hWnd);
- return 0;
-
- case MSG_ERASEBKGND:
- if(bmpno[1] == '9')
- { bmpno[0] = bmpno[0]+1;
- bmpno[1] = '0';
- }
- else
- {bmpno[1] = bmpno[1]+1;}
-
- LoadBitmapFromFile(HDC_SCREEN, &s_bmp, bmpno);
- hdc = BeginPaint (hWnd);
- FillBoxWithBitmap (hdc, 0, 0, 512, 480, &s_bmp);
- EndPaint(hWnd, hdc);
-
- if(bmpno[0] == '3' && bmpno[1] == '1')
- {
- bmpno[0] = '0';
- bmpno[1] = '0';
- }
-
- return 0;
-
- default:
- return DefaultMainWinProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
- int MiniGUIMain (int argc, const char* argv[])
- {
- MSG Msg;
- HWND hMainWnd;
- MAINWINCREATE CreateInfo;
- #ifdef _LITE_VERSION
- SetDesktopRect(0, 0, 800, 600);
- #endif
- CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER;
- CreateInfo.dwExStyle = WS_EX_NONE;
- CreateInfo.spCaption = "";
- CreateInfo.hMenu = 0;
- CreateInfo.hCursor = GetSystemCursor(0);
- CreateInfo.hIcon = 0;
- CreateInfo.MainWindowProc = WinProc;
- CreateInfo.lx = 0;
- CreateInfo.ty = 0;
- CreateInfo.rx = 640;
- CreateInfo.by = 480;
- CreateInfo.iBkColor = PIXEL_lightwhite;
- CreateInfo.dwAddData = 0;
- CreateInfo.hHosting = HWND_DESKTOP;
-
- hMainWnd = CreateMainWindow (&CreateInfo);
-
- if (hMainWnd == HWND_INVALID)
- return -1;
- ShowWindow(hMainWnd, SW_SHOWNORMAL);
- while (GetMessage(&Msg, hMainWnd)) {
- TranslateMessage(&Msg);
-
- DispatchMessage(&Msg);
- }
- MainWindowThreadCleanup (hMainWnd);
- return 0;
- }
- #ifndef _LITE_VERSION
- #include <minigui/dti.c>
- #endif
复制代码
这个代码进行图片的循环显示什么的都没有问题
问题只有一个
就是不能把消息发到主窗口
我想问题出在标注汉字的地方吧 |
|