#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK CldProc (HWND, UINT, WPARAM, LPARAM) ;
#define b_start 1
#define e_start 2
#define e_sprng 3
#define e_enwrt 4
#define b_ok 5
#define WM_SENDWINDOWHANDLE WM_USER+0
#define WM_SHOWSTRING WM_USER+1
static int start = 0;
static int end = 0;
static int sprung = 0;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Dawen for Prometheus") ;
MSG msg ;
HWND hwnd ;
HWND child;
WNDCLASS wndclass ;
WNDCLASS wndclass2;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, NULL) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = "NULL" ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode !"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, TEXT ("Dawen for Prometheus"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 300,
NULL, NULL, hInstance, NULL) ;
wndclass2.style = CS_HREDRAW | CS_VREDRAW ;
wndclass2.lpfnWndProc = CldProc ;
wndclass2.cbClsExtra = 0 ;
wndclass2.cbWndExtra = 0 ;
wndclass2.hInstance = hInstance ;
wndclass2.hIcon = LoadIcon (hInstance, NULL) ;
wndclass2.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass2.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass2.lpszMenuName = "NULL" ;
wndclass2.lpszClassName = "Child" ;
if (!RegisterClass (&wndclass2))
{
MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode !"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
child = CreateWindow ("Child", TEXT ("Dawen for Prometheus"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT , CW_USEDEFAULT,
300, 300,
NULL, NULL, hInstance, NULL);
SendMessage(hwnd,WM_SENDWINDOWHANDLE,(WPARAM)child,0);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance ;
static HWND Hbutton;
static HWND HStart;
static HWND HSprung;
static HWND HEnd;
static HWND child = NULL;
char v1[30];
char v2[30];
char v3[30];
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
HStart = CreateWindow("edit","0",
WS_CHILD | WS_VISIBLE | WS_BORDER,
85,30,
80,20,
hwnd,(HMENU) e_start,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
HSprung = CreateWindow("edit","0",
WS_CHILD | WS_VISIBLE| WS_BORDER,
85,60,
80,20,
hwnd,(HMENU) e_sprng,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
HEnd = CreateWindow("edit","0",
WS_CHILD | WS_VISIBLE| WS_BORDER,
85,90,
80,20,
hwnd,(HMENU) e_enwrt,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
Hbutton = CreateWindow("button","Start",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
85,120,
80,25,
hwnd,(HMENU) b_start,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
return 0 ;
case WM_COMMAND:
if(lParam == (LPARAM) Hbutton)
{
if(HIWORD(wParam) == BN_CLICKED)
{
GetWindowText(HStart,v1,lstrlen(v1));
GetWindowText(HSprung,v2,lstrlen(v2));
GetWindowText(HEnd,v3,lstrlen(v3));
start = atoi(v1);
sprung = atoi(v2);
end = atoi(v3);
wsprintf(v1,"%i",start);
ShowWindow(child,SW_SHOWNORMAL);
SendMessage(child,WM_SHOWSTRING,(WPARAM)v1,0);
start = start + sprung;
}
}
return 0;
case WM_KEYDOWN:
switch(wParam)
{
case VK_RETURN:
if(start<=end)
{
wsprintf(v1,"%i",start);
ShowWindow(child,SW_SHOWNORMAL);
SendMessage(child,WM_SHOWSTRING,(WPARAM)v1,0);
start = start + sprung;
}
else
{
MessageBox(NULL,"Start und Endwert sind identisch","INFO !!!",MB_OK | MB_ICONSTOP);
}
break;
}
return 0;
case WM_SENDWINDOWHANDLE:
child = (HWND)wParam;
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
TextOut(hdc,10,60,"Sprungwert",lstrlen("Sprungwert"));
TextOut(hdc,10,90,"EndWert",lstrlen("Endwert"));
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
LRESULT CALLBACK CldProc (HWND child, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance ;
static HWND HStart;
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_KEYDOWN:
switch(wParam)
{
case VK_RETURN :
ShowWindow(child,SW_HIDE);
break;
}
return 0;
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
HStart = CreateWindow("edit","0",
WS_CHILD | WS_VISIBLE | WS_BORDER,
85,30,
80,20,
child,(HMENU) e_start,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
return 0 ;
case WM_SHOWSTRING:
SetWindowText(HStart,(TCHAR*)wParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(child,&ps);
TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
EndPaint(child,&ps);
return 0;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (child, message, wParam, lParam) ;
}