?
Solved

Disable double click in TrichEdit

Posted on 2003-04-01
7
Medium Priority
?
523 Views
Last Modified: 2010-04-06
Hey there, releative newbie here...

I'm writing a program and one of the features is that when I press CONTROL and click on a text block in a TrichEdit window it increments to the next relative value. All fine and well unless I click too fast and it tries to highlight something else further along the line. Is there any way of disabling this? My current thoughts are to use a timer and if the second mouse click is too fast then ignore it. I think this would work but I would prefer to be able to click as fast as I like and not have the program shoot off elsewhere.
Any suggestions?

Also another really easy question (at least I imagine it is if you know the answer! :(  ) Is there a way to disbale the blinking caret in an edit box or richedit window? I'd like to hide it when text is selcted and then re-enable it when entering data. I'll offer another 10 points for an answer.

Thanks a lot.
0
Comment
Question by:Ramah_Palmer
[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
  • 4
  • 3
7 Comments
 
LVL 34

Accepted Solution

by:
Slick812 earned 280 total points
ID: 8256892
hello Ramah_Palmer, you can subclasss the Richedit and catch the WM_LBUTTONDBLCLK messages and block it. You can use the HideCaret( ) function to do that.


  private
    { Private declarations }
    ClaretShow: Boolean;
    PRichEdWndProc, POldWndProc: Pointer;
    procedure RichEdWndProc(var Msg: TMessage);

implementation

{$R *.DFM}

procedure TForm3.FormCreate(Sender: TObject);
begin
ClaretShow := True;
PRichEdWndProc := MakeObjectInstance(RichEdWndProc);
POldWndProc:= Pointer(SetWindowLong(RichEdit1.Handle,GWL_WNDPROC, Integer(PRichEdWndProc)));
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
if Assigned(PRichEdWndProc) then
  begin
  SetWindowLong(RichEdit1.Handle,GWL_WNDPROC, Integer(POldWndProc));
  FreeObjectInstance(PRichEdWndProc);
  end;
end;

procedure TForm3.RichEdWndProc(var Msg: TMessage);
begin
if (Msg.Msg = WM_LBUTTONDBLCLK) then Exit;
{if you Exit the WM_LBUTTONDBLCLK will not be sent to the System for processing}
Msg.Result := CallWindowProc(POldWndProc,RichEdit1.Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end;

procedure TForm3.sbut_HideClaretClick(Sender: TObject);
begin
{you can hide and Show the RichEdit Clatet}
if ClaretShow then
  begin
  ClaretShow := False;
  HideCaret(RichEdit1.Handle);
  end else
  begin
  ClaretShow := True;
  ShowCaret(RichEdit1.Handle);
  end;
end;

procedure TForm3.RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
{whenever the Richedit is clicked the Claret shows}
ClaretShow := True;
end;

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ask questions if you need more infomation. . . Suggestion, 20 and 10 points for a question are VERY VERY LOW, you should offer at least 50 points. . . . maybe this type of question is worth 80 or 100 points?
0
 

Author Comment

by:Ramah_Palmer
ID: 8269222
Thanks a lot Slick. I've now got the doubleclick problem working beautifully. I'm having some problems with your hidecaret solution though. I may be doing it wrong but I assume that I have to add the sbut_HideClaretClick procedure to my form's definitions? If I do I can get the program to compile otherwise it throws errors. But once it's compiled how exactly is the procedure called?

As regards to the points I offered, sorry but ignorance told me they would be quite simple problems for you guys to help with. I didn't realise the answer would involve quite as much work for you as it did. Rest assured that when I accept your answer I will up the points for you.
Cheers.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 8273594
????????, , ,  LOOK AT THE PROCEDURE
procedure TForm3.sbut_HideClaretClick(Sender: TObject);

it says Click(Sender: TObject); at the end

This is a BUTTON CLICK EVENT, add a button to your form. double click the OnClick event for that button and add this code -


if ClaretShow then
 begin
 ClaretShow := False;
 HideCaret(RichEdit1.Handle);
 end else
 begin
 ClaretShow := True;
 ShowCaret(RichEdit1.Handle);
 end;

I guess I should add more explanation?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Slick812
ID: 8273606
there's many many questions here at EE, take some time to look around at some qestions and you can get some idea about points, there are so many questions here, you may need at least 50 points to get noticed. Also since there are many questions, you can often find your answer by a Search here at EE
0
 

Author Comment

by:Ramah_Palmer
ID: 8274396
Thanks Slick. As I say, I'm a relative newbie to all this and am not completely au fait with accepted conventions. Now that you've explained the answer it makes sense now. I thought you meant to use it as a standalone procedure. A button like that isn't the way I want to use it but now I know how it's supposed to work I can tailor it to my needs. Again, many thanks.
Back to the points issue, I scored so low for three reasons. One, as I explained last time, I didn't know the complexity of the question. Two, I looked at a lot of questions in the 'Questions answered' section and most of them seemed even lower than 20. And thirdly, I've only just registered here, I'm not a paid member yet and I admit, I was hoarding my free points. :)
And coz I aint a paid member I cannot use the search facility. I did however look through over a thousand questions before I posted mine. But there is about 27000 in all and didn't really have the time.
So thanks again. Despite my low scoring you answered my question very promptly. One last thing, just off the top of your head, don't spend any time on this but is there a book that you can recommend to one such as me? I've found books on Delphi are very thin on the ground. I've pretty much got to grips with the language (except pointers still make me run away) and the IDE, but am nowhere near windows handling messages like the ones you gave me.
Thanks.
0
 

Author Comment

by:Ramah_Palmer
ID: 8274398
Thanks Slick, hope 70 points are more to your liking. I'm saving the rest now for one more question. After that looks like the credit card will have to come out...
0
 
LVL 34

Expert Comment

by:Slick812
ID: 8276108
I did not sugges that you look at All of the questions :-), just a few. I also did not mean that there wasn't low point questions, but notice that I'm the only one to comment here, I did not realize that there was no search for you??? I don't have time to check, but it seems like everyone has access to some sort of search here, I realize the Premium search is restricted, by you might want to look at the "Info" area to see about that.

Books

for beginers
Teach Yourself Delphi 4 in 21 days

moderate level
Using Delphi 4

Delphi 4 Unleased
even though these are Delphi 4, it's got alot of stuff that can be used in newer versions

Real Good, maybe advanced
Delphi Developers Handbook


if you want to know more about the windows API and windows messages, look at

http://www.angelfire.com/hi5/delphizeus/index.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
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

801 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