StateBtnGroup.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "stdafx.h"
  2. #include "StateBtnGroup.h"
  3. IMPLEMENT_DYNAMIC(CStateBtnGroup, CWnd)
  4. CStateBtnGroup::CStateBtnGroup(void)
  5. {
  6. CButtonGroup();
  7. }
  8. CStateBtnGroup::~CStateBtnGroup(void)
  9. {
  10. for (size_t i = 0; i < pButtons.size(); i++)
  11. {
  12. delete(pButtons[i]);
  13. pButtons[i] = NULL;
  14. }
  15. }
  16. void CStateBtnGroup::addButton(CString name, UINT nID)
  17. {
  18. CStateButton* pBtn = new CStateButton;
  19. pButtons.push_back(pBtn);
  20. CString str;
  21. str.Format("%d", pButtons.size());
  22. pBtn->Create("a", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, getCurRect(pButtons.size() - 1), pParent, nID);
  23. pBtn->name = name;
  24. pBtn->index = pButtons.size() - 1;
  25. pBtn->type = type;
  26. pBtn->pParent = this;
  27. row = pButtons.size() / maxColumn + 1;
  28. if (pButtons.size() % maxColumn == 0)
  29. {
  30. row -= 1;
  31. }
  32. column = maxColumn;
  33. }
  34. void CStateBtnGroup::changeButtonInfo(UINT index, CString name, CString amount, CString vol, CString price,UINT state)
  35. {
  36. if (pButtons[index]->name == name
  37. && pButtons[index]->amount == amount
  38. && pButtons[index]->vol == vol
  39. && pButtons[index]->price == price
  40. && pButtons[index]->state == state)
  41. {
  42. return;
  43. }
  44. pButtons[index]->name = name;
  45. pButtons[index]->amount = amount;
  46. pButtons[index]->vol = vol;
  47. pButtons[index]->price = price;
  48. pButtons[index]->state = state;
  49. ::SendMessage(pButtons[index]->m_hWnd, WM_PAINT, (LPARAM)0, (WPARAM)0);
  50. }