OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [demos/] [mwin/] [muserfd.c] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#include <windows.h>
2
#include <wintern.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
 
6
 
7
#if DOS_DJGPP | defined(__FreeBSD__)
8
#include <sys/types.h>
9
#endif
10
 
11
#define MAX_TEST_FD (500)
12
 
13
LRESULT CALLBACK wproc(HWND,UINT,WPARAM,LPARAM);
14
 
15
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
16
                   PSTR szCmdLine, int iCmdShow)
17
{
18
        static char szAppName[]="HolaWin";
19
        HWND hwnd;
20
        WNDCLASS wndclass;
21
        int random_fd[MAX_TEST_FD][2], fd, unreg_fd;
22
 
23
        wndclass.style          = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
24
        wndclass.lpfnWndProc    = (WNDPROC)wproc;
25
        wndclass.cbClsExtra     =0;
26
        wndclass.cbWndExtra     =0;
27
        wndclass.hInstance      =0;
28
        wndclass.hIcon          =0;
29
        wndclass.hCursor        =0;
30
        wndclass.hbrBackground  =(HBRUSH)GetStockObject(LTGRAY_BRUSH);
31
        wndclass.lpszMenuName   =NULL;
32
        wndclass.lpszClassName  = szAppName;
33
 
34
        RegisterClass(&wndclass);
35
        hwnd=CreateWindowEx(0L,
36
                          szAppName,
37
                          "Hola",
38
                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
39
                          CW_USEDEFAULT,
40
                          CW_USEDEFAULT,
41
                          80,
42
                          80,
43
                          NULL,
44
                          NULL,
45
                          NULL,
46
                          NULL);
47
 
48
        /*
49
         * Create a random list of fd's to test the list
50
         * code.
51
         */
52
 
53
        printf ("Select a random list of fd's to test with.\n");
54
 
55
        for (fd = 0; fd < MAX_TEST_FD; fd++)
56
        {
57
          random_fd[fd][0] = random () % FD_SETSIZE;
58
          random_fd[fd][1] = random () % 3;
59
        }
60
 
61
        for (fd = 0; fd < MAX_TEST_FD; fd++)
62
        {
63
          switch (random_fd[fd][1])
64
          {
65
            case 0:
66
              MwRegisterFdInput (hwnd, random_fd[fd][0]);
67
              break;
68
 
69
            case 1:
70
              MwRegisterFdOutput (hwnd, random_fd[fd][0]);
71
              break;
72
 
73
            case 2:
74
              MwRegisterFdExcept (hwnd, random_fd[fd][0]);
75
              break;
76
 
77
            default:
78
 
79
              printf ("Bad fd type, fd index = %i, type = %i !\n",
80
                      fd, random_fd[fd][1]);
81
              return 1;
82
          }
83
        }
84
 
85
        unreg_fd = random () % MAX_TEST_FD;
86
 
87
        for (fd = 0; fd < MAX_TEST_FD; fd++)
88
        {
89
          switch (random_fd[unreg_fd][1])
90
          {
91
            case 0:
92
              MwUnregisterFdInput (hwnd, random_fd[unreg_fd][0]);
93
              break;
94
 
95
            case 1:
96
              MwUnregisterFdOutput (hwnd, random_fd[unreg_fd][0]);
97
              break;
98
 
99
            case 2:
100
              MwUnregisterFdExcept (hwnd, random_fd[unreg_fd][0]);
101
              break;
102
 
103
            default:
104
 
105
              printf ("Bad fd type !\n");
106
              return 1;
107
          }
108
 
109
          unreg_fd++;
110
          if (unreg_fd >= MAX_TEST_FD)
111
            unreg_fd = 0;
112
        }
113
 
114
 
115
        return 0;
116
}
117
 
118
LRESULT CALLBACK wproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
119
{
120
        HDC hdc;
121
        PAINTSTRUCT ps;
122
        RECT rect;
123
 
124
        switch (iMsg) {
125
        case WM_CREATE:
126
                break;
127
        case WM_PAINT:
128
#if 0
129
        case WM_MOUSEFIRST:
130
#endif
131
                hdc=BeginPaint(hwnd,&ps);
132
                GetClientRect(hwnd,&rect);
133
                DrawText(hdc, "Hola, NOS", -1, &rect,
134
                         DT_SINGLELINE|DT_CENTER|DT_VCENTER);
135
                EndPaint(hwnd,&ps);
136
                break;
137
        case WM_DESTROY:
138
                PostQuitMessage(0);
139
                break;
140
        default:
141
                return DefWindowProc(hwnd,iMsg,wParam,lParam);
142
        }
143
        return (0);
144
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.