codice:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
CreateWindow(TEXT("button"),TEXT("Hello"), WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON , 60,80,100,25, hwnd, (HMENU) 1, NULL , NULL);
CreateWindow(TEXT("edit"),TEXT("0"), WS_TABSTOP | WS_VISIBLE | WS_CHILD , 10,10,100,20, hwnd, (HMENU) 2, NULL , NULL);
CreateWindow(TEXT("edit"),TEXT("0"), WS_TABSTOP | WS_VISIBLE | WS_CHILD , 120,10,100,20, hwnd, (HMENU) 3, NULL , NULL);
CreateWindow(TEXT("edit"),TEXT("0"), WS_TABSTOP | WS_VISIBLE | WS_CHILD , 60,40,100,20, hwnd, (HMENU) 4, NULL , NULL);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case 1:
char* a; char* b;
GetWindowText(GetDlgItem(hwnd,2), a , 256 );
GetWindowText(GetDlgItem(hwnd,3), b , 256 );
int aV = conv.FromCharToInt(a);
int bV = conv.FromCharToInt(b);
int x = aV + bV;
SetWindowText(GetDlgItem(hwnd,4), conv.FromIntToConstChar(bV) );
break;
}
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
il codice del FromCharToInt è questo: