Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Event handler for control notifications?

Posted on 1998-09-15
4
Medium Priority
?
324 Views
Last Modified: 2010-08-05
I know how to set up my own event handler for a WM_.. message. But, I don't know how to set up one for a control notification message such as EN_PROTECTED or EN_LINK (richedit). Such notifications come through WM_COMMAND. So, I can always set up a WM_COMMAND handler to catch the above. But, I was just wondering whether there is an easier way to do this.

Thanks,
Sanjay
0
Comment
Question by:skanade
[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
  • 2
4 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1339766
Don't know. But I think handling WM_COMMAND is the only/best way...
0
 
LVL 2

Expert Comment

by:Hagen040798
ID: 1339767
for RichEdit you must use this.

type
  TMyRichEdit = class(TRichEdit)
  protected
    procedure CNNotify(var Message: TWMnotify); message cn_Notify;
  end;  

procedure TMyRichEdit.CNNotify(var Message: TWMNotify);
type
  PENLink = ^TENLink;
var
  TextRange: packed record
               chrg: TCharRange;
               URL: PChar;
             end;
begin
  with Message.NMHdr^ do
    case Code of
      EN_LINK:
        with PENLink(Pointer(Message.NMHdr))^ do
          if Msg = wm_SetCursor then
          begin
            SetCursor(Screen.Cursors[crHandPoint]);
            Message.Result := 1;
          end else
            if Msg = wm_LButtonDblClk then
            try
              TextRange.URL := StrAlloc(chrg.cpMax - chrg.cpMin + 10);
              TextRange.chrg := chrg;
              Perform(em_GetTextRange, 0, LongInt(@TextRange));
              ShellExecute(Application.Handle, 'open', TextRange.URL, nil, nil, sw_ShowNormal);
              Message.Result := 1;
            finally
              StrDispose(TextRange.URL);
            end;
      EN_OLEOPFAILED: ;
    end;
end;

0
 

Author Comment

by:skanade
ID: 1339768
Hagen,

Thanks! That worked. Please put a comment as answer so that I can give you the points.

Sanjay
0
 
LVL 2

Accepted Solution

by:
Hagen040798 earned 200 total points
ID: 1339769
Hi

my Answer.
When you will more from RichEdit-programming, i can you help.
When you not will make a Descend vom TRichEdit, you can the TRichEdit dynamicly subclassing (D3).

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    procedure FormCreate(Sender: TObject);
  private
    SaveWndProc: TWndMethod;
    procedure RichEditWndProc(var Msg: TMessage);
  end;

procedure TForm1.FormCreate(Sender: TObject)
begin
  SaveWndProc := RichEdit1.WndProc;
  RichEdit1.WndProc := RichEditWndProc;
end;

procedure TForm1.RichEditWndProc(var Msg: TMessage);
begin
  if Msg.Msg = cn_Notify then
    with TWMNotify(Msg).NMHdr^ do    
      case Code of
        en_Link:
          begin
            Exit;
          end;
      end;
  SaveWndProc(Msg);
end;

Thanks for the points. Hagen.
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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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