#include <windows.h>
|
#include <windows.h>
|
#include <wintern.h>
|
#include <wintern.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
|
|
#if DOS_DJGPP | defined(__FreeBSD__)
|
#if DOS_DJGPP | defined(__FreeBSD__)
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#endif
|
#endif
|
|
|
#define MAX_TEST_FD (500)
|
#define MAX_TEST_FD (500)
|
|
|
LRESULT CALLBACK wproc(HWND,UINT,WPARAM,LPARAM);
|
LRESULT CALLBACK wproc(HWND,UINT,WPARAM,LPARAM);
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
PSTR szCmdLine, int iCmdShow)
|
PSTR szCmdLine, int iCmdShow)
|
{
|
{
|
static char szAppName[]="HolaWin";
|
static char szAppName[]="HolaWin";
|
HWND hwnd;
|
HWND hwnd;
|
WNDCLASS wndclass;
|
WNDCLASS wndclass;
|
int random_fd[MAX_TEST_FD][2], fd, unreg_fd;
|
int random_fd[MAX_TEST_FD][2], fd, unreg_fd;
|
|
|
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
|
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
|
wndclass.lpfnWndProc = (WNDPROC)wproc;
|
wndclass.lpfnWndProc = (WNDPROC)wproc;
|
wndclass.cbClsExtra =0;
|
wndclass.cbClsExtra =0;
|
wndclass.cbWndExtra =0;
|
wndclass.cbWndExtra =0;
|
wndclass.hInstance =0;
|
wndclass.hInstance =0;
|
wndclass.hIcon =0;
|
wndclass.hIcon =0;
|
wndclass.hCursor =0;
|
wndclass.hCursor =0;
|
wndclass.hbrBackground =(HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wndclass.hbrBackground =(HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
wndclass.lpszMenuName =NULL;
|
wndclass.lpszMenuName =NULL;
|
wndclass.lpszClassName = szAppName;
|
wndclass.lpszClassName = szAppName;
|
|
|
RegisterClass(&wndclass);
|
RegisterClass(&wndclass);
|
hwnd=CreateWindowEx(0L,
|
hwnd=CreateWindowEx(0L,
|
szAppName,
|
szAppName,
|
"Hola",
|
"Hola",
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
CW_USEDEFAULT,
|
CW_USEDEFAULT,
|
CW_USEDEFAULT,
|
CW_USEDEFAULT,
|
80,
|
80,
|
80,
|
80,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL);
|
NULL);
|
|
|
/*
|
/*
|
* Create a random list of fd's to test the list
|
* Create a random list of fd's to test the list
|
* code.
|
* code.
|
*/
|
*/
|
|
|
printf ("Select a random list of fd's to test with.\n");
|
printf ("Select a random list of fd's to test with.\n");
|
|
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
{
|
{
|
random_fd[fd][0] = random () % FD_SETSIZE;
|
random_fd[fd][0] = random () % FD_SETSIZE;
|
random_fd[fd][1] = random () % 3;
|
random_fd[fd][1] = random () % 3;
|
}
|
}
|
|
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
{
|
{
|
switch (random_fd[fd][1])
|
switch (random_fd[fd][1])
|
{
|
{
|
case 0:
|
case 0:
|
MwRegisterFdInput (hwnd, random_fd[fd][0]);
|
MwRegisterFdInput (hwnd, random_fd[fd][0]);
|
break;
|
break;
|
|
|
case 1:
|
case 1:
|
MwRegisterFdOutput (hwnd, random_fd[fd][0]);
|
MwRegisterFdOutput (hwnd, random_fd[fd][0]);
|
break;
|
break;
|
|
|
case 2:
|
case 2:
|
MwRegisterFdExcept (hwnd, random_fd[fd][0]);
|
MwRegisterFdExcept (hwnd, random_fd[fd][0]);
|
break;
|
break;
|
|
|
default:
|
default:
|
|
|
printf ("Bad fd type, fd index = %i, type = %i !\n",
|
printf ("Bad fd type, fd index = %i, type = %i !\n",
|
fd, random_fd[fd][1]);
|
fd, random_fd[fd][1]);
|
return 1;
|
return 1;
|
}
|
}
|
}
|
}
|
|
|
unreg_fd = random () % MAX_TEST_FD;
|
unreg_fd = random () % MAX_TEST_FD;
|
|
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
for (fd = 0; fd < MAX_TEST_FD; fd++)
|
{
|
{
|
switch (random_fd[unreg_fd][1])
|
switch (random_fd[unreg_fd][1])
|
{
|
{
|
case 0:
|
case 0:
|
MwUnregisterFdInput (hwnd, random_fd[unreg_fd][0]);
|
MwUnregisterFdInput (hwnd, random_fd[unreg_fd][0]);
|
break;
|
break;
|
|
|
case 1:
|
case 1:
|
MwUnregisterFdOutput (hwnd, random_fd[unreg_fd][0]);
|
MwUnregisterFdOutput (hwnd, random_fd[unreg_fd][0]);
|
break;
|
break;
|
|
|
case 2:
|
case 2:
|
MwUnregisterFdExcept (hwnd, random_fd[unreg_fd][0]);
|
MwUnregisterFdExcept (hwnd, random_fd[unreg_fd][0]);
|
break;
|
break;
|
|
|
default:
|
default:
|
|
|
printf ("Bad fd type !\n");
|
printf ("Bad fd type !\n");
|
return 1;
|
return 1;
|
}
|
}
|
|
|
unreg_fd++;
|
unreg_fd++;
|
if (unreg_fd >= MAX_TEST_FD)
|
if (unreg_fd >= MAX_TEST_FD)
|
unreg_fd = 0;
|
unreg_fd = 0;
|
}
|
}
|
|
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
LRESULT CALLBACK wproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK wproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
{
|
{
|
HDC hdc;
|
HDC hdc;
|
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
RECT rect;
|
RECT rect;
|
|
|
switch (iMsg) {
|
switch (iMsg) {
|
case WM_CREATE:
|
case WM_CREATE:
|
break;
|
break;
|
case WM_PAINT:
|
case WM_PAINT:
|
#if 0
|
#if 0
|
case WM_MOUSEFIRST:
|
case WM_MOUSEFIRST:
|
#endif
|
#endif
|
hdc=BeginPaint(hwnd,&ps);
|
hdc=BeginPaint(hwnd,&ps);
|
GetClientRect(hwnd,&rect);
|
GetClientRect(hwnd,&rect);
|
DrawText(hdc, "Hola, NOS", -1, &rect,
|
DrawText(hdc, "Hola, NOS", -1, &rect,
|
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
|
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
|
EndPaint(hwnd,&ps);
|
EndPaint(hwnd,&ps);
|
break;
|
break;
|
case WM_DESTROY:
|
case WM_DESTROY:
|
PostQuitMessage(0);
|
PostQuitMessage(0);
|
break;
|
break;
|
default:
|
default:
|
return DefWindowProc(hwnd,iMsg,wParam,lParam);
|
return DefWindowProc(hwnd,iMsg,wParam,lParam);
|
}
|
}
|
return (0);
|
return (0);
|
}
|
}
|
|
|