[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


SynMemo and bookmarks problem

Posted on 2006-03-24
Medium Priority
Last Modified: 2008-01-09
Hi there,

I am creating text editor using TSynMemo component from SynEdit package. I would like to use bookmark functionality. Based on SynEdit example I created OnGutterClick event as follows:

procedure TSourceEditorForm.reSourceEditGutterClick(Sender: TObject;
  Button: TMouseButton; X, Y, Line: Integer; Mark: TSynEditMark);
   bookMark: TSynEditMark;
   if not Assigned(Mark) then
      if reSourceEdit.Marks.Count > 4 then exit;
      bookMark := TSynEditMark.Create(reSourceEdit);
      bookMark.ImageIndex := reSourceEdit.Marks.Count + 9;
      bookMark.Line := reSourceEdit.CaretY;
      bookMark.Char := reSourceEdit.CaretX;
      bookMark.Visible := true;
   else if not Mark.IsBookmark then

Unfortunately it doesn't work as expected. When I click gutter line with existing bookmark it doesn't disappear. Another bookmark is created. It seems that Mark parameter in event handler is never valid. Does anyone have OnGutterClick event implemented correctly?


Question by:albireo77
  • 2

Expert Comment

ID: 16291800
Hi albi

I'm not able to recreate your problem entirely, i think i maybe using an earlier/later version of SynEdit than you as my OnGutterClick event is different, mine doesn't have the "Button: TMouseButton;" The "Char" property doesn't exist for TSynEditMark either in my version.

Anyway i've come up with the following which appears to work fine

procedure TForm1.SynMemo1GutterClick(Sender: TObject; X, Y, Line: Integer; mark: TSynEditMark);
   if not Assigned(Mark) then
      Mark := TSynEditMark.Create(SynMemo1);
      Mark.Line := SynMemo1.CaretY;
      Mark.Visible := true;
   if not Mark.IsBookmark then

basically what you've done with your code is checked to see if the variable "Mark" is assigned and if not you then create another TSynEditMark through your own variable "bookMark", the problem here is the next time you click on the gutter the program checks if "Mark" has been assigned which it hasn't and it never will be because you create "bookMark". Theoretically you should only ever get one bookmark on the entire gutter from this code, this is the problem i was getting anyway well without the Char property cause it doesn't exist but because you have the "Char" property in your version i can see why you would get more than one bookmark per line if the Char value is different for each bookmark.

I hope this makes sense


Author Comment

ID: 16319050

I checked and OnGutterClick event handler without Button parameter exists in SynEdit 1.x I had 2.x After going back to 1.4 I created new OnGutterClick handler. That's very strange because whenever I click gutter and this event handler exists I get access violation exception. Even when the handler has only comment inside! So it's not bad code fault. If there is no handler, there's no exception. I created new TSynMemo completely from scratch and the situation is similar. Any ideas?


Accepted Solution

HillGroover earned 800 total points
ID: 16371806
Hi albi,

Try removing all the .dcu files in the project directory and recompile and see what happens when you have the event in then.

if that doesn't work search for all the .dcu files that relate to synedit and remove them then reinstall version 1.4, it could be that somewhere something related to version 2 is still lurking around.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

868 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