Solved

Using THTML component

Posted on 1997-08-30
9
169 Views
Last Modified: 2010-04-06
The fist version of my training software had got a simple hypertext system I had programming myself. In this hypertext, a right-click on a word was causing the apearance of a popup window with the translation of the word under the mouse cursor.
In the second version of the software, I've replaced my hypertext by Dave Baldwin's THTML which offers a lot of advantages and allows very good presentation on the screen. Yet, in HTML Viewer, I dont manage to offer the same  function "right-click=translation".
How can I allow it in THTML Viewer component ?
0
Comment
Question by:jpdupont
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1343069
Can you send me the THTML?
0
 

Author Comment

by:jpdupont
ID: 1343070
Yes
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1343071
I receive sorce but without INC and DLL but no problem because i saw so this is't free component.
I try help you but i now try understand how it works. When i finished then mayby i can give you answer.
Sorry for my english.
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 3

Expert Comment

by:mirek071497
ID: 1343072
Very fine component!

I probably don't understand you'r question.
What you mean when you write
"right-click=translation".

This component have virtual procedure URLAction;
I think so you must ovveride this proc.
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1343073
Of course MouseUp and MouseDown you must override too.
0
 

Author Comment

by:jpdupont
ID: 1343074
Right-click=translation
means that when you click with the
right-button of the mouse you must get the word under the mouse cursor,
then find his translation in a lexicon
causing the apearance of a popup window with the translation of the word.

All word of the hypertext have to be translated (in a database). This is an educational software of languages (e.g. german with
all words translated in english or french).
Some word are also used as links to others pages or actions.
Dave Baldwin suggest to me that I should find a solution from his
"SelText".
If "SelText" allow to select a word with the mouse (and therefore to search it in the lexicon) is there any way, by programming - modifying the sources
- to automatically select the word under the cursor, rather than select it pixel by pixel dragging the mouse ?

Regards

Jean-Pol

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1343075
Yes, but i spend some time with this. Wait to tomorrow. I mail to You new HtmlView.Pas but as i write later i can't test this fully so you will need remove some smal mistakes.

0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 120 total points
ID: 1343076
Here is the new THtmlViewer2 component.
I made this very simple but i think so you can improve this.
This component select word under cursor after right-click and you can read this at you'r code :

procedure TForm1.HTMLViewer1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
     if (Button = mbRight) then
       ShowMessage( HTMLViewer21.SelText );
end;


unit NewHTML;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Htmlview;

type
  THtmlViewer2 = class(THTMLViewer)
  private {}
  protected
    procedure HTMLMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer); override;
  public {}
  published {}
  end;

procedure Register;

implementation

Type
  MyPanel = class( TPaintPanel ) { this is only for acces to canvas at PaintPanel }
  end;

procedure Register;
begin
  RegisterComponents('Samples', [THtmlViewer2]);
end;

procedure THtmlViewer2.HTMLMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
var
  XR, CaretHt: integer;
  YR: LongInt;
  Cell1: TObject;
  WasFocused: boolean;
  Found : boolean;
  ReadBuff : array[0..40] of char;
  BegSel, i : longint;
begin
  WasFocused := Focused;
  SetFocus;
  if (Button = mbRight) and WasFocused then
  with SectionList do
  begin
    Sel1 := FindCursor( MyPanel(PaintPanel).Canvas, X, Y+YOff, XR, YR, CaretHt, Cell1);
    if Sel1 > -1 then
      begin
      SelB := Sel1-1;
      SelE := SelB+1;
      Found := false;
      while (SelB>=0) and (not Found) do
      begin
        GetSelTextBuf( ReadBuff, 2 );
        if ReadBuff[0] in ['A'..'Z', 'a'..'z' ] then
          begin
            Dec(SelB);
            SelE := SelB+1;
          end
        else
          found := true;
      end;
      BegSel := SelB;
      SelB := Sel1;
      SelE := SelB+30;
      i:=1;
      found := false;
      if GetSelTextBuf( ReadBuff, 30 )<>0 then;
      while (i<=30) and (not Found) do
      begin
        if ReadBuff[i] in ['A'..'Z', 'a'..'z' ] then
          inc(i)
        else
          found := true;
      end;
      SelB := BegSel;
      SelE := i+Sel1;
      if SelB <> SelE then
        InvalidateRect(PaintPanel.Handle, Nil, True);
      CaretPos := Sel1;
    end;
  end;
  inherited HTMLMouseDown(Sender,Button,Shift,X,Y);
end;

end.

0
 

Author Comment

by:jpdupont
ID: 1343077
Very fine Mirek !
All is OK
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month6 days, 2 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question