为了描述这个问题,您最好使用以下用例测试我的应用程序:
应用程序:http ://ubuntuone.com/p/nF/
- 打开应用程序;
- 单击“>”标题按钮;
- 再次单击相同的按钮;
- 再次单击相同的按钮。
如您所见 - 在第一次扩展中正确检测到 URL,但在任何进一步扩展中都没有。
希望在您的帮助下解决此问题:)
目前,每次展开对话框时我都会发送 WM,但它仍然无法正常工作......
展开/折叠按钮代码片段:
if (PreviewOpn.Caption = '<') and (Width >= 499) then // if form is expanded
begin
PreviewOpn.Caption := '>';
if CheckWin32Version(6,0) then begin
Constraints.MinWidth := 252; ClientWidth := Round(252 - ((Width - ClientWidth) / 2));
end else begin
Constraints.MinWidth := 248; ClientWidth := Round(248 - ((Width - ClientWidth) / 2));
end;
PopupActionBar1.Items[1].Enabled := False; PopupActionBar1.Items[1].Checked := False;
if (PreviewOpn.Caption = '<') and (Width >= 248) then PreviewOpn.Caption := '>';
end else // else if form is collapsed
begin
SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, EM_GETEVENTMASK or ENM_LINK); //|
SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, Integer(True), 0);
PreviewOpn.Caption := '<';
if CheckWin32Version(6,0) then begin
Constraints.MinWidth := 252; ClientWidth := Round(510 - ((Width - ClientWidth) / 2));
end else begin
Constraints.MinWidth := 248; ClientWidth := Round(499 - ((Width - ClientWidth) / 2));
end;
PopupActionBar1.Items[1].Enabled := True; PopupActionBar1.Items[1].Checked := True;
if (PreviewOpn.Caption = '>') and (Width >= 499) then PreviewOpn.Caption := '<';
if (FileExists(Edit1.Text)) or (FileExists(Edit2.Text)) or (FileExists(ParamStr(1)))
then RAWInputBtnClick(TabSet1);
end;
vClick(VKPInputBtn); // calls PopuMenu items enabling triggers
for n := 0 to RichEdit1.Lines.Count - 1 do if RichEdit1.Width < Canvas.TextWidth(RichEdit1.Lines[n]) then // enable automatic scroolbar settup
RichEdit1.ScrollBars := ssBoth;
在表单 OnCreate 事件中:
SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, EM_GETEVENTMASK or ENM_LINK); //|
SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, Integer(True), 0); //|
RichEdit1.Lines[5] := RichEdit1.Lines[5] + ' '; //| resend message for line to fix update issue
正如http://msdn.microsoft.com/en-us/library/bb787991%28VS.85%29.aspx文档所述,通过文本修改检测 URL,这意味着重新调用检测的唯一方法是发送某种消息添加/删除字符,但是:
按下键盘上的键后立即检测到 URL,并且只检测到 INSIDE 行。可能的修复将非常讨厌,因此我什至不认为为此开发代码 sinpp :) 想法:通过所有可用字符 Lopp,例如,添加 Char(#10) 然后删除 Char(#10)。缺点:想象一下 RichEdit 控件内的大型 RTF 文本会发生什么...