C++ pəncərədə əməliyyat

Salam c++ pəncərədə switchin arasina yazıram coutu səhv vermir amma ekrana da heçnə cıxmır necə edə bilərəm? [code] #include <windows.h> #include <iostream> /* This is where all the input to the window goes to */ LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_CREATE:{ int a; std::cin>>a; std::cout<<"Salamlar"; break; } /* Upon destruction, tell the main thread to stop */ case WM_DESTROY: { PostQuitMessage(0); break; } /* All other messages (a lot of them) are processed using default procedures */ default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0; } /* The 'main' function of Win32 GUI programs: this is where execution starts */ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; /* A properties struct of our window */ HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */ MSG Msg; /* A temporary location for all messages */ /* zero out the struct and set the stuff we want to modify */ memset(&wc,0,sizeof(wc)); wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = WndProc; /* This is where we will send messages to */ wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); /* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszClassName = "WindowClass"; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */ wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */ if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, /* x */ CW_USEDEFAULT, /* y */ 640, /* width */ 480, /* height */ NULL,NULL,hInstance,NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } /* This is the heart of our program where all input is processed and sent to WndProc. Note that GetMessage blocks code flow until it receives something, so this loop will not produce unreasonably high CPU usage */ while(GetMessage(&Msg, NULL, 0, 0) > 0) { /* If no error is received... */ TranslateMessage(&Msg); /* Translate key codes to chars if present */ DispatchMessage(&Msg); /* Send it to WndProc */ } return Msg.wParam; } [/code]

Verilmiş cavablar və yazılan şərhlər (5 cavab var)

Azerbaycan (2014-07-31 15:16:54)
Size cox tesekkur edirem Uje hemin buttonu biraz basa dusdum ne ne ucun du hele serbestde yazdim kodu 2-3 defe indi o button uzerinde emeliyyatlari nece aprmaq olar? yeni buttona basanda nese olsun? Birde orda hmenu ve getmodulehandle neyi temsil edir?

Azerbaycan (2014-07-31 13:37:35)
Tesekkur edirem ancaq cetindi cetin basdamisam axrina kimide gedecem qabaqda 4 il vaxtim var hele

ahmed (2014-07-31 12:47:58)
Həmin o dediyiniz yerə aşağıdakı kodu əlavə edib yoxlayın, pəncərədə yeni düymə yaranmalıdır. [code] HWND hWndButton=CreateWindowEx(NULL, "BUTTON", "OK", WS_TABSTOP|WS_VISIBLE| WS_CHILD|BS_DEFPUSHBUTTON, 50, 220, 100, 24, hwnd, (HMENU)101, GetModuleHandle(NULL), NULL); [/code] cin, cout ona görə səhv vermir ki, orda səhv heçnə yoxdur. cin, cout standart giriş/çıxış faylları ilə işləyir. kansol proqramlarında bu fayllar ekrana və klaviaturaya istinad edir. GUİ proqramlarında isə vəziyyət ayrı cürdür. GUİ proqramlar event driven proqramlardır. Yəni hadisəyə bağlı. İstifadəçinin icra elədiyi işləri izləməlisiniz və müvafiq kodu yerinə yetirməlisiniz. Amma Win32 C++ kodları ilə indi hər adam məşğul ola bilmir. Bu Windows GUI proqramlaşdırmanın ən köhnə və olduqca çətin yoludur. Bundan sonra MFC -dən istifadə olundu obyekt yönümlu. Hal-hazırda isə .NET C# geniş yayılıb. Sizin kodlaşdırmağa cəhd elədiyiniz iş ən güclü proqramçıların çətinliklə öhdəsinnən gəldiyi işlərdir. İnternetdə videolar ola bilər, amma dediyim kimi Win32 -dən əvvəllər istidfadə olunurdu, indi heç kim onnan istifadə eləmir. Örgənmək də mənasızdır. Onnansa elə dərinnən C++ dilinə həvəsiniz varsa və öz proqramçı bacarığınızı sınamaq istəyirsinizsə ağacları örgənməyi , ağac yaratmağı, ağacda axtarış aparmağı v.s. kimi işlərlə məşğul olmağı məsləhət görürəm. Obyekt yönümlü proqramlaşdırmadan və göstəricilərdən birlikdə istifadə etməklə.

Azerbaycan (2014-07-31 11:55:31)
Neticede hecne birdene pencere acilir fso bes yaxsi bura yazini nece yazim? bes onda cin,cout neye goredi?cin, cout sehv olsaydi asipka gostererdi de Internetde videosu var button yaratmagin men ne qeder edirem alinmir.ne etmeliyemse 6-11 ci setrler arasindfa yazmaliyam internetde videolarda ele edirler prosta mende alinmir

ahmed (2014-07-31 10:11:23)
Proqram kompilyasiya olur? Nəticə alırsan? Bu kansol proqramı deyil, GUİ proqramıdır, WinMain -dən istifadə eliyirsən. Yəni cout, cin -dən burada istifadə eliyə bilmərsən, ancaq standart çıxış deskriptorların dəyişib log kimi fayla nəsə yaza bilərsən.

Mövzu üzrə bənzər suallara da baxa bilərsiniz.

proqramlaşdırma üçün ingilis dilində bilik səviyəsi

C++ input

C++ da problem

C diski

programlaşdırmanı kurslarda öyrənmək yoxsa özbaşına öyrənmək?

C#-da prosesə progress bar qoşmaq