MyComboBox.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // MyComboBox.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "MyComboBox.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMyComboBox
  28. CMyComboBox::CMyComboBox()
  29. {
  30. }
  31. CMyComboBox::~CMyComboBox()
  32. {
  33. }
  34. BEGIN_MESSAGE_MAP(CMyComboBox, CComboBox)
  35. //{{AFX_MSG_MAP(CMyComboBox)
  36. ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // Behandlungsroutinen für Nachrichten CMyComboBox
  41. /*
  42. This will automatically send a CBN_EDITCHANGE command.
  43. Also it will set the window text to the selected item
  44. */
  45. void CMyComboBox::OnSelchange()
  46. {
  47. CString SelectedItem;
  48. GetLBText(GetCurSel(),SelectedItem);
  49. SetWindowText(SelectedItem);
  50. WPARAM wparam;
  51. int ctrlid=GetDlgCtrlID();
  52. WORD command=CBN_EDITCHANGE;
  53. memcpy((BYTE*)&wparam+2, &command, 2);
  54. memcpy((BYTE*)&wparam, &ctrlid, 2);
  55. GetOwner()->SendMessage(WM_COMMAND,wparam,(LPARAM)m_hWnd);
  56. }