sppmacd Temat założony przez niniejszego użytkownika |
[C++] [WinAPI] Request for member 'str' in 'L1', which is of non-class type 'double' » 2016-05-07 15:59:36 Witam, mam problem z kodem.
-------------- Build: Debug in calculator (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -g -c C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp -o obj\Debug\main.o C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp: In function 'LRESULT WindowProcedure(HWND, UINT, WPARAM, LPARAM)': C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:152:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:157:48: error: request for member 'str' in 'L2', which is of non-class type 'double' [b]SetWindowText( sl2, L2.str().c_str() );[/b] ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:170:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:175:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:188:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:193:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:206:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:211:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:224:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:229:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:242:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:247:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:260:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:265:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:278:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:283:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:296:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:301:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:314:48: error: request for member 'str' in 'L1', which is of non-class type 'double' SetWindowText( sl1, L1.str().c_str() ); ^ C:\Users\Adios\Desktop\Programy\moje\calculator\main.cpp:319:48: error: request for member 'str' in 'L2', which is of non-class type 'double' SetWindowText( sl2, L2.str().c_str() ); ^ Process terminated with status 1 (0 minute(s), 0 second(s)) 20 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Kod: #if defined(UNICODE) && !defined(_UNICODE) #define _UNICODE #elif defined(_UNICODE) && !defined(UNICODE) #define UNICODE #endif
#include <tchar.h> #include <windows.h> #include <string> #include <iostream> #include <cmath>
#define ID_1 1000 #define ID_2 1001 #define ID_3 1002 #define ID_4 1003 #define ID_5 1004 #define ID_6 1005 #define ID_7 1006 #define ID_8 1007 #define ID_9 1008 #define ID_0 1009 #define ID_D 1010 #define ID_O 1011 #define ID_M 1012 #define ID_Z 1013 #define ID_R 1014 #define ID_K 1015 #define ID_POT 1016 #define ID_SQR 1017 #define ID_SL1 2000 #define ID_SL2 2001
short TYPE = 0; double L1 = 0; double L2 = 0; double WYNIK = 0;
HWND hwnd, p1, p2, p3, p4, p5, p6, p7, p8, p9, p0, pd, po, pm, pz, pk, ppot, psqr, sl1, sl2, pr;
LRESULT CALLBACK WindowProcedure( HWND, UINT, WPARAM, LPARAM );
TCHAR szClassName[] = _T( "CodeBlocksWindowsApp" );
int WINAPI WinMain( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow ) { MSG messages; WNDCLASSEX wincl; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof( WNDCLASSEX ); wincl.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wincl.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); wincl.hCursor = LoadCursor( NULL, IDC_ARROW ); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground =( HBRUSH ) COLOR_BACKGROUND; if( !RegisterClassEx( & wincl ) ) return 0; hwnd = CreateWindowEx( 0, szClassName, _T( "Kalkulator" ), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 375, HWND_DESKTOP, NULL, hThisInstance, NULL ), p1 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "1", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 190, 30, 30, hwnd,( HMENU ) ID_1, hThisInstance, NULL ), p2 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "2", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 190, 30, 30, hwnd,( HMENU ) ID_2, hThisInstance, NULL ), p3 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "3", WS_CHILD | WS_VISIBLE | WS_BORDER, 90, 190, 30, 30, hwnd,( HMENU ) ID_3, hThisInstance, NULL ), p4 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "4", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 150, 30, 30, hwnd,( HMENU ) ID_4, hThisInstance, NULL ), p5 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "5", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 150, 30, 30, hwnd,( HMENU ) ID_5, hThisInstance, NULL ), p6 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "6", WS_CHILD | WS_VISIBLE | WS_BORDER, 90, 150, 30, 30, hwnd,( HMENU ) ID_6, hThisInstance, NULL ), p7 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "7", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 110, 30, 30, hwnd,( HMENU ) ID_7, hThisInstance, NULL ), p8 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "8", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 110, 30, 30, hwnd,( HMENU ) ID_8, hThisInstance, NULL ), p9 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "9", WS_CHILD | WS_VISIBLE | WS_BORDER, 90, 110, 30, 30, hwnd,( HMENU ) ID_9, hThisInstance, NULL ), p0 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "0", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 230, 30, 30, hwnd,( HMENU ) ID_0, hThisInstance, NULL ), pd = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "+", WS_CHILD | WS_VISIBLE | WS_BORDER, 130, 110, 30, 30, hwnd,( HMENU ) ID_D, hThisInstance, NULL ), po = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "-", WS_CHILD | WS_VISIBLE | WS_BORDER, 130, 150, 30, 30, hwnd,( HMENU ) ID_O, hThisInstance, NULL ), pm = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "*", WS_CHILD | WS_VISIBLE | WS_BORDER, 130, 190, 30, 30, hwnd,( HMENU ) ID_M, hThisInstance, NULL ), pz = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "/", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 230, 30, 30, hwnd,( HMENU ) ID_Z, hThisInstance, NULL ), pk = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", ":10", WS_CHILD | WS_VISIBLE | WS_BORDER, 130, 230, 30, 30, hwnd,( HMENU ) ID_K, hThisInstance, NULL ), ppot = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "^", WS_CHILD | WS_VISIBLE | WS_BORDER, 170, 110, 30, 30, hwnd,( HMENU ) ID_POT, hThisInstance, NULL ), psqr = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "SQ", WS_CHILD | WS_VISIBLE | WS_BORDER, 170, 150, 30, 30, hwnd,( HMENU ) ID_SQR, hThisInstance, NULL ), sl1 = CreateWindowEx( WS_EX_CLIENTEDGE, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 70, 190, 30, hwnd,( HMENU ) ID_SL1, hThisInstance, NULL ), sl2 = CreateWindowEx( WS_EX_CLIENTEDGE, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 30, 190, 30, hwnd,( HMENU ) ID_SL2, hThisInstance, NULL ), pr = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "=", WS_CHILD | WS_VISIBLE | WS_BORDER, 90, 230, 30, 30, hwnd,( HMENU ) ID_R, hThisInstance, NULL ); ShowWindow( hwnd, nCmdShow ); while( GetMessage( & messages, NULL, 0, 0 ) ) { TranslateMessage( & messages ); DispatchMessage( & messages ); } return messages.wParam; }
LRESULT CALLBACK WindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { switch( message ) { case WM_DESTROY: PostQuitMessage( 0 ); break; case WM_COMMAND: switch( wParam ) { case ID_1: { if( TYPE == 0 ) { L1 = L1 * 10 + 1; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 1; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_2: { if( TYPE == 0 ) { L1 = L1 * 10 + 2; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 2; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_3: { if( TYPE == 0 ) { L1 = L1 * 10 + 3; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 3; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_4: { if( TYPE == 0 ) { L1 = L1 * 10 + 4; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 4; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_5: { if( TYPE == 0 ) { L1 = L1 * 10 + 5; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 5; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_6: { if( TYPE == 0 ) { L1 = L1 * 10 + 6; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 6; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_7: { if( TYPE == 0 ) { L1 = L1 * 10 + 7; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 7; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_8: { if( TYPE == 0 ) { L1 = L1 * 10 + 8; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 8; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_9: { if( TYPE == 0 ) { L1 = L1 * 10 + 9; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 9; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_0: { if( TYPE == 0 ) { L1 = L1 * 10 + 0; SetWindowText( sl1, L1.str().c_str() ); } else { L2 = L2 * 10 + 0; SetWindowText( sl2, L2.str().c_str() ); } std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_D: { TYPE = 1; std::cout << TYPE << std::endl; break; } case ID_O: { TYPE = 2; std::cout << TYPE << std::endl; break; } case ID_M: { TYPE = 3; std::cout << TYPE << std::endl; break; } case ID_Z: { TYPE = 4; std::cout << TYPE << std::endl; break; } case ID_POT: { TYPE = 5; std::cout << TYPE << std::endl; break; } case ID_SQR: { TYPE = 6; std::cout << TYPE << std::endl; break; } case ID_K: { if( TYPE == 0 ) L1 = L1 / 10; else L2 = L2 / 10; std::cout << L1 << std::endl; std::cout << L2 << std::endl; std::cout << TYPE << std::endl; break; } case ID_R: { switch( TYPE ) { case 1: WYNIK = L1 + L2; break; case 2: WYNIK = L1 - L2; break; case 3: WYNIK = L1 * L2; break; case 4: WYNIK = L1 / L2; break; case 5: WYNIK = pow( L1, L2 ); break; case 6: WYNIK = sqrt( L1 ); break; } std::cout << WYNIK << std::endl; L1 = L2 = TYPE = WYNIK = 0; } } default: return DefWindowProc( hwnd, message, wParam, lParam ); } return 0; }
Proszę o pomoc! |