frmMain窗体上有两个Label1,Label2我用鼠标点击一下其中一个Label,在按一下F1弹出窗体frmChild,frmChild的Caption显示所选的Label的Caption
如何做?
我已经没分了!!
大侠们帮帮忙!!

解决方案 »

  1.   

    全局变量:var
    str: string;在Label的Click事件代码中加入:str := (Sender as TLable).Caption;用RegisterHotkey或别的什么方法相应捕捉F1按键, 然后:frmChild.Caption := str;
    frmChild.Show();
      

  2.   

    在frmMain的属性KEYPREVIEW设为TRUE,然后在frmMain的onKeyDown事件里写如下代码:
    if  Key = VK_F1 then
    begin
      ShowChild(Self.CurrCaption);
      Key := 0;
    end;然后自己写一个ShowChild(_Caption:string)
    begin
      with TfrmChild.Create(Self) do
      try
        Caption := _Caption
        ShowModal;
      finally
        free;
      end;
    end;至于选择LABEL,在其中一个的onMouseDown里写
      Self.CurrCaption := TLabel(Sender).Caption