Oh, all things disappeared!

I'm very disappointed: when finally correct all the grammar mistakes, screen only display the "0:0:0 0 ms"! where is button and record? !Please help me "find" them, thank you!
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <windows.h>
#define START 1
#define STOP 2
#define REC 3
#define REST 4
#include "MMSYSTEM.H"
#pragma comment(lib,"winmm.lib")
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
struct mtime
{
	int h,m,s,ms;
};
struct mbs {char name [9]; int id; Bs} [] = {" START time ",START," STOP the clock",STOP," suspended ", REST, "record", REC};
mtime timerec[50];//time recording
mtime nowtime;
int nowhowmany;//Now how much storage time record
int xchar,ychar;
HWND bshwnd[5];
int xwin=0,ywin=0;
bool rest=0;
int whenstart;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("HelloWin") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     
     hwnd = CreateWindow (szAppName,                  // window class name
                          TEXT ("The Hello Program"), // window caption
                          WS_OVERLAPPEDWINDOW,        // window style
                          CW_USEDEFAULT,              // initial x position
                          CW_USEDEFAULT,              // initial y position
                          CW_USEDEFAULT,              // initial x size
                          CW_USEDEFAULT,              // initial y size
                          NULL,                       // parent window handle
                          NULL,                       // window menu handle
                          hInstance,                  // program instance handle
                          NULL) ;                     // creation parameters
     
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
     
     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_CREATE:
		{
			int xchar = LOWORD (GetDialogBaseUnits ()),ychar = HIWORD (GetDialogBaseUnits ());
			nowtime.h=0,nowtime.m=0,nowtime.s=0,nowtime.ms=0;
			nowhowmany=0;
			for(int i=0;i<50;i++)
				timerec[i].h=0,timerec[i].m=0,timerec[i].s=0,timerec[i].ms=0;
			for(int j=0;j<4;j++)
				bshwnd[bs[j].id]=CreateWindow(TEXT("button"),bs[j].name,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
				0,0,1,1,hwnd,(HMENU)bs[j].id,((LPCREATESTRUCT) lParam)->hInstance,NULL);
			EnableWindow(bshwnd[STOP],0);
			EnableWindow(bshwnd[REST],0);
			EnableWindow(bshwnd[REC],0);
			SetFocus(bshwnd[START]);
			return 0;
		}
	case WM_SIZE:
		{
			xwin=LOWORD (lParam);
			ywin=HIWORD (lParam);
			for(int i=1;i<4;i++)
				MoveWindow(bshwnd[i],xwin*(i-1)/4,ychar,xwin/4,ychar*7/4,1);
			return 0;
		}
	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			char what[20];
			HDC hdc=BeginPaint(hwnd,&ps);
			TextOut(hdc,0,0,what,wsprintf(what,"%i:%i:%i  %ims",nowtime.h,nowtime.m,nowtime.s,nowtime.ms));
			for(int i=0;i<50;i++)
				TextOut(hdc,0,(ychar*11)/4+i,what,wsprintf(what,"%i:%i:%i  %ims",timerec[i].h,timerec[i].m,timerec[i].s,timerec[i].ms));
			EndPaint(hwnd,&ps);
			return 0;
		}
	case WM_TIMER:
		{
			nowtime.ms+=timeGetTime()-whenstart,whenstart=timeGetTime();
			if(nowtime.ms>=1000)
			{
				nowtime.ms-=1000;
				nowtime.s++;
				if(nowtime.s>=60)
				{
					nowtime.s=0;
					nowtime.m++;
					if(nowtime.m>=60)
					{
						nowtime.m=0;
						nowtime.h++;
					}
				}
			}
			return 0;
		}
	case WM_COMMAND:
		{
			if(HIWORD (wParam)==BN_CLICKED)
			{
				switch(LOWORD (wParam))
				{
				case START:
					{
					for(int i=0;i<50;i++)
						timerec[i].h=0,timerec[i].m=0,timerec[i].s=0,timerec[i].ms=0;
					SetFocus(bshwnd[STOP]);
					
					EnableWindow(bshwnd[START],0);
					EnableWindow(bshwnd[STOP],1);
					EnableWindow(bshwnd[REST],1);
					EnableWindow(bshwnd[REC],1);
					whenstart=timeGetTime();
					SetTimer(hwnd,1,1,NULL);
					break;
					}
				case STOP:
					SetFocus(bshwnd[START]);
					EnableWindow(bshwnd[STOP],0);
					EnableWindow(bshwnd[REST],0);
					EnableWindow(bshwnd[REC],0);
					KillTimer(hwnd,1);
					nowhowmany=0;
					break;
				case REST:
					if(rest)
					{
						rest=0;
						SetWindowText(bshwnd[REST],"suspended");
						SetTimer(hwnd,1,1,NULL);
					}
					else
					{
						rest=1;
						SetWindowText(bshwnd[REST],"continue");
						KillTimer(hwnd,1);
					}
					break;
				case REC:
					timerec[nowhowmany]=nowtime;
					break;
				}
			}
			return 0;
		}
	case WM_DESTROY :
		PostQuitMessage (0) ;
		return 0 ;
	case WM_CLOSE:
		if(MessageBox(hwnd,"Are you sure you want to exit timer?" , "confirmed exit",MB_YESNO)==IDYES)
			break;
		return 0;
	}
	return DefWindowProc (hwnd, message, wParam, lParam) ;
}
I might be missing something but line 13 looks off ... ?
What is 'Bs' ?
Last edited on
It is one of the 'grammer' aka syntax errors he was talking about.

If he corrects the syntax errors and gets the program to run, there are a number of logical/operational errors bugs that prevent the window showing properly.
struct mbs{char name[9];int id;}bs[]=......
Possible computer translation tune "word order",so......
Topic archived. No new replies allowed.