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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
class ZiMupanel extends JFrame { public ZiMupanel() { Container con = this.getContentPane(); // 设置窗口名称 this.setTitle("滚动字幕"); // 设置布局管理器为 null ,方便 面板定位,一般使用null 布局时,将窗口设置不可改变大小 this.setLayout(null); // 设置窗口位置和大小 this.setBounds(300, 300, 460, 330); // 设置窗口可见 this.setVisible(true); // 设置不可改变大小 this.setResizable(false); // 设置当点击窗口的关闭按钮时退出 // 设置此窗体关闭,滚动面板不关闭 this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Panelfont1 p1 = new Panelfont1(); con.add(p1); p1.setBounds(15, 15, 175, 60); Panelfont2 p2 = new Panelfont2(); con.add(p2); p2.setBounds(195, 15, 250, 60); Panelneizi p3 = new Panelneizi(); con.add(p3); p3.setBounds(15, 80, 175, 80); Paneldirection p4 = new Paneldirection(); con.add(p4); p4.setBounds(195, 80, 250, 80); Panel5 p5 = new Panel5(); con.add(p5); p5.setBounds(15, 155, 430, 70); Panel6 p6 = new Panel6(); con.add(p6); p6.setBounds(15, 220, 430, 70); } } class Panelfont1 extends JPanel implements ActionListener{ public Panelfont1() { this.setBorder(BorderFactory.createTitledBorder("滚动字幕的文字大小控制"));//设置 面板边框 this.setLayout(new GridLayout(1, 2)); bigfont = new JRadioButton("大字体", false); smallfont = new JRadioButton("小字体", true); bigfont.addActionListener(this); smallfont.addActionListener(this); ButtonGroup sexRadioButtonGroup = new ButtonGroup();// 创建一个选按钮组 sexRadioButtonGroup.add(bigfont);// 将单选按钮对象添加到按钮组中 sexRadioButtonGroup.add(smallfont);// 将单选按钮对象添加到按钮组中 //Enumeration elements = sexRadioButtonGroup.getElements();// 遍历按钮组中的所有按钮 this.add(bigfont); this.add(smallfont); } public void actionPerformed(ActionEvent e) { if(bigfont.isSelected()){ fontSize = 50; }else { fontSize = 36; } Font font = new Font(fontName,Font.BOLD,fontSize);

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值