-----------------------------------------------------------------------------*/
| 733 | |
| 734 | /*-----------------------------------------------------------------------------*/ |
| 735 | void |
| 736 | LayoutMenu(HWND hWnd) |
| 737 | { |
| 738 | PNHMenuWindow data; |
| 739 | HWND menu_ok; |
| 740 | HWND menu_cancel; |
| 741 | RECT clrt, rt; |
| 742 | POINT pt_elem, pt_ok, pt_cancel; |
| 743 | SIZE sz_elem, sz_ok, sz_cancel; |
| 744 | |
| 745 | data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); |
| 746 | menu_ok = GetDlgItem(hWnd, IDOK); |
| 747 | menu_cancel = GetDlgItem(hWnd, IDCANCEL); |
| 748 | |
| 749 | /* get window coordinates */ |
| 750 | GetClientRect(hWnd, &clrt); |
| 751 | |
| 752 | // OK button |
| 753 | if (data->is_active) { |
| 754 | GetWindowRect(menu_ok, &rt); |
| 755 | if (data->type == MENU_TYPE_TEXT |
| 756 | || (data->type == MENU_TYPE_MENU && data->how == PICK_NONE)) { |
| 757 | sz_ok.cx = (clrt.right - clrt.left) - 2 * MENU_MARGIN; |
| 758 | } else { |
| 759 | sz_ok.cx = (clrt.right - clrt.left) / 2 - 2 * MENU_MARGIN; |
| 760 | } |
| 761 | sz_ok.cy = rt.bottom - rt.top; |
| 762 | pt_ok.x = clrt.left + MENU_MARGIN; |
| 763 | pt_ok.y = clrt.bottom - MENU_MARGIN - sz_ok.cy; |
| 764 | ShowWindow(menu_ok, SW_SHOW); |
| 765 | MoveWindow(menu_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE); |
| 766 | } else { |
| 767 | sz_ok.cx = sz_ok.cy = 0; |
| 768 | pt_ok.x = pt_ok.y = 0; |
| 769 | ShowWindow(menu_ok, SW_HIDE); |
| 770 | } |
| 771 | |
| 772 | // CANCEL button |
| 773 | if (data->is_active |
| 774 | && !(data->type == MENU_TYPE_TEXT |
| 775 | || (data->type == MENU_TYPE_MENU && data->how == PICK_NONE))) { |
| 776 | GetWindowRect(menu_ok, &rt); |
| 777 | sz_cancel.cx = (clrt.right - clrt.left) / 2 - 2 * MENU_MARGIN; |
| 778 | pt_cancel.x = (clrt.left + clrt.right) / 2 + MENU_MARGIN; |
| 779 | sz_cancel.cy = rt.bottom - rt.top; |
| 780 | pt_cancel.y = clrt.bottom - MENU_MARGIN - sz_cancel.cy; |
| 781 | ShowWindow(menu_cancel, SW_SHOW); |
| 782 | MoveWindow(menu_cancel, pt_cancel.x, pt_cancel.y, sz_cancel.cx, |
| 783 | sz_cancel.cy, TRUE); |
| 784 | } else { |
| 785 | sz_cancel.cx = sz_cancel.cy = 0; |
| 786 | pt_cancel.x = pt_cancel.y = 0; |
| 787 | ShowWindow(menu_cancel, SW_HIDE); |
| 788 | } |
| 789 | |
| 790 | // main menu control |
| 791 | pt_elem.x = clrt.left + MENU_MARGIN; |
| 792 | pt_elem.y = clrt.top + MENU_MARGIN; |
no test coverage detected