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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [demos/] [mwin/] [mtest2.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
#define MWINCLUDECOLORS
2
#include <windows.h>
3
 
4
LRESULT CALLBACK wproc(HWND,UINT,WPARAM,LPARAM);
5
 
6
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
7
                   PSTR szCmdLine, int iCmdShow)
8
{
9
        static char szAppName[]="HolaWin";
10
        HWND hwnd;
11
        MSG msg;
12
        WNDCLASS wndclass;
13
 
14
        int width, height;
15
        RECT r;
16
        HWND hlist,hedit;
17
 
18
        GetWindowRect(GetDesktopWindow(), &r);
19
        width = height = r.right / 2;
20
 
21
        MwRegisterButtonControl(NULL);
22
        MwRegisterEditControl(NULL);
23
        MwRegisterListboxControl(NULL);
24
        MwRegisterProgressBarControl(NULL);
25
        MwRegisterStaticControl(NULL);
26
        MwRegisterComboboxControl(NULL);
27
        MwRegisterScrollbarControl(NULL);
28
 
29
        wndclass.style          = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
30
        wndclass.lpfnWndProc    = (WNDPROC)wproc;
31
        wndclass.cbClsExtra     =0;
32
        wndclass.cbWndExtra     =0;
33
        wndclass.hInstance      =0;
34
        wndclass.hIcon          =0;
35
        wndclass.hCursor        =0;
36
        wndclass.hbrBackground  =(HBRUSH)GetStockObject(LTGRAY_BRUSH);
37
        wndclass.lpszMenuName   =NULL;
38
        wndclass.lpszClassName  = szAppName;
39
 
40
        RegisterClass(&wndclass);
41
        hwnd=CreateWindowEx(0L,
42
                          szAppName,
43
                          "Hola",
44
                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
45
                          CW_USEDEFAULT,
46
                          CW_USEDEFAULT,
47
                          width,        /* 80, */
48
                          height,       /* 80, */
49
                          NULL,
50
                          NULL,
51
                          NULL,
52
                          NULL);
53
#if !ELKS
54
 
55
        hedit=CreateWindowEx(0L, "EDIT",
56
                "OK",
57
                WS_BORDER|WS_CHILD | WS_VISIBLE,
58
                width * 5 / 8, 10, 100, 18,
59
                hwnd, (HMENU)5, NULL, NULL);
60
 
61
        CreateWindowEx(0L, "PROGBAR",
62
                "OK",
63
                WS_BORDER|WS_CHILD | WS_VISIBLE,
64
                width * 5 / 8, 32, 100, 18,
65
                hwnd, (HMENU)6, NULL, NULL);
66
 
67
        hlist = CreateWindowEx(0L, "LISTBOX",
68
                "OK",
69
                WS_VSCROLL|
70
                /*WS_HSCROLL|*/
71
                WS_BORDER|WS_CHILD | WS_VISIBLE,
72
                width * 5 / 8, 54, 100, 54,
73
                hwnd, (HMENU)7, NULL, NULL);
74
 
75
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry");
76
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple");
77
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange");
78
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Banana");
79
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"Smooth");
80
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"00000");
81
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"11111");
82
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"22222");
83
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"33333");
84
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"44444");
85
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"55555");
86
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"66666");
87
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"77777");
88
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"88888");
89
        SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"99999");
90
 
91
        CreateWindowEx(0L, "BUTTON",
92
                "Cancel",
93
                WS_CHILD | WS_VISIBLE,
94
                width * 5 / 8 + 50, 106+16+6, 50, 14,
95
                hwnd, (HMENU)8, NULL, NULL);
96
 
97
        CreateWindowEx(0L, "STATIC",
98
                "Static",
99
                WS_CHILD | WS_VISIBLE,
100
                width * 5 / 8, 106+34+6, 100, 18,
101
                hwnd, (HMENU)9, NULL, NULL);
102
#if 0
103
        {
104
        HWND hcombo;
105
 
106
        hcombo = CreateWindowEx(0L, "COMBOBOX",
107
                 "Combobox",
108
#if 0
109
                 CBS_SIMPLE |           /* edit+list */
110
#endif
111
#if 0
112
                 CBS_DROPDOWNLIST |     /* static+pop */
113
#endif
114
#if 1
115
                 CBS_DROPDOWN |         /* edit+pop */
116
#endif
117
 
118
                 WS_VSCROLL | WS_CHILD | WS_VISIBLE,
119
                 width * 5 / 8, 106+14+4+18+4, 100, (18*5),
120
                 hwnd, (HMENU)10, NULL, NULL);
121
 
122
        SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Cherry");
123
        SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Apple");
124
        SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Orange");
125
        SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Banana");
126
        }
127
#endif
128
 
129
#if 1
130
        CreateWindowEx(0L, "SCROLLBAR",
131
                "OK",
132
                SBS_VERT |
133
                WS_CHILD | WS_VISIBLE ,
134
                width * 5 / 8 -(18*2), 106+68, 18, 128,
135
                hwnd, (HMENU)11, NULL, NULL);
136
 
137
        CreateWindowEx(0L, "SCROLLBAR",
138
                "OK",
139
                SBS_HORZ |
140
                WS_CHILD | WS_VISIBLE ,
141
                width * 5 / 8 -18 , 106+68, 128, 18,
142
                hwnd, (HMENU)12, NULL, NULL);
143
#endif
144
 
145
#endif
146
 
147
        ShowWindow(hwnd,iCmdShow);
148
        UpdateWindow(hwnd);
149
 
150
        while (GetMessage(&msg,NULL,0,0)) {
151
                TranslateMessage(&msg);
152
                DispatchMessage(&msg);
153
        }
154
 
155
        return msg.wParam;
156
}
157
LRESULT CALLBACK wproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
158
{
159
        HDC hdc;
160
        PAINTSTRUCT ps;
161
        RECT rect;
162
        HGDIOBJ oldfont;
163
 
164
        switch (iMsg) {
165
        case WM_CREATE:
166
                break;
167
        case WM_PAINT:
168
        /*case WM_MOUSEFIRST:*/
169
                hdc=BeginPaint(hwnd,&ps);
170
 
171
                /*GetClientRect(hwnd,&rc);*/
172
                /*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
173
                /*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
174
 
175
                GetClientRect(hwnd,&rect);
176
                oldfont=SelectObject(hdc,CreateFont(12,
177
                        0,0,0,0,0,0,0,0,0,0,0,
178
                        FF_DONTCARE|DEFAULT_PITCH,
179
                        "HZXFONT"));
180
                DrawText(hdc, "Hola, NOS, ¤¤¤å´ú¸Õ", -1, &rect,
181
                         DT_SINGLELINE|DT_CENTER|DT_VCENTER);
182
                DeleteObject(SelectObject(hdc,oldfont));
183
 
184
                /*for (i=0;i<100;i++)
185
                        SetPixel(hdc,i,i,BLUE);*/
186
 
187
                EndPaint(hwnd,&ps);
188
                break;
189
        case WM_DESTROY:
190
                PostQuitMessage(0);
191
                break;
192
        default:
193
                return DefWindowProc(hwnd,iMsg,wParam,lParam);
194
        }
195
        return 0;
196
}

powered by: WebSVN 2.1.0

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