Changeset 835 for trunk/KeyComboDlg.cpp


Ignore:
Timestamp:
1/2/2009 5:35:27 AM (5 years ago)
Author:
lowjoel
Message:

Fixed the Hotkey selection dialog. The old code did not allow a trailing NULL to be returned, preventing the GetLine? call from succeeding. I've now added space for it and added error handling code.

Fixes #130.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/KeyComboDlg.cpp

    r42 r835  
    7272void CKeyComboDlg::OnBnClickedOk() 
    7373{ 
    74     char ch[10];     
    75     m_eKey.GetLine(0,ch,1); 
    76     m_strValue = ch; 
     74    char ch[8];  
     75    memset(ch, 0, sizeof(ch)); 
     76    if (m_eKey.GetLine(0, ch, sizeof(ch))) 
     77    { 
     78        m_strValue = ch[0]; 
     79        m_strValue.MakeUpper(); 
     80    } 
     81 
    7782    OnOK(); 
    7883} 
     
    8287    CDialog::OnActivate(nState, pWndOther, bMinimized); 
    8388    m_eKey.SetFocus(); 
    84     // TODO: Add your message handler code here 
    8589} 
    8690 
     
    9296    // function and call CRichEditCtrl().SetEventMask() 
    9397    // with the ENM_CHANGE flag ORed into the mask. 
    94     char ch[10]; 
    95     m_eKey.GetLine(0,ch,1); 
    96     CString strLine(ch); 
     98 
     99    //Recursion guard 
    97100    static bool busy = false; 
    98101    if (busy) 
     
    100103    busy = true; 
    101104 
     105    char ch[8]; 
     106    memset(ch, 0, sizeof(ch)); 
     107    if (!m_eKey.GetLine(0, ch, sizeof(ch))) 
     108        return; 
     109 
     110    CString strLine(ch); 
     111    strLine.MakeUpper(); 
    102112    if (!strLine.Trim().IsEmpty()) 
    103113    { 
    104114        CString strTmp(m_strRegKey.MakeUpper()); 
    105         strLine.MakeUpper(); 
    106115        if (strTmp.Find(strLine[0]) == -1) { 
    107116            //Invalid selection, clear the entry 
    108             m_eKey.SetWindowText("m"); 
     117            m_eKey.Undo(); 
    109118 
    110119            //TODO: This works only with XP/Vista. What about others? 
Note: See TracChangeset for help on using the changeset viewer.