Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INT_PTR CALLBACK Shop(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- char iTxt[20],item[20];
- int ind2,length,ind;
- string Drinks[7] ;
- string Food[7];
- string Clother[7];
- char* str;
- Drinks[0] = "beer";
- Drinks[1] = "milk";
- Drinks[2] = "soda";
- Drinks[3] = "water";
- Drinks[4] = "limonade";
- Drinks[5] = "fanta";
- Drinks[6] = "kola";
- Food[0] = "pizza";
- Food[1] = "pasta";
- Food[2] = "hamburger";
- Food[3] = "fish";
- Food[4] = "cheese";
- Food[5] = "eggs";
- Food[6] = "cake";
- Clother[0] = "shirt";
- Clother[1] = "t-shirt";
- Clother[2] = "jeans";
- Clother[3] = "dress";
- Clother[4] = "top";
- Clother[5] = "pants";
- Clother[6] = "shoes";
- UNREFERENCED_PARAMETER(lParam);
- switch (message)
- {
- case WM_INITDIALOG:
- CheckDlgButton(hDlg, IDC_RADIO_KEYBOARD, BST_CHECKED);
- CheckDlgButton(hDlg, IDC_RADIO_DRINKS, BST_CHECKED);
- //CheckDlgButton(hDlg, IDC_RADIO_ARRAY, BST_CHECKED);
- //CheckDlgButton(hDlg, IDC_RADIO_FOOD, BST_CHECKED);
- //CheckDlgButton(hDlg, IDC_RADIO_CLOTHES, BST_CHECKED);
- return (INT_PTR)TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else if (LOWORD(wParam) == IDC_ADD) {
- if (SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_FINDSTRING, -1, (LPARAM)iTxt) == LB_ERR) {
- if (IsDlgButtonChecked(hDlg, IDC_RADIO_KEYBOARD))
- {//вземаме съдържанието в Item(edit control) и го добавяме в Articles (list box)
- GetDlgItemText(hDlg, IDC_ITEM, (LPSTR)iTxt, 20);
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_ADDSTRING, 0, (LPARAM)iTxt);
- }
- if (IsDlgButtonChecked(hDlg, IDC_RADIO_ARRAY)) {
- if (IsDlgButtonChecked(hDlg, IDC_RADIO_DRINKS)) {
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_RESETCONTENT, 0, 0);
- for (int i = 0; i < 7; i++) {
- string temp = Drinks[i];
- str = &temp[0];
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_ADDSTRING, 0, (LPARAM)str);
- }
- }else if (IsDlgButtonChecked(hDlg, IDC_RADIO_FOOD)) {
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_RESETCONTENT, 0, 0);
- for (int i = 0; i < 7; i++) {
- string temp = Food[i];
- str = &temp[0];
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_ADDSTRING, 0, (LPARAM)str);
- }
- }else if (IsDlgButtonChecked(hDlg, IDC_RADIO_CLOTHES)) {
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_RESETCONTENT, 0, 0);
- for (int i = 0; i < 7; i++) {
- string temp = Clother[i];
- str = &temp[0];
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_ADDSTRING, 0, (LPARAM)str);
- }
- }
- }
- }
- } else if (LOWORD(wParam) == IDC_BUY) {
- char* text;
- ind2 = SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_GETCURSEL, 0, 0);
- length= SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_GETTEXTLEN, ind2, 0);
- text = new char[length + 1];
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_GETTEXT, ind2, (LPARAM)text);
- if (SendDlgItemMessage(hDlg, IDC_COMBO_CART,CB_FINDSTRING,-1, (LPARAM)text)==CB_ERR) {
- SendDlgItemMessage(hDlg, IDC_COMBO_CART, CB_ADDSTRING, 0, (LPARAM)text);
- SendDlgItemMessage(hDlg, IDC_COMBO_CART, CB_SELECTSTRING, -1, (LPARAM)text);
- }
- }
- else if (LOWORD(wParam) == IDC_DELETE) {
- ind = SendDlgItemMessage(hDlg, IDC_COMBO_CART, CB_GETCURSEL, 0, 0);
- SendDlgItemMessage(hDlg, IDC_COMBO_CART, CB_DELETESTRING, ind, 0);
- }
- else if (LOWORD(wParam) == IDC_SEARCH) {
- GetDlgItemText(hDlg, IDC_ITEM, item, 20);
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_SELECTSTRING, -1, (LPARAM)item);
- if (SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_SELECTSTRING, -1, (LPARAM)item) == LB_ERR) {
- MessageBox(NULL, "No such item!", "Information", MB_ICONINFORMATION | MB_YESNO);
- }
- }
- else if (LOWORD(wParam) == IDC_CLEAR) {
- SetWindowText(GetDlgItem(hDlg, IDC_ITEM), "");
- SendDlgItemMessage(hDlg, IDC_LIST_ARTICLES, LB_RESETCONTENT, 0, 0);
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment