#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.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_TIME_STATIC 110
#define _ID_TIMER 100
static PLOGFONT logfont_rbf_gb12_song,logfont_rbf_gb16_song;//创建逻辑字体
static char* 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);
return buff;
}
static int TaskBarWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
char buff [20];
HDC hdc,timeedit;
switch (message) {
case MSG_CREATE:
{
timeedit=CreateWindow (CTRL_STATIC, mk_time (buff), WS_CHILD | WS_BORDER | WS_VISIBLE | SS_CENTER,_ID_TIME_STATIC,0, 550, 284, 50, hWnd, 0);
logfont_rbf_gb12_song = CreateLogFont("ttf", "simsun", "UTF-8",
FONT_WEIGHT_DEMIBOLD, FONT_SLANT_ROMAN,
FONT_FLIP_NIL, FONT_OTHER_AUTOSCALE,
FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE, 40, 0);
logfont_rbf_gb16_song = CreateLogFont ("rbf", "song", "GB2312-0",
FONT_WEIGHT_BOOK, FONT_SLANT_ROMAN,
FONT_FLIP_NIL, FONT_OTHER_AUTOSCALE,
FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,
32, 0);
SetWindowFont (timeedit, logfont_rbf_gb16_song);
SetTimer (hWnd, _ID_TIMER, 100);
break;
}
break;
case MSG_TIMER:
{
SetDlgItemText (hWnd, _ID_TIME_STATIC, 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[])
{
MAINWINCREATE CreateInfo;
HWND hMainWnd;
MSG Msg;
CreateInfo.dwStyle = WS_ABSSCRPOS | WS_VISIBLE|WS_CAPTION;
CreateInfo.dwExStyle = WS_EX_TOOLWINDOW;
CreateInfo.spCaption = "TaskBar" ;
CreateInfo.hMenu = 0;
CreateInfo.hCursor = GetSystemCursor (0);
CreateInfo.hIcon = 0;
CreateInfo.MainWindowProc = TaskBarWinProc;
CreateInfo.lx = 0;
CreateInfo.ty = 0;
CreateInfo.rx = 1024;
CreateInfo.by = 600;
CreateInfo.iBkColor = PIXEL_black;
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 _MGRM_PROCESSES
#include <minigui/dti.c>
#endif
离线
代码看不出什么问题来, 是不是硬件有问题?
离线
试试这样:
CreateInfo.dwExStyle = WS_EX_TOOLWINDOW | WS_EX_CLIPCHILDREN;
最近编辑记录 novice (2020-04-22 09:03:02)
离线
试试这样:
CreateInfo.dwExStyle = WS_EX_TOOLWINDOW | WS_EX_CLIPCHILDREN;
感谢前辈们的评论,这个我看文档写的影响绘图效率就没加,不过问题我找到了:
首先官方3.0文档定时器例子部分代码确实有问题,其中少了一个大括号,其次这段程序也许在x86上跑不会出现问题(本地环境没搭所以没测,直接上板子),但是低端嵌入式产品绘制的时候文字带背景绘图就会在定时绘图的情况下绘图出现文字背景的噪点,只要是字符串都有这毛病(是不是时间无关),将文字背景改成透明的就行了,用什么写字的API都可以。
minigui用的人是不是太少了,网上讨论的帖子也很旧,多来些大佬讨论讨论哈哈
离线