Solved

'Rubber band rectangle' problem

Posted on 2007-03-28
5
499 Views
Last Modified: 2010-04-05
Dear Experts,

Thanks to you all I have a new feature in my application:  
To select text of a canvas with the mouse by creating a
'Rubber band rectangle'. And it works good.

When I have asked the questions on this site to make a
'Rubber band rectangle' I used  a TImage to draw on.

But, now I have deside not to use the TImage anymore to
draw on, but drawing on the form's canvas itself.

By drawing on the form's canvas, the 'Rubber band rectangle'
works like a clock, much better then using the TImage.

But one little problem occurs. When I use menu-item Select All
or create a 'Rubber band rectangle' with the mouse to select text
you see also the ROWS and COlUMNS. And that's nog good.
Who can help me to solve this problem?

If you don't know what I mean, you can download my example
on my site: http://members.home.nl/peterkiers/
(Beneath the Under Construction Bar you see a floppy disk).

Select menu-item Fill buffer to display characters on the canvas
and select them by clicking on menu-item Select All or use your
mouse. And you see the selected text will be highlighted but
you see also the rows and colums, and that is not what i want.

Who can help me solve this problem?

Thank you in advanced,

Greetings,

Peter Kiers




0
Comment
Question by:peterkiers
  • 3
5 Comments
 
LVL 1

Author Comment

by:peterkiers
ID: 18813464
I have added a picture on my site to let you see what happens
if text is selected.

P.
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 18813750
What about this?
http://i10.tinypic.com/2hr2y5t.jpg
any problem?
Should be some problem related to font. Try using different font.
0
 
LVL 10

Accepted Solution

by:
dinilud earned 500 total points
ID: 18813784
procedure TMainForm.DispCell(x, y: integer; PaintBlanks: boolean);
var
  xpos, ypos: integer;
begin
  xpos := (x * FontWidthPix) - FontWidthPix;
  ypos := (y * FontHeightPix) - FontHeightPix;
  with Canvas do
  begin
    Brush.Style := bsSolid;
    Brush.Color := ColorBlack;
    Pen.Color:=clBlack;
    if (ScrBuf[y, x].data = Char(cdDefault)) or
      (ScrBuf[y, x].data = Char(cdFieldAttr)) then
    begin
      if PaintBlanks then
      begin
        Font.Style := [];
        TextOut(xpos, ypos, ' ');
      end;
    end
    else
    begin
      if (Byte(ScrBuf[y, x].attrib) and caNonDisp) <> caNonDisp then
      begin
        Pen.Mode := pmCopy;
        Font.Color := ColorMapI2W(ScrBuf[y, x].color);
        if ScrBuf[y, x].hilite = Char(chDefault) then
          Font.Style := []
        else if ScrBuf[y, x].hilite = Char(chReverse) then
        begin
          Font.Style := [];
          //Pen.Mode := pmXor;
          Brush.Color := ColorMapI2W(ScrBuf[y, x].color);
          Pen.Color :=Brush.Color;
          Font.Color := ColorBlack;
        end
        else if ScrBuf[y, x].hilite = Char(chUnderLine) then
          Font.Style := [fsUnderline]
        else if ScrBuf[y, x].hilite = Char(chBlink) then
          Font.Style := [fsStrikeout]
        else
          Font.Style := [];
        if (Byte(ScrBuf[y, x].attrib) and caIntens) = caIntens then
          Font.Style := Font.Style + [fsBold];
        Rectangle(xpos,YPos,xpos+FontWidthPix, ypos+FontHeightPix);
        TextOut(xpos, ypos, ScrBuf[y, x].data);
      end
      else
        TextOut(xpos, ypos, ' ');
    end;
  end;
end;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 18814016
Hi, with your code the problem is solved only
The cursor has vanished. When I click on a cell
there is no cursor anuymore.

Peter


0
 
LVL 1

Author Comment

by:peterkiers
ID: 18814275
ah, I have solved it myself
dinilud thank you.

Greetings,

Peter Kiers
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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