Files
lisimeng123 213ec2b058 add
2022-11-22 05:54:54 +08:00

158 lines
3.2 KiB
C

/*
** wnd_template.c: Sample program for mGNCS Programming Guide
** Using progressbar.
**
** Copyright (C) 2009 ~ 2019 FMSoft Technologies.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <mgncs/mgncs.h>
#define ID_BTN 101
#define ID_PROG 200
static BOOL mymain_onCreate (mWidget* _this, DWORD add_data)
{
SetTimer (_this->hwnd, 100, 20);
return TRUE;
}
static void mymain_onClose (mWidget* _this, int message)
{
DestroyMainWindow (_this->hwnd);
PostQuitMessage (_this->hwnd);
}
static void mymain_onTimer (mWidget *_this, int id, DWORD count)
{
//START_OF_SET_PROPERTY
static int pb_pos = 0;
mProgressBar *pb = (mProgressBar*)ncsGetChildObj (_this->hwnd, ID_PROG);
if (pb)
{
pb_pos++;
_c(pb)->setProperty(pb, NCSP_PROG_CURPOS, pb_pos);
if (pb_pos == _c(pb)->getProperty(pb, NCSP_PROG_MAXPOS))
{
DestroyMainWindow (_this->hwnd);
PostQuitMessage (_this->hwnd);
}
}
//END_OF_SET_PROPERTY
}
static void mymain_onPaint(mWidget *self, HDC hdc, const CLIPRGN* inv)
{
SetBkMode (hdc, BM_TRANSPARENT);
TextOut (hdc, 10, 10, "Installing ......");
}
static NCS_EVENT_HANDLER mymain_handlers[] = {
{MSG_CREATE, mymain_onCreate},
{MSG_CLOSE, mymain_onClose},
{MSG_PAINT, mymain_onPaint},
{MSG_TIMER, mymain_onTimer},
{0, NULL}
};
static void btn_onClicked(mWidget* _this, int id, int nc, HWND hCtrl)
{
if(nc == NCSN_WIDGET_CLICKED)
{
PostMessage(GetParent(_this->hwnd), MSG_CLOSE, 0, 0);
}
};
static NCS_EVENT_HANDLER btn_handlers[] =
{
{NCS_NOTIFY_CODE(NCSN_WIDGET_CLICKED), btn_onClicked},
{0, NULL}
};
static NCS_RDR_INFO btn_rdr_info[] =
{
{"fashion","fashion", NULL}
};
//START_OF_INITIAL_PROPS
static NCS_PROP_ENTRY progress_props[] =
{
{NCSP_PROG_MAXPOS, 100},
{NCSP_PROG_MINPOS, 0 },
{NCSP_PROG_LINESTEP, 1},
{NCSP_PROG_CURPOS, 0 },
{ 0, 0 }
};
//END_OF_INITIAL_PROPS
//START_OF_TEMPLATE
static NCS_WND_TEMPLATE _ctrl_templ[] =
{
{
NCSCTRL_PROGRESSBAR,
ID_PROG,
10, 33, 290, 25,
WS_BORDER | WS_VISIBLE | NCSS_PRGBAR_SHOWPERCENT,
WS_EX_NONE,
"",
progress_props,
NULL,
NULL, NULL, 0, 0
},
{
NCSCTRL_BUTTON,
ID_BTN,
120, 70, 80, 25,
WS_VISIBLE | NCSS_NOTIFY,
WS_EX_NONE,
"Cancel",
NULL,
btn_rdr_info,
btn_handlers, NULL, 0, 0
},
};
//END_OF_TEMPLATE
static NCS_MNWND_TEMPLATE mymain_templ =
{
NCSCTRL_DIALOGBOX,
1,
0, 0, 320, 130,
WS_CAPTION | WS_BORDER | WS_VISIBLE,
WS_EX_NONE,
"Progressbar",
NULL,
NULL,
mymain_handlers,
_ctrl_templ,
sizeof(_ctrl_templ)/sizeof(NCS_WND_TEMPLATE),
0,
0, 0,
};
int MiniGUIMain (int argc, const char* argv[])
{
ncsInitialize ();
mDialogBox* mydlg = (mDialogBox *)ncsCreateMainWindowIndirect
(&mymain_templ, HWND_DESKTOP);
_c(mydlg)->doModal (mydlg, TRUE);
ncsUninitialize ();
return 0;
}