ReactOS  0.4.15-dev-321-g2d9b385
CEditCompatModes.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Compatibility Layer Shell Extension
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: CEditCompatModes implementation
5  * COPYRIGHT: Copyright 2015-2019 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 #include <windowsx.h>
10 
11 
12 class CEditCompatModes : public CDialogImpl<CEditCompatModes>
13 {
14 private:
18 
19  CStringW GetListText(HWND ListBox, int Cur)
20  {
21  CStringW Str;
22  int Length = ListBox_GetTextLen(ListBox, Cur);
23  LPWSTR Buffer = Str.GetBuffer(Length + 1);
24  ListBox_GetText(ListBox, Cur, Buffer);
25  Str.ReleaseBuffer(Length);
26  return Str;
27  }
28 
29 public:
31  : m_pPage(page)
32  {
33  m_pPage->AddRef();
34  }
35 
37  {
38  m_pPage->Release();
39  }
40 
42  {
44 
47 
49 
50  while (TRUE)
51  {
53  HRESULT hr = pList.Next(1, &str, NULL);
54  if (hr != S_OK)
55  break;
57  }
58 
59  for (int n = 0; n < m_pPage->m_CustomLayers.GetSize(); ++n)
60  {
61  const WCHAR* Str = m_pPage->m_CustomLayers[n].GetString();
63  if (Index == LB_ERR)
65  }
66 
67  OnListboxUpdated(0, 0, 0, bHandled);
68  return 0;
69  }
70 
71  LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
72  {
73  if (wID == IDOK)
74  {
76  m_pPage->m_CustomLayers.RemoveAll();
77  for (int Cur = 0; Cur < Count; ++Cur)
78  {
79  CString Str = GetListText(m_hListActive, Cur);
80  m_pPage->m_CustomLayers.Add(Str);
81  }
82  }
83  EndDialog(wID);
84  return 0;
85  }
86 
87  LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
88  {
89  int Sel = ListBox_GetCurSel(m_hListAdd);
90  CStringW Str = GetListText(m_hListAdd, Sel);
91 
93  if (Index == LB_ERR)
95 
97  return 0;
98  }
99 
100  LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
101  {
102  int Sel = ListBox_GetCurSel(m_hListActive);
103  CStringW Str = GetListText(m_hListActive, Sel);
104 
106  int Index = ListBox_FindStringExact(m_hListAdd, -1, Str);
107  if (Index != LB_ERR)
109  OnListboxUpdated(wNotifyCode, wID, hWndCtl, bHandled);
110  return 0;
111  }
112 
113  LRESULT OnRemoveAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
114  {
116  OnListboxUpdated(wNotifyCode, wID, hWndCtl, bHandled);
117  return 0;
118  }
119 
120  LRESULT OnListboxUpdated(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
121  {
122  if (m_hListAdd == hWndCtl)
124  else if (m_hListActive == hWndCtl)
126 
130  bHandled = TRUE;
131  return 0;
132  }
133 
134 public:
136 
142 
147  END_MSG_MAP()
148 };
149 
150 
152 {
153  CEditCompatModes modes(page);
154  INT_PTR Result = modes.DoModal(hWnd);
155  return Result == IDOK;
156 }
157 
158 
#define TRUE
Definition: types.h:120
HWND SetFocus()
Definition: atlwin.h:1130
#define IDOK
Definition: winuser.h:824
#define ListBox_GetCurSel(hwndCtl)
Definition: windowsx.h:456
BOOL EndDialog(_In_ int nRetCode)
Definition: atlwin.h:1450
#define IDC_REMOVEALL
Definition: resource.h:17
HRESULT hr
Definition: shlfolder.c:183
#define IDC_REMOVE
Definition: resource.h:18
CSimpleArray< CString > m_CustomLayers
#define ListBox_DeleteString(hwndCtl, index)
Definition: windowsx.h:448
BOOL EnableWindow(BOOL bEnable=TRUE)
Definition: atlwin.h:489
#define ListBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:453
HWND hWnd
Definition: settings.c:17
#define IDC_NEWCOMPATIBILITYMODE
Definition: resource.h:15
GLdouble n
Definition: glext.h:7729
#define ListBox_ResetContent(hwndCtl)
Definition: windowsx.h:469
#define ListBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:447
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:63
#define ListBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:475
WPARAM wParam
Definition: combotst.c:138
LRESULT OnListboxUpdated(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define IDD_EDITCOMPATIBILITYMODES
Definition: resource.h:4
#define LB_ERR
Definition: winuser.h:2407
unsigned int BOOL
Definition: ntddk_ex.h:94
LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
ULONG Release()
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
Definition: module.h:566
#define IDC_ADD
Definition: resource.h:16
#define COMMAND_ID_HANDLER(id, func)
Definition: atlwin.h:1835
Definition: bufpool.h:45
HWND GetDlgItem(int nID)
Definition: atlwin.h:571
CEditCompatModes(CLayerUIPropPage *page)
LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define END_MSG_MAP()
Definition: atlwin.h:1799
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOL CenterWindow(HWND hWndCenter=NULL)
Definition: atlwin.h:309
unsigned short WORD
Definition: ntddk_ex.h:93
#define ListBox_GetText(hwndCtl, index, lpszBuffer)
Definition: windowsx.h:464
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG AddRef()
#define IDC_COMPATIBILITYMODE
Definition: resource.h:8
#define ListBox_GetTextLen(hwndCtl, index)
Definition: windowsx.h:465
CLayerUIPropPage * m_pPage
BOOL ShowEditCompatModes(HWND hWnd, CLayerUIPropPage *page)
#define S_OK
Definition: intsafe.h:59
LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
unsigned int UINT
Definition: ndis.h:50
LRESULT OnRemoveAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1780
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1808
CWindow GetParent() const
Definition: atlwin.h:654
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define ListBox_GetCount(hwndCtl)
Definition: windowsx.h:455
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
INT_PTR DoModal(HWND hWndParent=::GetActiveWindow(), LPARAM dwInitParam=NULL)
Definition: atlwin.h:1435
CStringW GetListText(HWND ListBox, int Cur)