首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

组件事件重写有关问题

2012-03-18 
组件事件重写问题代码如下class PACKAGE TeEdit : public TEdit{private:protected:void __fastcall OnKey

组件事件重写问题
代码如下
class PACKAGE TeEdit : public TEdit
{
private:
protected:
  void __fastcall OnKeyPress(System::TObject* Sender, char &Key);
}
void __fastcall TeEdit::OnKeyPress(System::TObject* Sender, char &Key)
{
  TEdit::OnKeyPress(Sender,Key);

  AnsiString m_strDelayTime = this->Text;
  double m_nMaxDelayTime = 1000;
  switch(Key)
  {
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
  break;
  case 8:
  break;
  case '-':
  if(m_strDelayTime.IsEmpty())
  break;
  else
  {
  Key = 0;
  break;
  }
  case '.':
  if(m_strDelayTime.IsEmpty() || Findstr(this->Text))
  Key = 0;
  break;
  case 13:
  if(this->Text.ToDouble() > m_nMaxDelayTime)
  this->Text = "1000.000";
  else
  {
  this->Text = FormatFloat("0.000",this->Text.ToDouble() + 0.00005);
  }
  break;
  default:
  Key = 0;
  break;
  }
}


结果是组件DIY的控件根本不走OnKeyPress(System::TObject* Sender, char &Key),请问WHY

[解决办法]
没用过,帮顶

热点排行