www.pudn.com > screensaver.rar > vkey.c
#include "vkey.h"
#include "genlib.h"
#include "GUILib.h"
#include "strlib.h"
#define GENKEY(L,T,C) GenWindow(L, T, KEY_SIZE, KEY_SIZE, C, onKeyClick, NULL, NULL, NULL, NULL, NULL)
#define START_X 0.3
#define START_Y 1.3
static void onKeyClick(handle_t win);
static handle_t arrKeys[95];
static void (*EventOnKey)(char ch);
void SetupKeyboard(void (*onKey)(char ch))
{
handle_t win;
char i;
double left;
double top;
EventOnKey = onKey;
top = START_Y;
left = START_X;
for(i = 32; i <= 126; i ++)
{
if ((left + KEY_SIZE) > WINDOW_WIDTH)
{
top -= (KEY_SIZE + KEY_SPACE);
left = START_X;
}
win = GENKEY(left, top, CharToString(i));
arrKeys[i - 32] = win;
CreateWindow(win);
left += (KEY_SIZE + KEY_SPACE);
}
}
void RemoveKeyboard()
{
char i;
for(i = 0; i < 95; i++)
{
RemoveWindow(arrKeys[i]);
}
RedrawAll();
}
static void onKeyClick(handle_t win)
{
EventOnKey(win->text[0]);
}