OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Code Critique (http://forum.oberonplace.com/forumdisplay.php?f=25)
-   -   Node Mover (http://forum.oberonplace.com/showthread.php?t=869)

ddonnahoe 22-02-2005 17:50

Node Mover
 
3 Attachment(s)
I am trying to run this macro in vbModeless, but to no avail on my home PC. What could be causing this problem?

At the beginning... cmdConvert_Click I am trying to determine if there is a node selected or not... I would also like to do this for the cmdMove_Click as well. I want the form to stay up so I can select a different node and move or convert it as well. This is a whole lot easier with shapes only.

Code:

Option Explicit

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdConvert_Click()
    Dim n As Node
   
    If n.Type = cdrMixedNodes Then
        n.Selected = True
        ConvertNode
    Else
        MsgBox "The selected object must be a node", vbOKOnly
    End If
End Sub

Private Sub cmdMove_Click()
    Dim x As Double, y As Double
    Dim sx As Double, sy As Double
    Dim dw As Double, dh As Double
    Dim msg As String
    Dim Resp As String
    Dim d As Document
   
    msg = "This will be off the page." & vbLf & "Is this OK?"
   
    Set dw = d.ActivePage.SizeWidth
    Set dh = d.ActivePage.SizeHeight
    sx = Val(CoordX.Text)
    sy = Val(CoordY.Text)
    If sx < 0 Or sy < 0 Or sx > dw Or sy > dh Then
        Resp = MsgBox(msg, vbYesNo, "Alert!")
            If Resp = vbYes Then
                MoveNode
            Else
                Exit Sub
            End If
    End If
End Sub

Private Sub ConvertNode()
    Dim n As Node
   
    n.Segment.Type = cdrCurveSegment
    If optCusp Then n.Type = cdrCuspNode
    If optSmooth Then n.Type = cdrSmoothNode
    If optSymmetrical Then n.Type = cdrSymmetricalNode
End Sub

Private Sub UserForm_Initialize()
    optCusp.Value = True
    CoordX.Text = "0.00"
    CoordY.Text = "0.00"
End Sub

Private Sub MoveNode()
    'moving the nodes...
    MsgBox "the node has been moved", vbCritical 'This is for testing purposes...
End Sub


jemmyell 23-02-2005 10:20

Hi Sean,

First a guess about vbModeless. How are you launching this form? If it is a child of a modal form, I don't think setting it to modeless will help. I am testing all my stuff that may be affected by a focus shift using debug.print instead of message boxes and I launch my test modeless forms from a macro button in my workspace.

In the rest of your code, I don't see how 'Dim n as Node' is ever assigned? Or 'Dim d as Document' either. I am unaware of default assignments for local variables like these, BUT I am very new to CorelDraw VBA also! :)

ddonnahoe 23-02-2005 10:56

Thanks for the reply...

This is the parent Window so it should be able to launch modeless. I know that child windows can only be launched as modal.

As for the unused variables... I am planning to use them further into the code.

The problem I'm running into with the modeless/modal is, I can run Modeless at work on XP Pro SP2 CD12 SP1. The only difference at home is that I am running XP Home SP2. My Draw is exactly the same.
<scratches head> :dontknow:

Alex 23-02-2005 15:05

Sean,

I guess the question is, how do you show the form? We haven't seen the actual code which does "BlahBlahForm.Show vbModeless", so that's where all confusion comes from.

ddonnahoe 23-02-2005 15:14

The launch module is coded as follows:
Code:

Option Explicit

Sub Run()
    MoverForm.Show vbModeless
End Sub

I copied directly from your (Alex's) ObjCreator Macro. It's very strange. It works on my office PC, but not at home. I have also posted all of the code for the form in the "Code Critique" section. I am hoping to get some other questions answered there as well.

Alex 23-02-2005 16:05

Quote:

Originally Posted by ddonnahoe
The launch module is coded as follows:
Code:

Option Explicit

Sub Run()
    MoverForm.Show vbModeless
End Sub

I copied directly from your (Alex's) ObjCreator Macro. It's very strange. It works on my office PC, but not at home. I have also posted all of the code for the form in the "Code Critique" section. I am hoping to get some other questions answered there as well.

Are you sure you are running the Run macro? And not just the form itself? When you are in VBA editor and select the form in Project Explorer window and hit Run (F5) the form will be "run". And it is always shown in Modal form. You need to make sure you select the code module and place your cursor into the "Sub Run()" before you actually run the macro (or use Tools>Visual Basic>Play in Draw, or customize a button for the macro, or any other mean). I sense that this is your problem...

Let me know how it goes.

ddonnahoe 23-02-2005 16:33

:banghead: HAHAHA!!!! Sometimes the easiest things are the very things we overlook.


All times are GMT -5. The time now is 14:33.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com