Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic VB to delphi Conversion Problem ! (Read 2819 times)
parkwonwoo
Junior Member
**
Offline


Open the Podbay Doors
HAL!

Posts: 61
Joined: Dec 8th, 2006
VB to delphi Conversion Problem !
Dec 8th, 2006 at 12:11am
Print Post  
Hi All, next code is from the FlowChartX Manual.

//--------------------------------------------------------------
Private Sub fc_MouseMove(ByVal docX As Long, ByVal docY As Long)

    Dim obj As Object
    Dim b As box

    'get the object under the mouse pointer
    obj = fc.ObjectFromPoint(docX, docY, True, False)

    If obj Is Nothing Then

       'clear the status bar message
       statusBar.Panels(1).Text = ""
       Exit Sub
    End If

    'if it is a box ...
    If TypeOf obj Is box Then
       b = obj
       statusBar.Panels(1).Text = b.UserString
    End If

End Sub
//----------------------------------------------------------

In Delphi, 'Nothing' and 'TypeOf' Statement is not converted.



My Malfunction Code is here.
//------------------------------------------------------------
var
  Obj: IDispatch;  //Dim obj As Object
begin
  obj := fc1.ObjectFromPoint(docX, docY, false, false);
//  if obj=nil then begin
//    RzStatusPane2.Caption :='void area';
    end;

//    if (obj is box) then begin
//        Box0 := obj;
//        RzStatusPane1.Caption := Box0.UserString;
//    end;
//   end;
end;
//-------------------------------------------------------------

Pleas tell me the correct conversion code of above it.

Thank in advances.
  

OS: WinXP sp2&&RAD: Borland Delphi7, C++Builder6, JBuilder9&&FrameWork: VCL+Win32 or J2SE&&FCX: FCX 4.1.x
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: VB to delphi Conversion Problem !
Reply #1 - Dec 8th, 2006 at 5:44am
Print Post  
Hi,

If obj Is Nothing Then

in VB should be equivalent to

if obj=nil then begin

in Delphi.

Checking if the object is a box should look like

if obj as IBox <> nil then ...

You might also use the GetBoxAt method to get a box object, without need to cast it from IDispatch.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
parkwonwoo
Junior Member
**
Offline


Open the Podbay Doors
HAL!

Posts: 61
Joined: Dec 8th, 2006
Re: VB to delphi Conversion Problem !
Reply #2 - Dec 8th, 2006 at 8:53am
Print Post  
Thanks of your answer.

I'm not solve the problem.

Code
Select All
procedure TForm1.FC1MouseMove(ASender: TObject; docX, docY: Integer);
 var
  Obj: IDispatch;  //Dim obj As Object
begin
  obj := fc1.ObjectFromPoint(docX, docY, false, false);
    if obj=nil then begin
	Label1.Caption :='void area';
    end;

    if (obj as IBOXItem<>nil) then begin
	Label1.Caption :='Box here';
    end;

end;
 



- Error: No Compile Eorror. ^^; but

- Result: There is no change to Label1.

What's wrong with my code?
  

OS: WinXP sp2&&RAD: Borland Delphi7, C++Builder6, JBuilder9&&FrameWork: VCL+Win32 or J2SE&&FCX: FCX 4.1.x
Back to top
 
IP Logged
 
parkwonwoo
Junior Member
**
Offline


Open the Podbay Doors
HAL!

Posts: 61
Joined: Dec 8th, 2006
Re: Problem Fixed. Thanks!
Reply #3 - Dec 10th, 2006 at 11:08pm
Print Post  
Mouse Move EvenetHandling Problem  and

Type Casting Problem is fixed.

Thanks !.

- Parkwonwoo
- South Korea.
  

OS: WinXP sp2&&RAD: Borland Delphi7, C++Builder6, JBuilder9&&FrameWork: VCL+Win32 or J2SE&&FCX: FCX 4.1.x
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint