1 // ComboDialog.cpp
2 
3 #include "StdAfx.h"
4 #include "ComboDialog.h"
5 
6 #include "../../../Windows/Control/Static.h"
7 
8 #ifdef LANG
9 #include "LangUtils.h"
10 #endif
11 
12 using namespace NWindows;
13 
OnInit()14 bool CComboDialog::OnInit()
15 {
16   #ifdef LANG
17   LangSetDlgItems(*this, NULL, 0);
18   #endif
19   _comboBox.Attach(GetItem(IDC_COMBO));
20 
21   /*
22   // why it doesn't work ?
23   DWORD style = _comboBox.GetStyle();
24   if (Sorted)
25     style |= CBS_SORT;
26   else
27     style &= ~CBS_SORT;
28   _comboBox.SetStyle(style);
29   */
30   SetText(Title);
31 
32   NControl::CStatic staticContol;
33   staticContol.Attach(GetItem(IDT_COMBO));
34   staticContol.SetText(Static);
35   _comboBox.SetText(Value);
36   FOR_VECTOR (i, Strings)
37     _comboBox.AddString(Strings[i]);
38   NormalizeSize();
39   return CModalDialog::OnInit();
40 }
41 
OnSize(WPARAM,int xSize,int ySize)42 bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
43 {
44   int mx, my;
45   GetMargins(8, mx, my);
46   int bx1, bx2, by;
47   GetItemSizes(IDCANCEL, bx1, by);
48   GetItemSizes(IDOK, bx2, by);
49   int y = ySize - my - by;
50   int x = xSize - mx - bx1;
51 
52   InvalidateRect(NULL);
53 
54   MoveItem(IDCANCEL, x, y, bx1, by);
55   MoveItem(IDOK, x - mx - bx2, y, bx2, by);
56   ChangeSubWindowSizeX(_comboBox, xSize - mx * 2);
57   return false;
58 }
59 
OnOK()60 void CComboDialog::OnOK()
61 {
62   _comboBox.GetText(Value);
63   CModalDialog::OnOK();
64 }
65