Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building line while holdine button down in an object
Message
From
04/12/1998 01:51:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
03/12/1998 05:53:01
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00163564
Message ID:
00163975
Views:
25
>Hi,
>
> Does anyone has any idea of drawing a line say in a OLE object to draw a line while holding down the left button of the mouse till the dragging is stopped on the object.
>
>
>Thanks.
>shashi
Shashi,
I did a similar thing (mimic objects selection as in form designer) in one of our projects but cannot collect the code for now. So I'll just give outline of what I did :
Problem 1 : As mouse moves or when first pressed different objects would get mouse* events. And cumbersome to write code for so many objects.
My solution : From a toolbar set selection mode on/off. On also immediately places a transparent shape covering whole form. It's a shape class, that has rest of the code for drawing and removeobjects itself as soon as drawing mode is finished.
So now you deal with only one object (shape) and through its methods do drawing. Add a line object, keep properties for start of line (LeftStart, TopStart) and . Then you would just change height, top and lineslant as mouse moves. Fox repaint extremely fast that this operation is smooth. Not for a line but for sizing a shape here is a sample class :
**************************************************
*-- Class:        shpsizeable (d:\test\classes\test.vcx)
*-- ParentClass:  shape
*-- BaseClass:    shape
*
DEFINE CLASS shpsizeable AS shape
  Height = 116
  Width = 107
  threshhold = 3
  Name = "sizeable"
  InResize = .F.
  ldraglb = .F.
  ldragbb = .F.
  ldragtb = .F.
  ldragrb = .F.
  PROCEDURE MouseMove
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  IF this.inResize
    IF this.ldraglb
      IF nXCoord < this.left
        this.width 	= this.width + abs(this.left - nXCoord)
      ELSE
        this.width 	= max(this.width - abs(this.left - nXCoord),0)
      ENDIF
      this.left = nXCoord
    ENDIF
    IF this.ldragtb
      IF nYCoord < this.top
        this.height = this.height + abs(this.top - nYCoord)
      ELSE
        this.height = max(this.height - abs(this.top - nYCoord),0)
      ENDIF
      this.top	= nYCoord
    ENDIF
    IF this.ldragrb
      IF nXCoord < this.left + this.width
        this.width 	= max(this.width - abs(this.left + this.width - nXCoord),0)
      ELSE
        this.width 	= this.width + abs(this.left + this.width - nXCoord)
      ENDIF
    ENDIF
    IF this.ldragbb
      IF nYCoord < this.top + this.height
        this.height = max(this.height - abs(this.top + this.height - nYCoord),0)
      ELSE
        this.height = this.height + abs(this.top + this.height - nYCoord)
      ENDIF
    ENDIF
  ELSE
    this.ldraglb = between(nXCoord,this.left-this.threshhold,this.left+this.threshhold)
    this.ldragtb = between(nYCoord,;
      this.top - this.threshhold, this.top+this.threshhold)
    this.ldragrb = between(nXCoord,;
      this.left+this.width-this.threshhold,this.left+this.width+this.threshhold)
    this.ldragbb = between(nYCoord, ;
      this.top+this.height-this.threshhold, this.top+this.height+this.threshhold)
    DO case
      CASE this.ldraglb and this.ldragtb ;
          or this.ldragrb and this.ldragbb
        this.mousepointer = 8
      CASE this.ldraglb and this.ldragbb ;
          or this.ldragrb and this.ldragtb
        this.mousepointer = 6
      CASE this.ldragrb or this.ldraglb
        this.mousepointer = 9
      CASE this.ldragtb or this.ldragbb
        this.mousepointer = 7
      OTHERWISE
        this.mousepointer = 0
    ENDCASE
  ENDIF
ENDPROC

  PROCEDURE MouseDown
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  this.ldraglb = between(nXCoord,this.left-this.threshhold,this.left+this.threshhold)
  this.ldragtb = between(nYCoord,;
    this.top - this.threshhold, this.top+this.threshhold)
  this.ldragrb = between(nXCoord,;
    this.left+this.width-this.threshhold,this.left+this.width+this.threshhold)
  this.ldragbb = between(nYCoord, ;
    this.top+this.height-this.threshhold, this.top+this.height+this.threshhold)
  this.inResize = this.ldraglb or this.ldragtb or this.ldragrb or this.ldragbb
ENDPROC

  PROCEDURE MouseUp
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  this.inResize = .f.
ENDPROC

ENDDEFINE
*
*-- EndDefine: shpsizeable
**************************************************
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform