I wish that when the user clicks the button, ONLY TEXT THAT CONTAINS AN URL (beginning with http://) on the Clipboard is automatically pasted into the TEdit.
I've tried the following code but doesn't work at all.
#include <Clipbrd.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String Text = "http://";
if (Clipboard()->HasFormat(CF_TEXT))
{
Edit->Text = ContainsText(Clipboard()->AsText, Text);
// Clipboard()->Clear();
}
}
ContainsText()returns aboolindicating whether the subtext was found or not. You are assigning that result directly to yourTEditinstead of using it to make a decision whether or not to assign the clipboard text to theTEdit.Try this instead:
BTW,
http://is not the only URL scheme widely used. At a minimum, consider also looking forhttps://as well.