OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Code Critique

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22-02-2005, 17:50
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Node Mover

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
Attached Images
 
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 23-02-2005, 10:20
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default

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!
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
  #3  
Old 23-02-2005, 10:56
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

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>
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #4  
Old 23-02-2005, 15:05
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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.
Reply With Quote
  #5  
Old 23-02-2005, 15:14
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

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.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #6  
Old 23-02-2005, 16:05
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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.
Reply With Quote
  #7  
Old 23-02-2005, 16:33
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

HAHAHA!!!! Sometimes the easiest things are the very things we overlook.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Node Coordinate designation ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 24-02-2005 09:00
highlighting node lkoky CorelDRAW/Corel DESIGNER VBA 2 05-11-2004 02:44
vba question bumblebee CorelDRAW/Corel DESIGNER VBA 4 04-08-2004 15:07
Detecting Last Node Selected? barnold CorelDRAW/Corel DESIGNER VBA 4 21-04-2004 13:03
Node selection question Peter Clifton CorelDRAW/Corel DESIGNER VBA 1 02-12-2003 12:00


All times are GMT -5. The time now is 12:57.


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