Recent

Author Topic: TMemo gives stranges black area when using scrollbars  (Read 1653 times)

rolandvh

  • Newbie
  • Posts: 3
TMemo gives stranges black area when using scrollbars
« on: June 14, 2020, 07:15:15 pm »
Hi,

I'm using free vision and I'm using a TMemo in a dialog window. I give the memo 2 scrollbars and a indicator as you can see in the code below:

Code: Pascal  [Select][+][-]
  1. // Menu Discription
  2.     R.Assign(3, 14, 48, 15);
  3.     MemoHScrollBar := New(PScrollbar, Init(R));
  4.     R.Assign(50, 7, 51, 14);
  5.     MemoVScrollBar := New(PScrollbar, Init(R));
  6.     Insert(MemoHScrollBar);
  7.     Insert(MemoVScrollBar);
  8.     R.Assign(48, 14, 51, 15);
  9.     MemoIndicator := New(PIndicator, Init(R));
  10.     Insert(MemoIndicator);
  11.     R.Assign(3,7,50,14);
  12.     PMemoMenuDescription:=New(PMemo,Init(R, MemoHScrollBar, MemoVScrollBar, MemoIndicator, 10000));
  13.     PMemoMenuDescription^.Limit.X := 70;
  14.     PMemoMenuDescription^.Limit.Y := 40;
  15.     Insert(PMemoMenuDescription);
  16.     R.Assign(3,6,32,7);
  17.     Insert(New(PLabel, Init(R,'~D~iscription menu ', PMemoMenuDescription)));
  18.  
When I type in the memo field and I get past the width of the field I get a strange black box and characters are repeated. Often I also get an error message after I close the application when this happens.  Error code 216 (general protection fault). I just can't see what I'm doing wrong. See the attachment.
This happens under windows 10 and linux
Thanks for any replies.


« Last Edit: June 14, 2020, 09:15:54 pm by rolandvh »

rolandvh

  • Newbie
  • Posts: 3
Re: TMemo gives stranges black area when using scrollbars
« Reply #1 on: June 14, 2020, 08:39:51 pm »
To make it all a little simpler to test I made a simple program. Could it be a bug in TMemo?

Code: Pascal  [Select][+][-]
  1. program errormemo;
  2. uses App, Menus, dialogs, drivers, views, objects, editors;
  3. type
  4.    TMyApp = OBJECT(TApplication)
  5.         constructor init;
  6.         procedure HandleEvent(var aEvent : TEvent); virtual;
  7.         procedure MakeMemoDialog;
  8.         procedure InitMenuBar; virtual;
  9.    end;
  10.  
  11.  
  12. var
  13.         MyApp: TMyApp;
  14. const cmMemoDialog = 1000;
  15.  
  16. constructor TMyApp.init;
  17. begin
  18.         inherited init;
  19. end;
  20.  
  21. procedure TMyApp.InitMenuBar;
  22. var R : TRect;
  23. begin
  24.        GetExtent(R);
  25.         R.B.Y := R.A.Y + 1;
  26.         MenuBar := New(PMenubar, Init(R, NewMenu(NewSubMenu('~M~emo test',  hcNoContext,
  27.                                                  NewMenu(
  28.                                                  NewItem('Test', 'F2', kbF2, cmMemoDialog, hcNoContext, nil)),nil))));
  29. end;
  30.  
  31. procedure TMyApp.HandleEvent(var aEvent : TEvent);
  32. begin
  33.         inherited HandleEvent(aEvent);
  34.         if aEvent.What = evCommand then begin
  35.           case aEvent.Command of
  36.             cmMemoDialog:
  37.             begin
  38.                 MakeMemoDialog;
  39.             end
  40.             else
  41.             begin
  42.                 Exit;
  43.             end;
  44.           end;
  45.     end;
  46.     ClearEvent(aEvent);
  47.  
  48. end;
  49.  
  50. procedure TMyApp.MakeMemoDialog;
  51. var
  52.     D: PDialog;
  53.     R: TRect;
  54.     rs: word;
  55.     aVScrollBar : PScrollBar;
  56.     aHScrollBar : PScrollBar;
  57.     aIndicator : PIndicator;
  58.     aMemo : PMemo;
  59. begin
  60.     GetExtent(R);
  61.     R.A.X := R.A.X + 4;
  62.     R.A.Y := R.A.Y + 1;
  63.     R.B.X := R.B.X - 4;
  64.     R.B.Y := R.B.Y - 4;
  65.     D := New(PDialog, Init(R, 'Test memo'));
  66.  
  67.     R.A.X := 3;
  68.     R.A.Y := 10;
  69.     R.B.X := 60;
  70.     R.B.Y := 11;
  71.     aHScrollBar := New(PScrollbar, Init(R));
  72.     D^.Insert(aHScrollBar);
  73.  
  74.     R.A.X := 60;
  75.     R.A.Y := 3;
  76.     R.B.X := 61;
  77.     R.B.Y := 10;
  78.     aVScrollBar := New(PScrollBar, Init(R));
  79.     D^.Insert(aVScrollBar);
  80.  
  81.     R.A.X := 61;
  82.     R.A.Y := 7;
  83.     R.B.X := 64;
  84.     R.B.Y := 8;
  85.     aIndicator := New(PIndicator, Init(R));
  86.     D^.Insert(aIndicator);
  87.  
  88.     R.A.X := 3;
  89.     R.A.Y := 3;
  90.     R.B.X := 60;
  91.     R.B.Y := 10;
  92.     aMemo := New(PMemo, Init(R, aHScrollBar, aVScrollBar, aIndicator, 10000));
  93.     aMemo^.Limit.X := 70;
  94.     aMemo^.Limit.Y := 40;
  95.     D^.Insert(aMemo);
  96.  
  97.  
  98.     rs := Desktop^.ExecView(D);
  99.     Dispose(D, Done);
  100.  
  101. end;
  102.  
  103. begin
  104.   MyApp.Init;
  105.   MyApp.Run;
  106.   MyApp.Done;
  107. end.
  108.  
« Last Edit: June 14, 2020, 09:16:38 pm by rolandvh »

TRon

  • Hero Member
  • *****
  • Posts: 525
Re: TMemo gives stranges black area when using scrollbars
« Reply #2 on: June 14, 2020, 09:12:38 pm »
Hi rolandvh,

please be so kind to edit your first two posts and enclose your code with code tags, see: https://wiki.freepascal.org/Forum#Use_code_tags

edit: thank you   :)

edit2: and i am able to confirm (not that i have any knowledge code-wise on fv)
« Last Edit: June 15, 2020, 07:05:52 am by TRon »

rolandvh

  • Newbie
  • Posts: 3
Re: TMemo gives stranges black area when using scrollbars
« Reply #3 on: June 15, 2020, 08:27:57 am »
Thank you for your reply.  Could be a bug then. Would be nice if someone could confirm this with the right knowledge of fv. But maybe I should report it in the bugtracker anyway.

 

TinyPortal © 2005-2018