DlgBase.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "DlgBase.h"
  2. void DlgBase::MakeComboEdit(UINT id, DWORD s)
  3. {
  4. HWND w = GetDlgItem(wnd, id);
  5. RECT r;
  6. GetChildRect(id, r);
  7. DestroyWindow(w);
  8. CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", 0, WS_CHILD | s, r.left - 1, r.top - 1, r.right - r.left, r.bottom - r.top, wnd, (HMENU)id, 0, 0);
  9. }
  10. void DlgBase::GetChildRect(UINT id, RECT& child)
  11. {
  12. RECT r_parent, r_child;
  13. GetWindowRect(wnd, &r_parent);
  14. GetWindowRect(GetDlgItem(wnd, id), &r_child);
  15. int dx = r_parent.left;
  16. int dy = r_parent.top;
  17. if (!(GetWindowLong(wnd, GWL_STYLE)&WS_CHILD))
  18. {
  19. dy += GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME);
  20. dx += GetSystemMetrics(SM_CXDLGFRAME);
  21. }
  22. child.left = r_child.left - dx;
  23. child.right = r_child.right - dx;
  24. child.top = r_child.top - dy;
  25. child.bottom = r_child.bottom - dy;
  26. }
  27. void DlgBase::do_sizing(UINT wp, RECT * r)
  28. {
  29. UINT dx, dy;
  30. dx = r->right - r->left;
  31. dy = r->bottom - r->top;
  32. if (dx < min_size_x_w)
  33. {
  34. switch (wp)
  35. {
  36. case WMSZ_BOTTOMLEFT:
  37. case WMSZ_LEFT:
  38. case WMSZ_TOPLEFT:
  39. r->left = r->right - min_size_x_w;
  40. break;
  41. case WMSZ_BOTTOMRIGHT:
  42. case WMSZ_RIGHT:
  43. case WMSZ_TOPRIGHT:
  44. r->right = r->left + min_size_x_w;
  45. break;
  46. }
  47. }
  48. if (dy < min_size_y_w)
  49. {
  50. switch (wp)
  51. {
  52. case WMSZ_BOTTOMLEFT:
  53. case WMSZ_BOTTOM:
  54. case WMSZ_BOTTOMRIGHT:
  55. r->bottom = r->top + min_size_y_w;
  56. break;
  57. case WMSZ_TOPLEFT:
  58. case WMSZ_TOP:
  59. case WMSZ_TOPRIGHT:
  60. r->top = r->bottom - min_size_y_w;
  61. break;
  62. }
  63. }
  64. }