How to get the text in TChromiumDevTools [duplicate] - delphi

This question already has answers here:
Get HTML Source from Chromium Embedded
(2 answers)
Delphi Chromium - Iterate DOM
(1 answer)
Closed 4 years ago.
For some reasons, I need to get the text inside ChromiumDevTools.Is that even possible?. I just need the text in the elements tab.
memo1.Text := idHttp.Get(url); // doesn't get the job done 100%, that is why I need the text inside the ChromiumDevTools

Related

Delphi Copyfile fail on long filename (over MAX_PATH) [duplicate]

This question already has answers here:
How to create directories in windows with path length greater than 256
(4 answers)
Closed 5 years ago.
i have a source file to copy in a target position:
aSource := 'C:\very_very_very_long_path\myfile.exe'; // over 260 chars
aTarget := 'C:\normal_path\myfile.exe';
if not(CopyFile(PChar(aSource), PChar(aTarget), false)) then
RaiseLastOSError;
this code raise exception with code 3 - which means ERROR_PATH_NOT_FOUND.
the target and source paths exists and if i rename the source to a less long name, it works.
How can i copy a file with long path (over MAX_PATH)?
Delphi should follow the Window convention of allowing long file names when supplied with the prefix \\?\. For example, convert "D:\very long path" to "\\?\D:\very long path".
This prefix is only applicable when using the Unicode version of the API, CopyFileW in this case. If you are using Delphi 2009 or later, then CopyFile maps to CopyFileW. If you use an earlier version then you will need to explicitly call CopyFileW, and make sure that the string that you pass is UTF-16 encoded.
A String literal only can be 255 Chars long. You can do something like this:
aSource := 'Patht 255 Chars'+'Rest of the Path';

Delphi - How to Register File extension for auto-open? [duplicate]

This question already has answers here:
How to associate a program with a file type, but only for the current user?
(2 answers)
Closed 8 years ago.
How can i auto-open a custom extension in my Delphi app ? I'm trying to make application
that loads text files but with a different extension.
Example : Text.DZ | all i want is when i click the file with .DZ Extension it opens my app automatically and loads the text inside into the memo1.lines.text.
I know that i have to register my new custom extension but i have no idea how to do it and
load the text into my app.
Also if you can include a source-code example that would be awesome.
Any help will be much appreciated ! and
Sorry for my newbiness and bad English explanation but i hope you guys understand me (^-^)/.
There's a way to do it programmatically, although I don't recall how off the cuff.
That said, if you're just wanting to do it for your own personal use, not for a piece of software you'll be distributing to others, then the easiest way is to use Windows Explorer: click the data file you want, then right-click and select Open With -> ... you'll probably need to select the Other... option at the bottom. That will bring up a dialog box that lets you choose your app. There should also be a checkbox somewhere that says something like "Make Default" or "Always Open With This" or something along those lines. Make sure that box is checked. Then click OK a couple of times and you're off to the races.
But you'll also need to set up your app to read the filename from the command line. You use ParamStr and ParamCount for this.
for i := 0 to ParamCount do
ShowMessage('Parameter '+IntToStr(i)+' = '+ParamStr(i));
When you double-click on the data file, it will open your app and pass this filename as ParamStr(1). So when you get it, simply do something like this:
memo1.lines.LoadFromFile( ParamStr(1) );
Use this as a STARTING POINT (it won't compile if you just copy-and-paste!):
procedure TMyForm234:FormCreate( blah blah )
begin
if ParamCount > 0 then
theMemo.Lines.LoadFromFile( ParamStr(1) );
end;

How to iterate line by line through a .docx file using apache POI [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
My object is to read a .docx file and to display the text of that on the view(Webpage).
I am using apache POI to read a .docx file in Grails Application
Please suggest me a way to display the output on view without loosing Blankspaces and LineBreaks.
My .docx document content
This is a .docx document ...
this is second line
this is third line
Result on Groovy console after reading when i am printing :
This is a .docx document ...
this is second line
this is third line
But when i pass the output to view It becomes
This is a .docx document ... this is second line this is third line
.
My code is :
import org.apache.poi.xwpf.usermodel.XWPFDocument
import org.apache.poi.xwpf.extractor.XWPFWordExtractor
...
String str = "E:\\Query.docx"
File docFile = null;
docFile = new File(str);
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
XWPFDocument doc = new XWPFDocument(fis)
XWPFWordExtractor docExtractor = new XWPFWordExtractor(doc)
println docExtractor.getText()
...
if one can suggest me the way to iterate through each line of the document then i can easily get my result.
Please help me i have got stucked.
HTML ignores line breaks. So, while a string like "Hello there\nLine 2\n" renders fine in the console as
Hello There
Line 2
As HTML it'll all show on the same line. You'll need to replace the newline characters with some suitable HTML, eg <br /> or wrapping things in paragraph/div tags.

Address in windows style in Ruby [duplicate]

This question already has answers here:
How to do a safe join pathname in ruby?
(2 answers)
Closed 8 years ago.
In a Ruby learning book I read
" .... The File.join method is simple to use, and it allows you to write the same code to run on both systems rather than choosing between backslashes and forward slashes in your code."
but for example in windowos when I type
File.join( "c:" , "dir2" , "dir3" , "a.txt" ) Ruby returns me "c:/dir2/dir3/a.txt"
Whereas I expect "c:\dir2\dir3\a.txt".
knoW how can I produce an absolute address in windows style ( with backslash ) .
thanks
File.join('c:','dir1', 'dir2').gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)

How to add my icon to component in the component palette page? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
delphi non visual component image
How to add my icon to my created component in the component palette page?
To add icon to component you need to create dcr file using Delphi image editor.
In image editor create bitmap 24x24 16 bit. Rename bitmap to your control name.
Example: TMyCustomControl - TMyCustomControl (same name)
Save dcr file in the folder where the package is with any name (example: Icon.dcr).
Then open your package and right click -> View source.
Add line :
{$R 'The dcr filename'}
In this case:
{$R 'Icon.dcr'}
Click Compile and Install.
There you go. You have created your own component with icon. :)
Create a .dcr file in the Delphi Image Editor.
Add a bitmap to this with the same name as your control. It needs to be 24 pixels square, and use 16 colours.
Link this .dcr, which is really just a resource file, to your package with a $R in your .dpk for example.

Resources