![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programmer
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1
![]() |
Simple. Just Override DblClick(). There is a little issue with mouse clicks that is easierly solved. InputQuery() is a cool function from the Dialogs Unit.
uses Dialogs; << Add dialogs to your uses list
TWorkFlowShape = class(TPaintBox)
public
procedure DblClick; override; <<< Add New Method
end;
procedure TWorkFlowShape.DblClick;
var S: String;
begin
FIgnoreClick := True; // Ignore a mouse down click. Read below
if InputQuery(Application.Title, 'Enter Text', S) then
begin
Text := S;
Invalidate;
end;
end;Add the variable FIgnoreClick:Boolean to the TWorkflowShape class. In the MouseDown method add this code to the start: if FIgnoreClick then
begin
FIgnoreClick := False;
Exit;
end;This enables us to ignore a mousedown click when we receive a Double click. |
|
|
|
|
|
#22 |
|
Trying to be a Real Coder
|
Re: Drag and drop shape
So cool. I'm got it.
Oke. Biggest obstacle right now is how to make line that can be drag and drop, I really have no clue. If this problem has been solved, the next step is how to build a database, I've never done before, any suggestion? Just a little confide, I have learned tool that can build a web based apps, such as flash, js, or java applet before. But, my lecturer recommends for using delphi. Indeed, I've made a monopoly game using delphi, but I don't understand graphic on Delphi. {please understandable, I found it difficult to write English sentences correctly }
__________________
just a drop of dew in the morning |
|
|
|
|
|
#23 |
|
Programmer
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1
![]() |
Re: Drag and drop shape
Here are some updates. Now supports text editing, multiple connections and you can detach/attach connections to different shapes. Double click a "grip" to disconnect a connector, and then drag it over another grip to reconnect it.
Workflow.png Workflow.zip As for loading and saving. I normally use TXMLDocument. I code each class so it knows how to load and save, too and from TXMLNode's. If you haven't used XML before, then you can try TIniFile which is a bit easier, but has its limitations. |
|
|
|
|
|
#24 |
|
Trying to be a Real Coder
|
Re: Drag and drop shape
delphi Syntax (Toggle Plain Text)
__________________
just a drop of dew in the morning |
|
|
|
|
|
#25 |
|
Trying to be a Real Coder
|
Re: Drag and drop shape
I want to add an event on FPaintBox
delphi Syntax (Toggle Plain Text)
When I double click on FPaintBox, the popup ( ShowMessage('Do Something'); ) does not appear
__________________
just a drop of dew in the morning |
|
|
|
|
|
#26 | |||
|
Programmer
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1
![]() |
Re: Drag and drop shape
Quote:
Quote:
1) Overload a method (Only works if you inherit from a class) 2) Patch into a "notify event". (Works when another class wants the events). Note, if multiple methods connect to an event, you need to make sure you link the events. Otherwise, you disable code. 3) "message methods". Used for messages that haven't been implemented by Delphi. This is non-portable to CLX So, you need number 2. which means you need this in the TWorkFlow constructor: Quote:
|
|||
|
|
|
|
|
#27 |
|
Trying to be a Real Coder
|
Re: Drag and drop shape
ok thanks. You very expert about delphi, i'm salute to you
__________________
just a drop of dew in the morning |
|
|
|
|
|
#28 |
|
Trying to be a Real Coder
|
Re: Drag and drop shape
I want to make a Line Class (TPaintBox) in workflow.pas
delphi Syntax (Toggle Plain Text)
The problem is the line doesn't appear. I attached the project
__________________
just a drop of dew in the morning |
|
|
|
|
|
#29 |
|
Programmer
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1
![]() |
Re: Drag and drop shape
The code looks ok, so maybe you havent set the Parent of the control or you haven't made the control big enough and the line is clipped.
But, I wouldn't do it this way. I would use the method in the code I posted. You will run into a pile of problems. For you task, I would put all the lines in the same TPaintBox and use TShape's as grips. (Like my code) Yea, I did try using seperate TPaintBox's for lines in the past and its not good. You also cant use the mouse events of the paintbox to select a line. You need to use a "point on line" algorithm. Trust me. Its not worth the head pain |
|
|
|
|
|
#30 |
|
Programmer
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1
![]() |
Re: Drag and drop shape
Just more issues to think about.
1) When a TPaintBox is inverted via a resize (ie: width < 0 or height < 0), doesn't get displayed. So to use it for inverted shapes or lines, you need more coding. 2) When a TPaintBox has a width or height of 0, then no line can be drawn. ie: if you have a line that is (100, 0)-(100, 100), then the line wont get drawn. 3) This method wont support zooming or rotations. If you need zooming, then you need to code your own control library (more coding) Basiclly, look at this method as a simple way to get what you need done. For more advanced WYSIWYG GUI's, you would need to code more (ie: floating point controls), which isn't in the projects interest. Just put all the lines (connectors) in the base control. And you can code all your line selector code there. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| popup with drag and drop wont work. | RareDevil | JavaScript and Client-Side Browser Scripting | 1 | Mar 7th, 2009 3:52 PM |
| Drag and Drop Text in C# | BstrucT | C# | 2 | May 12th, 2008 8:29 AM |
| Drag n' Drop | tayspen | C# | 2 | Oct 22nd, 2005 2:46 PM |