-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.c
132 lines (116 loc) · 3.31 KB
/
app.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <windows.h>
#include <stdio.h>
#include "ui.h"
#include "p1.h"
int B1, B2, B3, B4, E1, E2, C1, COMBO1, EML1, L1, LB1;
void app_thread(void *dummy)
{
char s[64];
while(1)
{
static int cnt;
sprintf(s, "%6d\r\n", cnt);
// if (cnt == 20)
// cnt = 0;
ENABLE_WIDGET(B1, cnt > 10);
ENABLE_WIDGET(B2, cnt > 10);
RO_WIDGET(E1, cnt > 10);
printf("%d", cnt > 10);
Sleep(100);
printf("."); fflush(stdout);
if (IS_CHECKBOX_CHECKED(C1))
{
EDITBOX_MULTILINE_APPEND_TEXT(EML1, s);
cnt++;
}
continue;
#if 0
char tmp[64];
int editlength = GetWindowTextLength(hTxt1);
GetWindowText(hTxt1, tmp, editlength+1);
printf("[%s]", tmp);
if (checkBoxVal)
{
AppendText(hTxtML, "\r\n");
AppendText(hTxtML, s);
UpdateWindow(hTxtML);
}
SetWindowText( hTxt, s);
if (cnt>10)
{
attivo=1;
backColor=RGB(255,255,0);
UpdateWindow(hTxt);
EnableWindow(hBtn1, FALSE);
}
if (cnt>100)
EnableWindow(hTxt, FALSE);
#endif
}
}
void listbox_selected(int i)
{
int pos = (int)SendMessage(dialog[i].hwnd, LB_GETCURSEL, 0, 0);
int idx =(int)SendMessage(dialog[i].hwnd, LB_GETITEMDATA, pos, 0);
if (idx != LB_ERR)
{
printf("Selected pos=%d idx=%d\n", pos, idx);
}
}
void B_pressed(int i)
{
printf("pressed %d\n", i);
}
void Text_changed(int i)
{
printf("Text changed %d\n", i);
}
void CheckBox_change(int i)
{
printf("Checkbox change %d\n", i);
}
void combo_selected(int i)
{
int comboIndex = SendMessage(dialog[i].hwnd, (UINT) CB_GETCURSEL, 0, 0);
printf("selected combo %d\n", comboIndex);
// SendMessage(dialog[i].hwnd, (UINT)CB_GETLBTEXT, (WPARAM)comboIndex, (LPARAM)listName);
}
void create_widget(void)
{
B1 = BUTTON_DEF (10, 8, 175, 22, "B1");
B2 = BUTTON_DEF (10, 38, 175, 22, "B2");
B3 = BUTTON_DEF (10, 68, 175, 22, "B3");
B4 = BUTTON_DEF (200, 8, 125, 90, "CLEAR");
LB1 = LISTBOX_DEF (200, 100, 125, 100);
E1 = EDIT_DEF (10, 98, 175, 17, "");
E2 = EDIT_DEF (10, 128, 175, 17, "");
C1 = CHECKBOX_DEF(10, 158, 175, 22, "checkbox");
COMBO1 = COMBOBOX_DEF(10, 218, 175, 22, "combobox");
L1 = LABEL_DEF (10, 248, 90, 22, "LABEL");
EML1 = EDITBOX_MULTILINE_DEF(10, 278, 275, 100);
for (int i=50; i; i--)
{
char s[64];
sprintf(s, "CIAO%d", i);
LISTBOX_ADD (LB1, s);
}
LISTBOX_DEF_ON_CLICK(LB1, listbox_selected);
COMBOBOX_ADD(COMBO1, "item1");
COMBOBOX_ADD(COMBO1, "item2");
COMBOBOX_ADD(COMBO1, "item3");
COMBOBOX_ADD(COMBO1, "item4");
COMBOBOX_DEF_ON_CLICK(COMBO1, combo_selected);
BUTTON_DEF_ON_CLICK(B1, B_pressed);
BUTTON_DEF_ON_CLICK(B2, B_pressed);
BUTTON_DEF_ON_CLICK(B3, B_pressed);
EDITBOX_DEF_ON_CHANGE(E1, Text_changed);
EDITBOX_DEF_ON_CHANGE(E2, Text_changed);
CHECKBOX_DEF_ON_CLICK(C1, CheckBox_change);
}
void main(int argc, char *argv[])
{
create_main_win(340,500);
create_widget();
// _beginthread(app_thread , 0, 0);
main_loop();
}