Hi, I have two problems when importing html, images all show as a box with a cross through, and when clicking on links my code gets the text of the link but can't get the actual url... No doubt I'm doing something stupid.
the images in html look something like this:
<img src="http://g-images.amazon.com/images/G/01/ ... ange-arrow" width=10 height=9>
The code I use when a 'link' is clicked is below, it shows the
link 'text' e.g. 'click here' for all 3 message boxes, and never shows
the 'aref' text itself.
Thanks in advance for guidance, I'm sure I"m doing something exceedingly dumb.
void __fastcall TMessageWindow::rvJump(TObject *Sender, int id)
{
TCustomRVFormattedData* RVData;
int ItemNo;
int atag;
AnsiString atxt;
rv->GetJumpPointLocation(id, RVData, ItemNo);
AnsiString url;
RVData->GetTextInfo(ItemNo,atxt,atag);
url = RVData->GetItemTextA(ItemNo);
MainMessageBox(url.c_str(),"Jump","OK","","","","");
MainMessageBox(atxt.c_str(),"Jump2","OK","","","","");
url = RVData->GetItemText(ItemNo);
MainMessageBox(url.c_str(),"Jump3","OK","","","","");
ShellExecute(0, "open", url.c_str(), NULL, NULL, SW_SHOW);
}
Importing html images and links
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1) By default, only local images can be loaded. To load remote images, you need to download them. Do you use RichViewActions?
In any case, as far as I remember, all trichview code for downloading remote images on HTML import (both in demo and in RichViewActions) requires correct file extension for image, .gif in this case.
2) Hyperlink targets are stored in tags.
RVData->GetTextInfo(ItemNo,atxt,atag);
url = (char*)atag;
The code above will work if the hyperlink is a text item, because GetTextInfo can be called only for text items.
An universal code will be:
url = (char*)(RVData->GetItemTag(ItemNo));
In any case, as far as I remember, all trichview code for downloading remote images on HTML import (both in demo and in RichViewActions) requires correct file extension for image, .gif in this case.
2) Hyperlink targets are stored in tags.
RVData->GetTextInfo(ItemNo,atxt,atag);
url = (char*)atag;
The code above will work if the hyperlink is a text item, because GetTextInfo can be called only for text items.
An universal code will be:
url = (char*)(RVData->GetItemTag(ItemNo));
hyperlinks and images.
[quote="Sergey Tkachenko"]1) By default, only local images can be>loaded. To load remote images, you need to download them. Do you use RichViewActions?
Cool, that makes sense, can you tell me which htmlimporter event to use to fetch the remote file and replace it with a local one ? Or must I pre-parse the html before converting it ? Or do I use richviewactions for this ?
re: hyperlinks:
Lets assume my html has:
<a href="http://xyz.com">Press me</a>
The call GetTextInfo gets me "Press me" and the GetItemTag call
gets me a blank string. I want "http://xyz.com"? Any ideas?
Thanks.
Cool, that makes sense, can you tell me which htmlimporter event to use to fetch the remote file and replace it with a local one ? Or must I pre-parse the html before converting it ? Or do I use richviewactions for this ?
re: hyperlinks:
Lets assume my html has:
<a href="http://xyz.com">Press me</a>
The call GetTextInfo gets me "Press me" and the GetItemTag call
gets me a blank string. I want "http://xyz.com"? Any ideas?
Thanks.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
There are two events where you can download images
1) RvHtmlImporter.OnImageRequired2
2) RichView.OnImportPicture
OnImportPicture is better because it also works when importing RTF files.
If you use RichViewActions, they can process OnImportPicture automatically. Open RichViewActions.inc, remove dot from {.$DEFINE USEINDY}, recompile RichViewActions packages (if they are already installed). Then place TIdHTTP component on form and assign it to IdHTTP property of TRVAControlPanel component.
If you do not use RichViewActions, here is a demo:
http://www.trichview.com/resources/html/rvhtml_indy.zip
It uses RvHtmlImporter1.OImageRequired2 event, but can be easily modified to use RichView1.OnImportPicture (the only difference - it's not necessary to add BasePath to the parameter of OnImportPicture)
1) RvHtmlImporter.OnImageRequired2
2) RichView.OnImportPicture
OnImportPicture is better because it also works when importing RTF files.
If you use RichViewActions, they can process OnImportPicture automatically. Open RichViewActions.inc, remove dot from {.$DEFINE USEINDY}, recompile RichViewActions packages (if they are already installed). Then place TIdHTTP component on form and assign it to IdHTTP property of TRVAControlPanel component.
If you do not use RichViewActions, here is a demo:
http://www.trichview.com/resources/html/rvhtml_indy.zip
It uses RvHtmlImporter1.OImageRequired2 event, but can be easily modified to use RichView1.OnImportPicture (the only difference - it's not necessary to add BasePath to the parameter of OnImportPicture)
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I have tried to compile and run the demo above.
When I paste from webbrowser which contains png image, I can not see
the image shown in the TRichViewEdit correctly(I mean, I can not see the
image), but for another image format like jpg can be shown correctly.
What I have to do to achieve it.
thank in advance.
When I paste from webbrowser which contains png image, I can not see
the image shown in the TRichViewEdit correctly(I mean, I can not see the
image), but for another image format like jpg can be shown correctly.
What I have to do to achieve it.
thank in advance.