/*
|
/*
|
* Copyright (c) 1999, 2000, 2001 Greg Haerr <greg@censoft.com>
|
* Copyright (c) 1999, 2000, 2001 Greg Haerr <greg@censoft.com>
|
*
|
*
|
* Demo program for Microwindows
|
* Demo program for Microwindows
|
*/
|
*/
|
#define MWINCLUDECOLORS
|
#define MWINCLUDECOLORS
|
#include "windows.h"
|
#include "windows.h"
|
#include "wintern.h" /* for MwSetDesktopWallpaper*/
|
#include "wintern.h" /* for MwSetDesktopWallpaper*/
|
|
|
#include "device.h"
|
#include "device.h"
|
|
|
#if DOS_TURBOC
|
#if DOS_TURBOC
|
unsigned _stklen = 4096;
|
unsigned _stklen = 4096;
|
#endif
|
#endif
|
|
|
#define CLIPDEMO 0 /* set for region clipping demo*/
|
#define CLIPDEMO 0 /* set for region clipping demo*/
|
|
|
#ifndef ELKS
|
#ifndef ELKS
|
#define TIMERDEMO 1 /* set for WM_TIMER demo*/
|
#define TIMERDEMO 1 /* set for WM_TIMER demo*/
|
#define GRAPH3D 0 /* 3d graphics demo*/
|
#define GRAPH3D 0 /* 3d graphics demo*/
|
#define IMAGE 0 /* 256 color image demo*/
|
#define IMAGE 0 /* 256 color image demo*/
|
#endif
|
#endif
|
#define ARCDEMO 1 /* arc drawing demo*/
|
#define ARCDEMO 1 /* arc drawing demo*/
|
#define CHILD 1 /* child window demo*/
|
#define CHILD 1 /* child window demo*/
|
#define CLIENT3D 0 /* old client draw test*/
|
#define CLIENT3D 0 /* old client draw test*/
|
#define USEBLIT 1 /* use blit rather than DrawDIB()*/
|
#define USEBLIT 1 /* use blit rather than DrawDIB()*/
|
|
|
#if GRAPH3D
|
#if GRAPH3D
|
#include "graph3d.h"
|
#include "graph3d.h"
|
#endif
|
#endif
|
|
|
extern MWIMAGEHDR image_car8;
|
extern MWIMAGEHDR image_car8;
|
extern MWIMAGEHDR image_zion208;
|
extern MWIMAGEHDR image_zion208;
|
extern MWIMAGEHDR image_penguin;
|
extern MWIMAGEHDR image_penguin;
|
extern MWIMAGEHDR image_under4;
|
extern MWIMAGEHDR image_under4;
|
extern MWIMAGEHDR image_microwin;
|
extern MWIMAGEHDR image_microwin;
|
extern MWIMAGEHDR image_cs1;
|
extern MWIMAGEHDR image_cs1;
|
extern MWIMAGEHDR image_rle8;
|
extern MWIMAGEHDR image_rle8;
|
|
|
#if CHILD
|
#if CHILD
|
#if ELKS | MSDOS
|
#if ELKS | MSDOS
|
PMWIMAGEHDR image = &image_cs1; /* 2 color bitmap for 16 color systems*/
|
PMWIMAGEHDR image = &image_cs1; /* 2 color bitmap for 16 color systems*/
|
#else
|
#else
|
PMWIMAGEHDR image = &image_penguin;
|
PMWIMAGEHDR image = &image_penguin;
|
#endif
|
#endif
|
#endif
|
#endif
|
|
|
#if IMAGE
|
#if IMAGE
|
PMWIMAGEHDR image2 = &image_zion208;
|
PMWIMAGEHDR image2 = &image_zion208;
|
#endif
|
#endif
|
|
|
#define APPCLASS "test"
|
#define APPCLASS "test"
|
#define APPCHILD "test2"
|
#define APPCHILD "test2"
|
|
|
/* forward decls*/
|
/* forward decls*/
|
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
|
|
|
int
|
int
|
MwUserInit(int ac, char **av)
|
MwUserInit(int ac, char **av)
|
{
|
{
|
/* test user init procedure - do nothing*/
|
/* test user init procedure - do nothing*/
|
return 0;
|
return 0;
|
}
|
}
|
|
|
int
|
int
|
RegisterAppClass(void)
|
RegisterAppClass(void)
|
{
|
{
|
WNDCLASS wc;
|
WNDCLASS wc;
|
|
|
#if !ELKS
|
#if !ELKS
|
MwRegisterButtonControl(NULL);
|
MwRegisterButtonControl(NULL);
|
MwRegisterEditControl(NULL);
|
MwRegisterEditControl(NULL);
|
MwRegisterListboxControl(NULL);
|
MwRegisterListboxControl(NULL);
|
MwRegisterProgressBarControl(NULL);
|
MwRegisterProgressBarControl(NULL);
|
/*MwRegisterComboboxControl(NULL);*/
|
/*MwRegisterComboboxControl(NULL);*/
|
#endif
|
#endif
|
wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wc.lpfnWndProc = (WNDPROC)WndProc;
|
wc.lpfnWndProc = (WNDPROC)WndProc;
|
wc.cbClsExtra = 0;
|
wc.cbClsExtra = 0;
|
wc.cbWndExtra = 0;
|
wc.cbWndExtra = 0;
|
wc.hInstance = 0;
|
wc.hInstance = 0;
|
wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
|
wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
|
wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
|
wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
|
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
wc.lpszClassName = APPCLASS;
|
wc.lpszClassName = APPCLASS;
|
RegisterClass( &wc);
|
RegisterClass( &wc);
|
|
|
#if CHILD
|
#if CHILD
|
wc.lpfnWndProc = (WNDPROC)ChildWndProc;
|
wc.lpfnWndProc = (WNDPROC)ChildWndProc;
|
wc.lpszClassName = APPCHILD;
|
wc.lpszClassName = APPCHILD;
|
return RegisterClass( &wc);
|
return RegisterClass( &wc);
|
#endif
|
#endif
|
return 1;
|
return 1;
|
}
|
}
|
|
|
HWND
|
HWND
|
CreateAppWindow(void)
|
CreateAppWindow(void)
|
{
|
{
|
HWND hwnd, hlist;
|
HWND hwnd, hlist;
|
static int nextid = 1;
|
static int nextid = 1;
|
int width, height;
|
int width, height;
|
RECT r;
|
RECT r;
|
GetWindowRect(GetDesktopWindow(), &r);
|
GetWindowRect(GetDesktopWindow(), &r);
|
width = height = r.right / 2;
|
width = height = r.right / 2;
|
|
|
hwnd = CreateWindowEx(0L, APPCLASS,
|
hwnd = CreateWindowEx(0L, APPCLASS,
|
"Microwindows Application",
|
"Microwindows Application",
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
width, height,
|
width, height,
|
NULL, (HMENU)nextid++, NULL, NULL);
|
NULL, (HMENU)nextid++, NULL, NULL);
|
|
|
#if CHILD
|
#if CHILD
|
if(hwnd
|
if(hwnd
|
#if GRAPH3D
|
#if GRAPH3D
|
&& (nextid & 03)!=2
|
&& (nextid & 03)!=2
|
#endif
|
#endif
|
) {
|
) {
|
CreateWindowEx(0L, APPCHILD,
|
CreateWindowEx(0L, APPCHILD,
|
"",
|
"",
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
4, 4, width / 3-6, height / 3,
|
4, 4, width / 3-6, height / 3,
|
hwnd, (HMENU)2, NULL, NULL);
|
hwnd, (HMENU)2, NULL, NULL);
|
CreateWindowEx(0L, APPCHILD,
|
CreateWindowEx(0L, APPCHILD,
|
"",
|
"",
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
width / 3, height / 3, width / 3-6, height / 3,
|
width / 3, height / 3, width / 3-6, height / 3,
|
hwnd, (HMENU)3, NULL, NULL);
|
hwnd, (HMENU)3, NULL, NULL);
|
CreateWindowEx(0L, APPCHILD,
|
CreateWindowEx(0L, APPCHILD,
|
"",
|
"",
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
WS_BORDER | WS_CHILD | WS_VISIBLE,
|
width * 3 / 5, height * 3 / 5,
|
width * 3 / 5, height * 3 / 5,
|
width * 2 / 3, height * 2 / 3,
|
width * 2 / 3, height * 2 / 3,
|
hwnd, (HMENU)4, NULL, NULL);
|
hwnd, (HMENU)4, NULL, NULL);
|
CreateWindowEx(0L, "EDIT",
|
CreateWindowEx(0L, "EDIT",
|
"OK",
|
"OK",
|
WS_BORDER|WS_CHILD | WS_VISIBLE,
|
WS_BORDER|WS_CHILD | WS_VISIBLE,
|
width * 5 / 8, 10, 100, 18,
|
width * 5 / 8, 10, 100, 18,
|
hwnd, (HMENU)5, NULL, NULL);
|
hwnd, (HMENU)5, NULL, NULL);
|
CreateWindowEx(0L, "PROGBAR",
|
CreateWindowEx(0L, "PROGBAR",
|
"OK",
|
"OK",
|
WS_BORDER|WS_CHILD | WS_VISIBLE,
|
WS_BORDER|WS_CHILD | WS_VISIBLE,
|
width * 5 / 8, 32, 100, 18,
|
width * 5 / 8, 32, 100, 18,
|
hwnd, (HMENU)6, NULL, NULL);
|
hwnd, (HMENU)6, NULL, NULL);
|
|
|
hlist = CreateWindowEx(0L, "LISTBOX",
|
hlist = CreateWindowEx(0L, "LISTBOX",
|
"OK",
|
"OK",
|
WS_HSCROLL|WS_VSCROLL|WS_BORDER|WS_CHILD | WS_VISIBLE,
|
WS_HSCROLL|WS_VSCROLL|WS_BORDER|WS_CHILD | WS_VISIBLE,
|
width * 5 / 8, 54, 100, 48,
|
width * 5 / 8, 54, 100, 48,
|
hwnd, (HMENU)7, NULL, NULL);
|
hwnd, (HMENU)7, NULL, NULL);
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry");
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry");
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple");
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple");
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange");
|
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange");
|
|
|
CreateWindowEx(0L, "BUTTON",
|
CreateWindowEx(0L, "BUTTON",
|
"Cancel",
|
"Cancel",
|
BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE,
|
BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE,
|
width * 5 / 8 + 50, 106, 50, 14,
|
width * 5 / 8 + 50, 106, 50, 14,
|
hwnd, (HMENU)8, NULL, NULL);
|
hwnd, (HMENU)8, NULL, NULL);
|
}
|
}
|
#endif
|
#endif
|
return hwnd;
|
return hwnd;
|
}
|
}
|
|
|
#if CHILD
|
#if CHILD
|
LRESULT CALLBACK
|
LRESULT CALLBACK
|
ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
{
|
{
|
RECT rc;
|
RECT rc;
|
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
|
|
switch(msg) {
|
switch(msg) {
|
case WM_PAINT:
|
case WM_PAINT:
|
BeginPaint(hwnd, &ps);
|
BeginPaint(hwnd, &ps);
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
#if USEBLIT
|
#if USEBLIT
|
{
|
{
|
HDC hdcMem;
|
HDC hdcMem;
|
HBITMAP hbmp, hbmpOrg;
|
HBITMAP hbmp, hbmpOrg;
|
|
|
/* redirect painting to offscreen dc, then use blit function*/
|
/* redirect painting to offscreen dc, then use blit function*/
|
hdcMem = CreateCompatibleDC(ps.hdc);
|
hdcMem = CreateCompatibleDC(ps.hdc);
|
hbmp = CreateCompatibleBitmap(hdcMem, rc.right, rc.bottom);
|
hbmp = CreateCompatibleBitmap(hdcMem, rc.right, rc.bottom);
|
hbmpOrg = SelectObject(hdcMem, hbmp);
|
hbmpOrg = SelectObject(hdcMem, hbmp);
|
|
|
/* draw onto offscreen dc*/
|
/* draw onto offscreen dc*/
|
DrawDIB(hdcMem, 0, 0, image);
|
DrawDIB(hdcMem, 0, 0, image);
|
|
|
/* blit offscreen with physical screen*/
|
/* blit offscreen with physical screen*/
|
BitBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
BitBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
0, 0, MWROP_SRCCOPY);
|
0, 0, MWROP_SRCCOPY);
|
/*StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
/*StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
|
0, 0, image->width/3*5, image->height/3*4, MWROP_SRCCOPY);*/
|
0, 0, image->width/3*5, image->height/3*4, MWROP_SRCCOPY);*/
|
DeleteObject(SelectObject(hdcMem, hbmpOrg));
|
DeleteObject(SelectObject(hdcMem, hbmpOrg));
|
DeleteDC(hdcMem);
|
DeleteDC(hdcMem);
|
}
|
}
|
#else
|
#else
|
DrawDIB(ps.hdc, rc.left, rc.top, image);
|
DrawDIB(ps.hdc, rc.left, rc.top, image);
|
#endif
|
#endif
|
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
break;
|
break;
|
default:
|
default:
|
return DefWindowProc( hwnd, msg, wp, lp);
|
return DefWindowProc( hwnd, msg, wp, lp);
|
}
|
}
|
return( 0);
|
return( 0);
|
}
|
}
|
#endif
|
#endif
|
|
|
LRESULT CALLBACK
|
LRESULT CALLBACK
|
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
{
|
{
|
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
HDC hdc;
|
HDC hdc;
|
#if CLIENT3D | IMAGE | GRAPH3D
|
#if CLIENT3D | IMAGE | GRAPH3D
|
RECT rc;
|
RECT rc;
|
#endif
|
#endif
|
#if GRAPH3D
|
#if GRAPH3D
|
static int countup = 1;
|
static int countup = 1;
|
int id;
|
int id;
|
static vec1 gx, gy;
|
static vec1 gx, gy;
|
#endif
|
#endif
|
#if TIMERDEMO
|
#if TIMERDEMO
|
static POINT mousept;
|
static POINT mousept;
|
#endif
|
#endif
|
#if ARCDEMO
|
#if ARCDEMO
|
static int startdegrees = 0;
|
static int startdegrees = 0;
|
static int enddegrees = 30;
|
static int enddegrees = 30;
|
#endif
|
#endif
|
|
|
switch( msg) {
|
switch( msg) {
|
#if TIMERDEMO
|
#if TIMERDEMO
|
case WM_CREATE:
|
case WM_CREATE:
|
SetTimer(hwnd, 1, 100, NULL);
|
SetTimer(hwnd, 1, 100, NULL);
|
mousept.x = 60;
|
mousept.x = 60;
|
mousept.y = 20;
|
mousept.y = 20;
|
break;
|
break;
|
|
|
case WM_TIMER:
|
case WM_TIMER:
|
#if GRAPH3D
|
#if GRAPH3D
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
if(countup) {
|
if(countup) {
|
mousept.y += 20;
|
mousept.y += 20;
|
if(mousept.y >= rc.bottom) {
|
if(mousept.y >= rc.bottom) {
|
mousept.y -= 20;
|
mousept.y -= 20;
|
countup = 0;
|
countup = 0;
|
}
|
}
|
} else {
|
} else {
|
mousept.y -= 20;
|
mousept.y -= 20;
|
if(mousept.y < 20) {
|
if(mousept.y < 20) {
|
mousept.y += 20;
|
mousept.y += 20;
|
countup = 1;
|
countup = 1;
|
}
|
}
|
}
|
}
|
SendMessage(hwnd, WM_MOUSEMOVE, 0,
|
SendMessage(hwnd, WM_MOUSEMOVE, 0,
|
MAKELONG(mousept.x, mousept.y));
|
MAKELONG(mousept.x, mousept.y));
|
#endif
|
#endif
|
#if ARCDEMO
|
#if ARCDEMO
|
startdegrees += 10;
|
startdegrees += 10;
|
if(startdegrees >= 360)
|
if(startdegrees >= 360)
|
startdegrees = 0;
|
startdegrees = 0;
|
enddegrees += 15;
|
enddegrees += 15;
|
if(enddegrees >= 360)
|
if(enddegrees >= 360)
|
enddegrees = 0;
|
enddegrees = 0;
|
InvalidateRect(hwnd, NULL, TRUE);
|
InvalidateRect(hwnd, NULL, TRUE);
|
#endif
|
#endif
|
break;
|
break;
|
|
|
case WM_DESTROY:
|
case WM_DESTROY:
|
KillTimer(hwnd, 1);
|
KillTimer(hwnd, 1);
|
break;
|
break;
|
#endif /* TIMERDEMO*/
|
#endif /* TIMERDEMO*/
|
case WM_SIZE:
|
case WM_SIZE:
|
break;
|
break;
|
|
|
case WM_MOVE:
|
case WM_MOVE:
|
break;
|
break;
|
|
|
#if CLIENT3D
|
#if CLIENT3D
|
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
PostMessage((HWND)wp, WM_PAINT, 0, 0L);
|
PostMessage((HWND)wp, WM_PAINT, 0, 0L);
|
break;
|
break;
|
|
|
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
PostMessage((HWND)wp, WM_PAINT, 0, 0L);
|
PostMessage((HWND)wp, WM_PAINT, 0, 0L);
|
break;
|
break;
|
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
if(GetFocus() != hwnd)
|
if(GetFocus() != hwnd)
|
return DefWindowProc(hwnd, msg, wp, lp);
|
return DefWindowProc(hwnd, msg, wp, lp);
|
return 1;
|
return 1;
|
#endif
|
#endif
|
#if GRAPH3D
|
#if GRAPH3D
|
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
if((GetWindowLong(hwnd, GWL_ID) & 03) == 1)
|
if((GetWindowLong(hwnd, GWL_ID) & 03) == 1)
|
return 1;
|
return 1;
|
return DefWindowProc(hwnd, msg, wp, lp);
|
return DefWindowProc(hwnd, msg, wp, lp);
|
#endif
|
#endif
|
case WM_PAINT:
|
case WM_PAINT:
|
hdc = BeginPaint(hwnd, &ps);
|
hdc = BeginPaint(hwnd, &ps);
|
|
|
#if CLIENT3D
|
#if CLIENT3D
|
if(GetFocus() == hwnd) {
|
if(GetFocus() == hwnd) {
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
Draw3dShadow(hdc, rc.left, rc.top,
|
Draw3dShadow(hdc, rc.left, rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
GetSysColor(COLOR_3DDKSHADOW),
|
GetSysColor(COLOR_3DDKSHADOW),
|
GetSysColor(COLOR_3DLIGHT));
|
GetSysColor(COLOR_3DLIGHT));
|
InflateRect(&rc, -1, -1);
|
InflateRect(&rc, -1, -1);
|
FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
|
FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
|
}
|
}
|
#endif
|
#endif
|
#if IMAGE
|
#if IMAGE
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
DrawDIB(hdc, rc.left+2, rc.top+2, image2);
|
DrawDIB(hdc, rc.left+2, rc.top+2, image2);
|
#endif
|
#endif
|
#if ARCDEMO
|
#if ARCDEMO
|
{
|
{
|
int x, y, w, h;
|
int x, y, w, h;
|
RECT rc;
|
RECT rc;
|
|
|
if(hdc != NULL) {
|
if(hdc != NULL) {
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
rc.top += 13;
|
rc.top += 13;
|
InflateRect(&rc, -3, -3);
|
InflateRect(&rc, -3, -3);
|
/*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/
|
/*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/
|
/*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
|
/*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
|
/*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
|
/*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
|
|
|
x = rc.left;
|
x = rc.left;
|
y = rc.top;
|
y = rc.top;
|
w = rc.right - rc.left;
|
w = rc.right - rc.left;
|
h = rc.bottom - rc.top;
|
h = rc.bottom - rc.top;
|
w += 10;
|
w += 10;
|
GdSetForeground(GdFindColor(RGB(0,255,0)));
|
GdSetForeground(GdFindColor(RGB(0,255,0)));
|
GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
|
GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
|
enddegrees*64, MWPIE);
|
enddegrees*64, MWPIE);
|
GdSetForeground(GdFindColor(RGB(0,0,0)));
|
GdSetForeground(GdFindColor(RGB(0,0,0)));
|
GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
|
GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
|
enddegrees*64, MWARCOUTLINE);
|
enddegrees*64, MWARCOUTLINE);
|
/*GdSetForeground(GdFindColor(RGB(255,255,255)));*/
|
/*GdSetForeground(GdFindColor(RGB(255,255,255)));*/
|
/*GdPoint(hdc->psd, x+w/2, y+h/2);*/
|
/*GdPoint(hdc->psd, x+w/2, y+h/2);*/
|
}
|
}
|
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
break;
|
break;
|
}
|
}
|
#endif /* ARCDEMO*/
|
#endif /* ARCDEMO*/
|
#if GRAPH3D
|
#if GRAPH3D
|
id = (int)GetWindowLong(hwnd, GWL_ID) & 03;
|
id = (int)GetWindowLong(hwnd, GWL_ID) & 03;
|
init3(hdc, id == 1? hwnd: NULL);
|
init3(hdc, id == 1? hwnd: NULL);
|
switch(id) {
|
switch(id) {
|
case 0:
|
case 0:
|
rose(1.0, 7, 13);
|
rose(1.0, 7, 13);
|
break;
|
break;
|
case 1:
|
case 1:
|
/*look3(0.5, 0.7, 1.5);*/
|
/*look3(0.5, 0.7, 1.5);*/
|
/*look3(0.2, -2 * gy, 1.0+gx);*/
|
/*look3(0.2, -2 * gy, 1.0+gx);*/
|
look3(-2 * gx, -2 * gy, 1.2);
|
look3(-2 * gx, -2 * gy, 1.2);
|
drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10);
|
drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10);
|
break;
|
break;
|
case 2:
|
case 2:
|
setcolor3(BLACK);
|
setcolor3(BLACK);
|
circle3(1.0);
|
circle3(1.0);
|
break;
|
break;
|
case 3:
|
case 3:
|
setcolor3(BLUE);
|
setcolor3(BLUE);
|
daisy(1.0, 20);
|
daisy(1.0, 20);
|
break;
|
break;
|
}
|
}
|
|
|
#if CLIPDEMO
|
#if CLIPDEMO
|
if(id == 1) {
|
if(id == 1) {
|
HRGN hrgn, hrgn2;
|
HRGN hrgn, hrgn2;
|
|
|
/* create circular clip region for effect*/
|
/* create circular clip region for effect*/
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
InflateRect(&rc, -80, -80);
|
InflateRect(&rc, -80, -80);
|
switch((int)GetWindowLong(hwnd, GWL_ID)) {
|
switch((int)GetWindowLong(hwnd, GWL_ID)) {
|
default:
|
default:
|
hrgn = CreateEllipticRgnIndirect(&rc);
|
hrgn = CreateEllipticRgnIndirect(&rc);
|
break;
|
break;
|
case 5:
|
case 5:
|
hrgn = CreateRoundRectRgn(rc.left, rc.top,
|
hrgn = CreateRoundRectRgn(rc.left, rc.top,
|
rc.right, rc.bottom, 100, 100);
|
rc.right, rc.bottom, 100, 100);
|
break;
|
break;
|
case 1:
|
case 1:
|
hrgn = CreateRectRgnIndirect(&rc);
|
hrgn = CreateRectRgnIndirect(&rc);
|
break;
|
break;
|
}
|
}
|
|
|
/* erase background, clip out blit area*/
|
/* erase background, clip out blit area*/
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
hrgn2 = CreateRectRgnIndirect(&rc);
|
hrgn2 = CreateRectRgnIndirect(&rc);
|
SelectClipRgn(hdc, hrgn2);
|
SelectClipRgn(hdc, hrgn2);
|
ExtSelectClipRgn(hdc, hrgn, RGN_XOR);
|
ExtSelectClipRgn(hdc, hrgn, RGN_XOR);
|
DeleteObject(hrgn2);
|
DeleteObject(hrgn2);
|
|
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));
|
FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));
|
|
|
/* clip in only blit area*/
|
/* clip in only blit area*/
|
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
}
|
}
|
#endif /* CLIPDEMO*/
|
#endif /* CLIPDEMO*/
|
|
|
paint3(hdc);
|
paint3(hdc);
|
|
|
#endif /* GRAPH3D*/
|
#endif /* GRAPH3D*/
|
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
break;
|
break;
|
|
|
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
break;
|
break;
|
|
|
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
#if GRAPH3D
|
#if GRAPH3D
|
if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
|
if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
|
POINT pt;
|
POINT pt;
|
|
|
POINTSTOPOINT(pt, lp);
|
POINTSTOPOINT(pt, lp);
|
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
gx = (vec1)pt.x / rc.right;
|
gx = (vec1)pt.x / rc.right;
|
gy = (vec1)pt.y / rc.bottom;
|
gy = (vec1)pt.y / rc.bottom;
|
InvalidateRect(hwnd, NULL, FALSE);
|
InvalidateRect(hwnd, NULL, FALSE);
|
mousept.x = pt.x;
|
mousept.x = pt.x;
|
mousept.y = pt.y;
|
mousept.y = pt.y;
|
}
|
}
|
#endif
|
#endif
|
break;
|
break;
|
|
|
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
break;
|
break;
|
|
|
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
break;
|
break;
|
|
|
default:
|
default:
|
return DefWindowProc( hwnd, msg, wp, lp);
|
return DefWindowProc( hwnd, msg, wp, lp);
|
}
|
}
|
return( 0);
|
return( 0);
|
}
|
}
|
|
|
int WINAPI
|
int WINAPI
|
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
int nShowCmd)
|
int nShowCmd)
|
{
|
{
|
MSG msg;
|
MSG msg;
|
HWND hwnd;
|
HWND hwnd;
|
RECT rc;
|
RECT rc;
|
|
|
RegisterAppClass();
|
RegisterAppClass();
|
GetWindowRect(GetDesktopWindow(), &rc);
|
GetWindowRect(GetDesktopWindow(), &rc);
|
#if !(ELKS | MSDOS)
|
#if !(ELKS | MSDOS)
|
/* create penguin window*/
|
/* create penguin window*/
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
|
rc.right-130-1, rc.bottom-153-1, 130, 153,
|
rc.right-130-1, rc.bottom-153-1, 130, 153,
|
GetDesktopWindow(), (HMENU)1000, NULL, NULL);
|
GetDesktopWindow(), (HMENU)1000, NULL, NULL);
|
#endif
|
#endif
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
#if !(ELKS | MSDOS)
|
#if !(ELKS | MSDOS)
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
CreateAppWindow();
|
hwnd = CreateAppWindow();
|
hwnd = CreateAppWindow();
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
OffsetRect(&rc, 50, 50);
|
OffsetRect(&rc, 50, 50);
|
MoveWindow(hwnd, rc.left, rc.top, rc.bottom-rc.top,
|
MoveWindow(hwnd, rc.left, rc.top, rc.bottom-rc.top,
|
rc.right-rc.left, TRUE);
|
rc.right-rc.left, TRUE);
|
#endif
|
#endif
|
#if !(ELKS | MSDOS)
|
#if !(ELKS | MSDOS)
|
/* set background wallpaper*/
|
/* set background wallpaper*/
|
MwSetDesktopWallpaper(&image_microwin);
|
MwSetDesktopWallpaper(&image_microwin);
|
/*MwSetDesktopWallpaper(&image_under4);*/
|
/*MwSetDesktopWallpaper(&image_under4);*/
|
/*MwSetDesktopWallpaper(&image_car8);*/
|
/*MwSetDesktopWallpaper(&image_car8);*/
|
#endif
|
#endif
|
|
|
/* type ESC to quit...*/
|
/* type ESC to quit...*/
|
while( GetMessage(&msg, NULL, 0, 0)) {
|
while( GetMessage(&msg, NULL, 0, 0)) {
|
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|