minigui3.0滾動顯示字幕 源碼

#include <stdio.h>
#include <string.h>
#include <time.h>

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>





#define _ID_TIMER 100
#define _ID_TIME_STATIC 100

static char* mini_mk_time (char* buff)
{
	/* // 時鐘顯示
	time_t t;
	struct tm * tm;
	time (&t);
	tm = localtime (&t);
	sprintf (buff, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
	*/

	//滾動字幕
   static int countnumber = 0;
   char *str="Welcome to industry and commerce banking terminal station!";
   buff=str+countnumber;
   countnumber++;
   if(countnumber==strlen(str))
   countnumber=0;

	return buff;
}
static int mini_TaskBarWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	char buff [100];
	switch (message) 
	{
		case MSG_CREATE:
			CreateWindow (CTRL_STATIC, mini_mk_time (buff),
			WS_CHILD | WS_BORDER | WS_VISIBLE | SS_CENTER,
			_ID_TIME_STATIC, 10, 100, 100, 20, hWnd, 0);
					
			// 創建一個間隔爲 1 秒的定時器,其標識號爲 _ID_TIMER,接收定時器消息的窗口爲 hWnd 
			SetTimer (hWnd, _ID_TIMER, 100);
			break;

		case MSG_TIMER:
		{
			// 接收到定時器消息。
			// 嚴格的程序還應該在這裏判斷 wParam 是否等於期望的定時器標識符,這裏是
			//_ID_TIMER。

			SetDlgItemText (hWnd, _ID_TIME_STATIC, mini_mk_time (buff));
			break;
		}
		case MSG_CLOSE:
			// 刪除定時器 
			KillTimer (hWnd, _ID_TIMER);
			DestroyAllControls (hWnd);
			DestroyMainWindow (hWnd);
			PostQuitMessage (hWnd);
			return 0;
		}

	return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

int MiniGUIMain (int argc, const char* argv[])
{
   MSG Msg;
    HWND hMainWnd;
    MAINWINCREATE CreateInfo;

#ifdef _MGRM_PROCESSES
    JoinLayer(NAME_DEF_LAYER , "helloworld" , 0 , 0);
#endif

    CreateInfo.dwStyle =  WS_VISIBLE | WS_BORDER | WS_CAPTION;
	CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.spCaption = "timer";
    CreateInfo.hMenu = 0;
    CreateInfo.hCursor = GetSystemCursor(0);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = mini_TaskBarWinProc;
    CreateInfo.lx = 0;
    CreateInfo.ty = 0;
    CreateInfo.rx = 200;
    CreateInfo.by = 200;
    CreateInfo.iBkColor = COLOR_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;
}

#ifdef _MGRM_THREADS
#includ

發佈了49 篇原創文章 · 獲贊 13 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章