标签:
#include <stdio.h>
#include <stdlib.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
static DLGTEMPLATE input_temp =
{
WS_BORDER | WS_CAPTION,
WS_EX_NONE,
0, 0, 640, 420,
"Please input the length",
0, 0, 4, NULL, 0
};
static CTRLDATA input_ctrls[] =
{
{
CTRL_BUTTON,
WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
470, 110, 60, 25,
IDOK,
"OK",
0
}
};
static BITMAP bmp_bkgnd;
static int input_proc(HWND hdlg, int msg, WPARAM wprm, LPARAM lprm)
{
switch(msg)
{
case MSG_INITDIALOG:
{
printf("init\n");
SetWindowAdditionalData(hdlg, lprm);
}
return 1;
case MSG_ERASEBKGND:
{
printf("erase\n");
BOOL flag = FALSE;
HDC hdc = (HDC)wprm;
const RECT *clip = (const RECT*)lprm;
RECT rect;
if(hdc == 0)
{
hdc = GetClientDC(hdlg);
flag = TRUE;
}
if(clip)
{
rect = *clip;
ScreenToClient(hdlg, &rect.left, &rect.top);
ScreenToClient(hdlg, &rect.right, &rect.bottom);
IncludeClipRect(hdc, &rect);
}
else
GetClientRect(hdlg, &rect);
FillBoxWithBitmap(hdc, 0, 0,
RECTW(rect), RECTH(rect), &bmp_bkgnd);
if(flag)
ReleaseDC(hdc);
}
return 0;
case MSG_CLOSE:
EndDialog(hdlg, IDCANCEL);
break;
}
return DefaultDialogProc(hdlg, msg, wprm, lprm);
}
static int input_dlg(HWND hwnd, double *length)
{
printf("input_dlg\n");
input_temp.controls = input_ctrls;
return DialogBoxIndirectParam(&input_temp, hwnd, input_proc, (LPARAM)length);
}
int MiniGUIMain(int argc, const char *argv[])
{
double length;
if(LoadBitmap(HDC_SCREEN, &bmp_bkgnd, "res/bkgnd.jpg"))
return 1;
printf("#######################\n");
if(input_dlg(HWND_DESKTOP, &length) == IDOK)
printf("The length is %.5f mm.\n", length);
UnloadBitmap(&bmp_bkgnd);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/mynamepfd/p/4326453.html