[dasher: 27/61] Fixing bugs reported by Dr. Memoy.



commit b1880e8ff10e69a00c5568783f661dcf06678fe5
Author: Ada Majorek <amajorek google com>
Date:   Thu Jul 14 21:53:29 2016 -0700

    Fixing bugs reported by Dr. Memoy.

 Src/DasherCore/Alphabet/AlphabetMap.cpp |    2 +-
 Src/DasherCore/DasherInterfaceBase.cpp  |    3 +-
 Src/Win32/Widgets/AdvancedPage.cpp      |    7 +-
 Src/Win32/Widgets/AlphabetBox.cpp       |    5 +-
 Src/Win32/Widgets/ControlPage.cpp       |  318 ++++++++++++-------------------
 Src/Win32/Widgets/ControlPage.h         |    2 +
 Src/Win32/Widgets/Prefs.cpp             |   17 +--
 Src/Win32/Widgets/StatusControl.cpp     |    3 +
 Src/Win32/Widgets/ViewPage.cpp          |    7 +-
 9 files changed, 142 insertions(+), 222 deletions(-)
---
diff --git a/Src/DasherCore/Alphabet/AlphabetMap.cpp b/Src/DasherCore/Alphabet/AlphabetMap.cpp
index 6e94f32..b58d937 100644
--- a/Src/DasherCore/Alphabet/AlphabetMap.cpp
+++ b/Src/DasherCore/Alphabet/AlphabetMap.cpp
@@ -205,7 +205,7 @@ CAlphabetMap::CAlphabetMap(unsigned int InitialTableSize)
 }
 
 CAlphabetMap::~CAlphabetMap() {
-  delete m_pSingleChars;
+  delete[] m_pSingleChars;
 }
 
 void CAlphabetMap::AddParagraphSymbol(symbol Value) {
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index d9bb868..3ee192f 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -87,7 +87,8 @@ CDasherInterfaceBase::CDasherInterfaceBase(CSettingsStore *pSettingsStore, CFile
   m_pFramerate(new CFrameRate(this)), 
   m_pSettingsStore(pSettingsStore), 
   m_pLockLabel(NULL),
-  m_preSetObserver(*pSettingsStore){
+  m_preSetObserver(*pSettingsStore),
+  m_bLastMoved(false) {
   
   pSettingsStore->Register(this);
   pSettingsStore->PreSetObservable().Register(&m_preSetObserver);
diff --git a/Src/Win32/Widgets/AdvancedPage.cpp b/Src/Win32/Widgets/AdvancedPage.cpp
index 0b33dcf..a68f042 100644
--- a/Src/Win32/Widgets/AdvancedPage.cpp
+++ b/Src/Win32/Widgets/AdvancedPage.cpp
@@ -133,8 +133,11 @@ bool CAdvancedPage::Apply() {
   HWND ListBox = GetDlgItem(m_hwnd, IDC_CONTROLBOXES);
   LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0);
   LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0);
-  auto CurrentControlBox = m_ControlBoxItems[CurrentIndex];
-  m_pAppSettings->SetStringParameter(SP_CONTROL_BOX_ID, CurrentControlBox);
+  if (CurrentIndex != LB_ERR)
+  {
+         auto CurrentControlBox = m_ControlBoxItems[CurrentIndex];
+         m_pAppSettings->SetStringParameter(SP_CONTROL_BOX_ID, CurrentControlBox);
+  }
 
   int fileEncodingIdx = SendMessage(GetDlgItem(m_hwnd, IDC_FILE_ENCODING), CB_GETCURSEL, 0, 0);
   switch (fileEncodingIdx) {
diff --git a/Src/Win32/Widgets/AlphabetBox.cpp b/Src/Win32/Widgets/AlphabetBox.cpp
index fe6a1a9..9ec37f9 100644
--- a/Src/Win32/Widgets/AlphabetBox.cpp
+++ b/Src/Win32/Widgets/AlphabetBox.cpp
@@ -254,8 +254,9 @@ LRESULT CAlphabetBox::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM l
         HWND ListBox = GetDlgItem(m_hwnd, IDC_ALPHABETS);
         LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0);
         LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0);
-        m_CurrentAlphabet = AlphabetList[CurrentIndex];
- 
+               if (CurrentIndex != LB_ERR)
+                       m_CurrentAlphabet = AlphabetList[CurrentIndex];
+
       }
       return TRUE;
       break;
diff --git a/Src/Win32/Widgets/ControlPage.cpp b/Src/Win32/Widgets/ControlPage.cpp
index bf6da83..11a6b19 100644
--- a/Src/Win32/Widgets/ControlPage.cpp
+++ b/Src/Win32/Widgets/ControlPage.cpp
@@ -52,26 +52,26 @@ void CControlPage::PopulateList() {
 
   SendMessage(SB_slider, TBM_SETPAGESIZE, 0L, 20);      // PgUp and PgDown change bitrate by reasonable 
amount
   SendMessage(SB_slider, TBM_SETTICFREQ, 100, 0L);
-  SendMessage(SB_slider, TBM_SETRANGE, FALSE, (LPARAM) MAKELONG(10, 800));
-  
-  speedbox = GetDlgItem(m_hwnd, IDC_SPEEDVAL);  
+  SendMessage(SB_slider, TBM_SETRANGE, FALSE, (LPARAM)MAKELONG(10, 800));
 
-  SendMessage(SB_slider, TBM_SETPOS, TRUE, (LPARAM) m_pAppSettings->GetLongParameter(LP_MAX_BITRATE));
+  speedbox = GetDlgItem(m_hwnd, IDC_SPEEDVAL);
+
+  SendMessage(SB_slider, TBM_SETPOS, TRUE, (LPARAM)m_pAppSettings->GetLongParameter(LP_MAX_BITRATE));
   _sntprintf(m_tcBuffer, 100, TEXT("%0.2f"), m_pAppSettings->GetLongParameter(LP_MAX_BITRATE) / 100.0);
-  SendMessage(speedbox, WM_SETTEXT, 0, (LPARAM) m_tcBuffer);
+  SendMessage(speedbox, WM_SETTEXT, 0, (LPARAM)m_tcBuffer);
 
   m_hMousePosStyle = GetDlgItem(m_hwnd, IDC_MOUSEPOS_STYLE);
   SendMessage(m_hMousePosStyle, CB_ADDSTRING, 0, (LPARAM)L"Centre circle");
   SendMessage(m_hMousePosStyle, CB_ADDSTRING, 0, (LPARAM)L"Two box");
 
-  if(m_pAppSettings->GetBoolParameter(BP_MOUSEPOS_MODE)) {
+  if (m_pAppSettings->GetBoolParameter(BP_MOUSEPOS_MODE)) {
     SendMessage(m_hMousePosStyle, CB_SETCURSEL, 1, 0);
   }
   else {
     SendMessage(m_hMousePosStyle, CB_SETCURSEL, 0, 0);
   }
 
-  if(m_pAppSettings->GetBoolParameter(BP_MOUSEPOS_MODE) || 
m_pAppSettings->GetBoolParameter(BP_CIRCLE_START)) {
+  if (m_pAppSettings->GetBoolParameter(BP_MOUSEPOS_MODE) || 
m_pAppSettings->GetBoolParameter(BP_CIRCLE_START)) {
     SendMessage(GetDlgItem(m_hwnd, IDC_MOUSEPOS), BM_SETCHECK, BST_CHECKED, 0);
   }
   else {
@@ -79,79 +79,38 @@ void CControlPage::PopulateList() {
   }
 
   // all the button checkboxes
-  for(int ii = 0; ii<sizeof(menutable)/sizeof(menuentry); ii++)
+  for (int ii = 0; ii < sizeof(menutable) / sizeof(menuentry); ii++)
   {
-    if(m_pAppSettings->GetBoolParameter(menutable[ii].paramNum)) 
-       {
+    if (m_pAppSettings->GetBoolParameter(menutable[ii].paramNum))
+    {
       SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_CHECKED, 0);
     }
-    else  
-       {
+    else
+    {
       SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_UNCHECKED, 0);
     }
   }
 
   // List entries:
 
-  for(int i(0); i<sizeof(listtable)/sizeof(menuentry); ++i) {
+  for (int i(0); i < sizeof(listtable) / sizeof(menuentry); ++i) {
     std::vector<std::string> vValues;
     m_pAppSettings->GetPermittedValues(listtable[i].paramNum, vValues);
-
-    for(std::vector<std::string>::iterator it(vValues.begin()); it != vValues.end(); ++it) {
-      Tstring Item;
-      WinUTF8::UTF8string_to_wstring(*it, Item);
-      int iIdx(SendMessage(GetDlgItem(m_hwnd, listtable[i].idcNum), LB_ADDSTRING, 0, (LPARAM) Item.c_str()));
-
-      if(*it == m_pAppSettings->GetStringParameter(listtable[i].paramNum))
-        SendMessage(GetDlgItem(m_hwnd, listtable[i].idcNum), LB_SETCURSEL, iIdx, 0);
+    CWindow lbox = GetDlgItem(m_hwnd, listtable[i].idcNum);
+    auto currentParameterValue = m_pAppSettings->GetStringParameter(listtable[i].paramNum);
+    for (auto value : vValues) {
+      wstring Item;
+      WinUTF8::UTF8string_to_wstring(value, Item);
+      int iIdx = lbox.SendMessage(LB_ADDSTRING, 0, (LPARAM)Item.c_str());
+
+      if (value == currentParameterValue)
+        lbox.SendMessage(LB_SETCURSEL, iIdx, 0);
     }
   }
-
-// TODO: Pretty horrible - sort this out
-  {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETCURSEL, 0, 0));
-    
-        int iLength(SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETTEXTLEN, iSelection, 0));
-        TCHAR *szData(new TCHAR[iLength + 1]);
-        SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETTEXT, iSelection, (LPARAM)szData);
-
-        std::string strNewValue;
-        WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-        delete[] szData;
-
-        SModuleSettings *pSettings;
-        int iSettingsCount;
-
-        EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS), 
m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount));
-      }
-      
-      {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETCURSEL, 0, 0));
-    
-               if(iSelection != LB_ERR) {
-                       int iLength(SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETTEXTLEN, 
iSelection, 0));
-                       TCHAR *szData(new TCHAR[iLength + 1]);
-                       SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETTEXT, iSelection, 
(LPARAM)szData);
-
-                       std::string strNewValue;
-                       WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-                       delete[] szData;
-
-               SModuleSettings *pSettings;
-                       int iSettingsCount;
-
-                       EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS2), 
m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount));
-               }
-               else {
-                       EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS2), false);
-               }
-      }
-      
-
+  EnablePrefferencesForSelectedModule(IDC_CONTROL_LIST, IDC_BUTTON_PREFS);
+  EnablePrefferencesForSelectedModule(IDC_INPUT_LIST, IDC_BUTTON_PREFS2);
 }
-
-
-bool CControlPage::Apply() 
+bool CControlPage::Apply()
 {
   int NewSpeed = SendMessage(SB_slider, TBM_GETPOS, 0, 0);
   m_pAppSettings->SetLongParameter( LP_MAX_BITRATE, NewSpeed);
@@ -181,17 +140,11 @@ bool CControlPage::Apply()
   }
 
   for(int i(0); i < sizeof(listtable)/sizeof(menuentry); ++i) {
-    int iSelection(SendMessage(GetDlgItem(m_hwnd, listtable[i].idcNum), LB_GETCURSEL, 0, 0));
-    
-    int iLength(SendMessage(GetDlgItem(m_hwnd, listtable[i].idcNum), LB_GETTEXTLEN, iSelection, 0));
-    TCHAR *szData(new TCHAR[iLength + 1]);
-    SendMessage(GetDlgItem(m_hwnd, listtable[i].idcNum), LB_GETTEXT, iSelection, (LPARAM)szData);
-
     std::string strNewValue;
-    WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-    delete[] szData;
-
-    m_pAppSettings->SetStringParameter(listtable[i].paramNum, strNewValue);
+       if (GetSelectedListboxText(listtable[i].idcNum, strNewValue))
+       {
+               m_pAppSettings->SetStringParameter(listtable[i].paramNum, strNewValue);
+       }
   }
 
        // Return false (and notify the user) if something is wrong.
@@ -199,128 +152,101 @@ bool CControlPage::Apply()
 }
 
 LRESULT CControlPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) {
-       double NewSpeed;
-       switch (message) 
-       {       
-       case WM_COMMAND:
-               switch (LOWORD(wParam)) 
-               {
-       /*      case (IDC_DISPLAY):
-                       break;*/
-    case IDC_CONTROL_LIST:
-      {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETCURSEL, 0, 0));
-
-        if(iSelection != LB_ERR) {    
-          int iLength(SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETTEXTLEN, iSelection, 0));
-          TCHAR *szData(new TCHAR[iLength + 1]);
-          SendMessage(GetDlgItem(m_hwnd, IDC_CONTROL_LIST), LB_GETTEXT, iSelection, (LPARAM)szData);
-  
-          std::string strNewValue;
-          WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-          delete[] szData;
-  
-          SModuleSettings *pSettings;
-          int iSettingsCount;
-
-          EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS), 
m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount));
-        }
-        else {
-          EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS), false);
-        }
-      }
-      break;
-    case IDC_INPUT_LIST:
-      {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETCURSEL, 0, 0));
-    
-               if(iSelection != LB_ERR) {
-          int iLength(SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETTEXTLEN, iSelection, 0));
-          TCHAR *szData(new TCHAR[iLength + 1]);
-          SendMessage(GetDlgItem(m_hwnd, IDC_INPUT_LIST), LB_GETTEXT, iSelection, (LPARAM)szData);
-
-          std::string strNewValue;
-          WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-          delete[] szData;
-
-          SModuleSettings *pSettings;
-          int iSettingsCount;
-
-          EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS2), 
m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount));
-        }
-        else {
-          EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_PREFS2), false);
-        }
-      }
-      break;
-    case IDC_BUTTON_PREFS: 
-      {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, listtable[0].idcNum), LB_GETCURSEL, 0, 0));
-      
-        if(iSelection != LB_ERR) {
-          int iLength(SendMessage(GetDlgItem(m_hwnd, listtable[0].idcNum), LB_GETTEXTLEN, iSelection, 0));
-          TCHAR *szData(new TCHAR[iLength + 1]);
-          SendMessage(GetDlgItem(m_hwnd, listtable[0].idcNum), LB_GETTEXT, iSelection, (LPARAM)szData);
-
-          std::string strNewValue;
-          WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-          delete[] szData;
-
-          SModuleSettings *pSettings;
-          int iSettingsCount;
-
-          if(!m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount))
-            break;
-
-          CModuleSettings dlg(strNewValue, pSettings, iSettingsCount, m_pAppSettings);
-          dlg.DoModal(m_hwnd);
-        }
-      }
-                 break;
-    case IDC_BUTTON_PREFS2: 
-      {
-        int iSelection(SendMessage(GetDlgItem(m_hwnd, listtable[1].idcNum), LB_GETCURSEL, 0, 0));
-    
-        if(iSelection != LB_ERR) {
-          int iLength(SendMessage(GetDlgItem(m_hwnd, listtable[1].idcNum), LB_GETTEXTLEN, iSelection, 0));
-          TCHAR *szData(new TCHAR[iLength + 1]);
-          SendMessage(GetDlgItem(m_hwnd, listtable[1].idcNum), LB_GETTEXT, iSelection, (LPARAM)szData);
-
-          std::string strNewValue;
-          WinUTF8::wstring_to_UTF8string(szData, strNewValue);
-          delete[] szData;
-
-          SModuleSettings *pSettings;
-          int iSettingsCount;
-
-          if(!m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount))
-            break;
-
-          CModuleSettings dlg(strNewValue, pSettings, iSettingsCount, m_pAppSettings);
-          dlg.DoModal(m_hwnd);
-        }
-      }
-                 break;
-               }
+  double NewSpeed;
+  switch (message)
+  {
+  case WM_COMMAND:
+       switch (LOWORD(wParam))
+       {
+       case IDC_CONTROL_LIST:
+         EnablePrefferencesForSelectedModule(IDC_CONTROL_LIST, IDC_BUTTON_PREFS);
+         break;
+       case IDC_INPUT_LIST:
+         EnablePrefferencesForSelectedModule(IDC_INPUT_LIST, IDC_BUTTON_PREFS2);
+         break;
+       case IDC_BUTTON_PREFS:
+       {
+         std::string strNewValue;
+         if (GetSelectedListboxText(IDC_CONTROL_LIST, strNewValue))
                break;
-       case WM_HSCROLL:
-               if((LOWORD(wParam) == SB_THUMBPOSITION) | (LOWORD(wParam) == SB_THUMBTRACK)) {
-                       // Some messages give the new postion
-                       NewSpeed = HIWORD(wParam);
-               }
-               else {
-                       // Otherwise we have to ask for it
-                       long Pos = SendMessage(SB_slider, TBM_GETPOS, 0, 0);
-                       NewSpeed = Pos;
-               }
-               {
-                       _sntprintf(m_tcBuffer, 100, TEXT("%0.2f"), NewSpeed / 100);
-                       SendMessage(speedbox, WM_SETTEXT, 0, (LPARAM) m_tcBuffer);
-               }
-               return TRUE;
+
+         SModuleSettings *pSettings = 0;
+         int iSettingsCount = 0;
+         if (!m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount))
                break;
 
-        }
-        // pass on to superclass:
+         CModuleSettings dlg(strNewValue, pSettings, iSettingsCount, m_pAppSettings);
+         dlg.DoModal(m_hwnd);
+       }
+       break;
+       case IDC_BUTTON_PREFS2:
+       {
+         std::string strNewValue;
+         if (GetSelectedListboxText(IDC_INPUT_LIST, strNewValue))
+               break;
+
+         SModuleSettings *pSettings = 0;
+         int iSettingsCount = 0;
+         if (!m_pDasherInterface->GetModuleSettings(strNewValue, &pSettings, &iSettingsCount))
+               break;
+
+         CModuleSettings dlg(strNewValue, pSettings, iSettingsCount, m_pAppSettings);
+         dlg.DoModal(m_hwnd);
+       }
+       break;
+       }
+       break;
+  case WM_HSCROLL:
+       if ((LOWORD(wParam) == SB_THUMBPOSITION) | (LOWORD(wParam) == SB_THUMBTRACK)) {
+         // Some messages give the new postion
+         NewSpeed = HIWORD(wParam);
+       }
+       else {
+         // Otherwise we have to ask for it
+         long Pos = SendMessage(SB_slider, TBM_GETPOS, 0, 0);
+         NewSpeed = Pos;
+       }
+       {
+         _sntprintf(m_tcBuffer, 100, TEXT("%0.2f"), NewSpeed / 100);
+         SendMessage(speedbox, WM_SETTEXT, 0, (LPARAM)m_tcBuffer);
+       }
+       return TRUE;
+       break;
+
+  }
+  // pass on to superclass:
   return CPrefsPageBase::WndProc(Window, message, wParam, lParam);
 }
+
+bool CControlPage::GetSelectedListboxText(int lboxId, string& selectedText)
+{
+  CWindow lbox = GetDlgItem(m_hwnd, lboxId);
+  int iSelection = lbox.SendMessage(LB_GETCURSEL, 0, 0);
+  if (iSelection == LB_ERR)
+       return false;
+
+  int iLength = lbox.SendMessage(LB_GETTEXTLEN, iSelection, 0);
+  if (iLength == LB_ERR)
+       return false;
+
+  TCHAR* szData = new TCHAR[iLength + 1];
+  int iLen2 = lbox.SendMessage(LB_GETTEXT, iSelection, (LPARAM)szData);
+  if (iLen2 == LB_ERR) {
+       delete[] szData;
+       return false;
+  }
+  WinUTF8::wstring_to_UTF8string(szData, selectedText);
+  delete[] szData;
+  return true;
+
+}
+
+void CControlPage::EnablePrefferencesForSelectedModule(int lboxId, int btnId)
+{
+  std::string strValue;
+  GetSelectedListboxText(lboxId, strValue);
+  SModuleSettings *pSettings = 0;
+  int iSettingsCount = 0;
+  EnableWindow(GetDlgItem(m_hwnd, btnId),
+       m_pDasherInterface->GetModuleSettings(strValue, &pSettings, &iSettingsCount));
+}
diff --git a/Src/Win32/Widgets/ControlPage.h b/Src/Win32/Widgets/ControlPage.h
index 82c0953..d31ebee 100644
--- a/Src/Win32/Widgets/ControlPage.h
+++ b/Src/Win32/Widgets/ControlPage.h
@@ -33,6 +33,8 @@ private:
   
   void PopulateList();
   bool Apply();
+  bool GetSelectedListboxText(int lbxId, std::string & selectedText);
+  void EnablePrefferencesForSelectedModule(int lboxId, int btnId);
 };
 
 #endif  // ndef
diff --git a/Src/Win32/Widgets/Prefs.cpp b/Src/Win32/Widgets/Prefs.cpp
index 2498379..055eae9 100644
--- a/Src/Win32/Widgets/Prefs.cpp
+++ b/Src/Win32/Widgets/Prefs.cpp
@@ -111,22 +111,7 @@ LRESULT CPrefs::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam)
       m_hwnd = Window;
     }
     return TRUE;
-  //case WM_COMMAND:
-  //  switch (LOWORD(wParam)) {
-  //  case (IDC_DISPLAY):
-  //    if(HIWORD(wParam) == EN_CHANGE) {
-  //      HWND Control = GetDlgItem(Window, IDC_DISPLAY);
-  //      LRESULT BufferLength = SendMessage(Control, WM_GETTEXTLENGTH, 0, 0) + 1;        // +1 to allow for 
terminator
-  //      TCHAR *Buffer = new TCHAR[BufferLength];
-  //      SendMessage(Control, WM_GETTEXT, BufferLength, (LPARAM) Buffer);
-  //      string ItemName;
-  //      SendMessage(GetDlgItem(Window, IDC_TEXT), WM_SETTEXT, 0, (LPARAM) Buffer);
-  //      delete[]Buffer;
-  //    }
-  //    return TRUE;
-  //  default:
-  //    return FALSE;
-  //  }
+
   default:
     return FALSE;
   }
diff --git a/Src/Win32/Widgets/StatusControl.cpp b/Src/Win32/Widgets/StatusControl.cpp
index 9f55680..2d510da 100644
--- a/Src/Win32/Widgets/StatusControl.cpp
+++ b/Src/Win32/Widgets/StatusControl.cpp
@@ -6,6 +6,9 @@
 
 CStatusControl::CStatusControl(Dasher::CSettingsUser *pCreateFrom, CAppSettings *pAppSettings) 
        : CSettingsObserver(pCreateFrom), m_pAppSettings(pAppSettings) {
+  m_hEdit = m_hUpDown = m_hCombo = m_hSpeedLabel = m_hAlphabetLabel =0;
+
+  m_iEditWidth = m_iEditHeight = 0;
 }
 
 void CStatusControl::HandleEvent(int iParameter) {
diff --git a/Src/Win32/Widgets/ViewPage.cpp b/Src/Win32/Widgets/ViewPage.cpp
index 7850c54..ec3a677 100644
--- a/Src/Win32/Widgets/ViewPage.cpp
+++ b/Src/Win32/Widgets/ViewPage.cpp
@@ -156,8 +156,6 @@ LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lPar
     if(HIWORD(wParam)==BN_CLICKED || HIWORD(wParam)==LBN_SELCHANGE) {
       if(LOWORD(wParam) != 0 && m_hPropertySheet != 0 && m_hwnd != 0) {
         PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button
-        // Behaviour isn't *perfect* since it activates the Apply button even if you, say,
-        // click 'new' alphabet then click Cancel when asked for a name.
       }
     }
     switch (LOWORD(wParam)) {
@@ -166,8 +164,9 @@ LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lPar
         HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS);
         LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0);
         LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0);
-        m_CurrentColours = ColourList[CurrentIndex];
-      }
+               if (CurrentIndex != LB_ERR)
+                       m_CurrentColours = ColourList[CurrentIndex];
+         }
       return TRUE;
  
   case IDC_DFONT_BUTTON:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]