Advertisement
Guest User

fdsfsd

a guest
Mar 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. // sdkl;fjsdklfjl.cpp : Defines the entry point for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "sdkl;fjsdklfjl.h"
  6.  
  7. #define MAX_LOADSTRING 100
  8.  
  9. // Global Variables:
  10. HINSTANCE hInst; // current instance
  11. TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  12. TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
  13.  
  14. // Forward declarations of functions included in this code module:
  15. ATOM MyRegisterClass(HINSTANCE hInstance);
  16. BOOL InitInstance(HINSTANCE, int);
  17. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  18. INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  19. INT_PTR CALLBACK Shopping(HWND, UINT, WPARAM, LPARAM);
  20.  
  21. int APIENTRY _tWinMain(HINSTANCE hInstance,
  22. HINSTANCE hPrevInstance,
  23. LPTSTR lpCmdLine,
  24. int nCmdShow)
  25. {
  26. UNREFERENCED_PARAMETER(hPrevInstance);
  27. UNREFERENCED_PARAMETER(lpCmdLine);
  28.  
  29. // TODO: Place code here.
  30. MSG msg;
  31. HACCEL hAccelTable;
  32.  
  33. // Initialize global strings
  34. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  35. LoadString(hInstance, IDC_SDKLFJSDKLFJL, szWindowClass, MAX_LOADSTRING);
  36. MyRegisterClass(hInstance);
  37.  
  38. // Perform application initialization:
  39. if (!InitInstance (hInstance, nCmdShow))
  40. {
  41. return FALSE;
  42. }
  43.  
  44. hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SDKLFJSDKLFJL));
  45.  
  46. // Main message loop:
  47. while (GetMessage(&msg, NULL, 0, 0))
  48. {
  49. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  50. {
  51. TranslateMessage(&msg);
  52. DispatchMessage(&msg);
  53. }
  54. }
  55.  
  56. return (int) msg.wParam;
  57. }
  58.  
  59.  
  60.  
  61. //
  62. // FUNCTION: MyRegisterClass()
  63. //
  64. // PURPOSE: Registers the window class.
  65. //
  66. // COMMENTS:
  67. //
  68. // This function and its usage are only necessary if you want this code
  69. // to be compatible with Win32 systems prior to the 'RegisterClassEx'
  70. // function that was added to Windows 95. It is important to call this function
  71. // so that the application will get 'well formed' small icons associated
  72. // with it.
  73. //
  74. ATOM MyRegisterClass(HINSTANCE hInstance)
  75. {
  76. WNDCLASSEX wcex;
  77.  
  78. wcex.cbSize = sizeof(WNDCLASSEX);
  79.  
  80. wcex.style = CS_HREDRAW | CS_VREDRAW;
  81. wcex.lpfnWndProc = WndProc;
  82. wcex.cbClsExtra = 0;
  83. wcex.cbWndExtra = 0;
  84. wcex.hInstance = hInstance;
  85. wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SDKLFJSDKLFJL));
  86. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  87. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  88. wcex.lpszMenuName = MAKEINTRESOURCE(IDC_SDKLFJSDKLFJL);
  89. wcex.lpszClassName = szWindowClass;
  90. wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  91.  
  92. return RegisterClassEx(&wcex);
  93. }
  94.  
  95. //
  96. // FUNCTION: InitInstance(HINSTANCE, int)
  97. //
  98. // PURPOSE: Saves instance handle and creates main window
  99. //
  100. // COMMENTS:
  101. //
  102. // In this function, we save the instance handle in a global variable and
  103. // create and display the main program window.
  104. //
  105. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  106. {
  107. HWND hWnd;
  108.  
  109. hInst = hInstance; // Store instance handle in our global variable
  110.  
  111. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  112. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  113.  
  114. if (!hWnd)
  115. {
  116. return FALSE;
  117. }
  118.  
  119. ShowWindow(hWnd, nCmdShow);
  120. UpdateWindow(hWnd);
  121.  
  122. return TRUE;
  123. }
  124.  
  125. //
  126. // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  127. //
  128. // PURPOSE: Processes messages for the main window.
  129. //
  130. // WM_COMMAND - process the application menu
  131. // WM_PAINT - Paint the main window
  132. // WM_DESTROY - post a quit message and return
  133. //
  134. //
  135. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  136. {
  137. int wmId, wmEvent;
  138. PAINTSTRUCT ps;
  139. HDC hdc;
  140.  
  141. switch (message)
  142. {
  143. case WM_COMMAND:
  144. wmId = LOWORD(wParam);
  145. wmEvent = HIWORD(wParam);
  146. // Parse the menu selections:
  147. switch (wmId)
  148. {
  149. case IDM_ABOUT:
  150. DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  151. break;
  152. case IDM_EXIT:
  153. DestroyWindow(hWnd);
  154. break;
  155. case ID_TOOLS_SHOPPING:
  156. DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Shopping);
  157. break;
  158. default:
  159. return DefWindowProc(hWnd, message, wParam, lParam);
  160. }
  161. break;
  162. case WM_PAINT:
  163. hdc = BeginPaint(hWnd, &ps);
  164. // TODO: Add any drawing code here...
  165. EndPaint(hWnd, &ps);
  166. break;
  167. case WM_DESTROY:
  168. PostQuitMessage(0);
  169. break;
  170. default:
  171. return DefWindowProc(hWnd, message, wParam, lParam);
  172. }
  173. return 0;
  174. }
  175.  
  176. // Message handler for about box.
  177. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  178. {
  179. UNREFERENCED_PARAMETER(lParam);
  180. switch (message)
  181. {
  182. case WM_INITDIALOG:
  183. return (INT_PTR)TRUE;
  184.  
  185. case WM_COMMAND:
  186. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  187. {
  188. EndDialog(hDlg, LOWORD(wParam));
  189. return (INT_PTR)TRUE;
  190. }
  191. break;
  192. }
  193. return (INT_PTR)FALSE;
  194. }
  195. INT_PTR CALLBACK Shopping(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  196. {
  197. UNREFERENCED_PARAMETER(lParam);
  198. switch (message)
  199. {
  200. case WM_INITDIALOG:
  201. CheckDlgButton(hDlg, IDC_RADIO1, BST_CHECKED);
  202. CheckDlgButton(hDlg, IDC_RADIO3, BST_CHECKED);
  203. return (INT_PTR)TRUE;
  204.  
  205. case WM_COMMAND:
  206. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  207. {
  208. EndDialog(hDlg, LOWORD(wParam));
  209. return (INT_PTR)TRUE;
  210. }
  211. if (LOWORD(wParam) == IDC_BUTTON1)
  212. {
  213. if(IsDlgButtonChecked(hDlg,IDC_RADIO1))
  214. {
  215. char as[20];
  216. GetDlgItemText(hDlg,IDC_EDIT1,as,20);
  217. SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) as);
  218. }
  219. if(IsDlgButtonChecked(hDlg,IDC_RADIO2))
  220. {
  221. const char* drinkar[6]={"kola","mosnter","fanta","menta","rakiq"};
  222. const char* foodar[6]={"krastvaciq","domat","kartof","magadanozi","marulq"};
  223. const char* clothesar[6]={"tshirt","sweater","pants","shoes","kelemqvka"};
  224.  
  225. if(IsDlgButtonChecked(hDlg,IDC_RADIO3))
  226. {
  227. for(int i=0;i<5;i++){
  228. SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) drinkar[i]);
  229. }
  230. }
  231. if(IsDlgButtonChecked(hDlg,IDC_RADIO4))
  232. {
  233. for(int i=0;i<5;i++){
  234. SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) foodar[i]);
  235. }
  236. }
  237. if(IsDlgButtonChecked(hDlg,IDC_RADIO5))
  238. {
  239. for(int i=0;i<5;i++){
  240. SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) clothesar[i]);
  241. }
  242. }
  243.  
  244. }
  245. }
  246. if (LOWORD(wParam) == IDC_BUTTON2)
  247. {
  248. char as[20];
  249. int indx = SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETCURSEL,0,0);
  250.  
  251. GetDlgItemText(hDlg,indx,as,20);
  252. SendMessage(hDlg, LB_GETTEXT, indx, (LPARAM)IDC_LIST1);
  253. SendDlgItemMessage(hDlg, IDC_LIST1, LB_GETTEXT,indx,(LPARAM)as);
  254. int check=SendDlgItemMessage(hDlg, IDC_COMBO1, CB_FINDSTRING,0,(LPARAM)as);
  255. if(check==LB_ERR)
  256. {
  257. SendDlgItemMessage(hDlg, IDC_COMBO1, CB_ADDSTRING,0,(LPARAM)as);
  258. }
  259. SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SELECTSTRING,0,(LPARAM)as);
  260.  
  261. }
  262. if (LOWORD(wParam) == IDC_BUTTON3)
  263. {
  264. char as[20];
  265. int indx = SendDlgItemMessage(hDlg, IDC_COMBO1, CB_GETCURSEL,0,0);
  266. GetDlgItemText(hDlg,indx,as,20);
  267. SendDlgItemMessage(hDlg,IDC_COMBO1, CB_DELETESTRING,indx,(LPARAM)as);
  268. }
  269. if (LOWORD(wParam) == IDC_BUTTON4)
  270. {
  271. SendDlgItemMessage(hDlg, IDC_COMBO1, CB_RESETCONTENT,0,0);
  272. }
  273. if (LOWORD(wParam) == IDC_BUTTON5)
  274. {
  275. char as[20];
  276. GetDlgItemText(hDlg,IDC_EDIT1,as,20);
  277. int check=SendDlgItemMessage(hDlg, IDC_LIST1, LB_FINDSTRING,0,(LPARAM)as);
  278. if(check!=LB_ERR)
  279. SendDlgItemMessage(hDlg, IDC_LIST1, LB_SELECTSTRING,0,(LPARAM)as);
  280. else
  281. MessageBox(hDlg,"Not Found","Nqma takuv item vuv lista",MB_OK);
  282. }
  283. break;
  284. }
  285. return (INT_PTR)FALSE;
  286. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement