OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15-07-2007, 23:49
fiorn
Guest
 
Posts: n/a
Question Text.story and mouse events

Hello,everyone.
I have some textshapes,and i have to get their story one by one.for example,i have some shapes: "A" ,"B"and "C".What i need is ,when i select shape"A",the variant i = "A",and when i select shape"B",i = "B".
How can i get the event mouse move and mouse down?Can't find in Corel library.
Can anyone help me ,thanks.
Reply With Quote
  #2  
Old 16-07-2007, 01:20
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

since v11 at least there are Global events in ThisMacroStorage/ThisDocument section of any gms macro project.
Open this module in project explorer in VBA Editor.
On top of the editor's code window there is a dropdown list with "(General)" usually. Choose another option there - usually GlobalMacroStorage.
A new Sub will appear, ignore it.
On the top, to the right there is another dropdown list - select "SelectionChange"
Remove the first appeared sub (usually GlobalMacroStorage_QueryDocumentClose)
type the code which may look like:
Code:
Option Explicit

Private Sub GlobalMacroStorage_SelectionChange()
   if not ActiveShape is nothing then
      set myGlobalShapeVar=ActiveShape
      ' do any additional processing
   endif
End Sub
In your usual code module (Module1 or form's code module) you should of course declare a global variable:
Code:
'top of code module
Option Explicit

public myGlobalShapeVar as shape
Further checks against shape's type and so on are up to your design
Reply With Quote
  #3  
Old 16-07-2007, 03:27
fiorn
Guest
 
Posts: n/a
Default

Thank your for reply,wOxxOm.my problem can be solve now,event "selection change" is the answer.but i still wanna to know if we can get mouse events using VBA?
Reply With Quote
  #4  
Old 16-07-2007, 13:02
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

there is no VBA mouse events registered and initiated from CorelDraw.

if you really need just that then you'll need to google for examples of SetTimer, GetCursorPos, SetWindowsHookEx, etc. These are part of Windows core functions - WinAPI. And well, it's a heavyduty stuff, but of course if you don't mind tackling with it then sooner rather than later you will find yourself pretty well accustomed to it.

I can help you maybe further if you describe what you wanna do in more details.
Reply With Quote
  #5  
Old 16-07-2007, 19:51
fiorn
Guest
 
Posts: n/a
Default

in fact soon after my thread posting i meet API problem.i wanna using a key stroke(Enter) to quit a sub and get into another sub.i find your suggestions to Rick Randall ,but GetUserClick can't help in my situation.I guess i need a keybd API.Can you tell me how to use this API?many appreciation.
Reply With Quote
  #6  
Old 16-07-2007, 20:17
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

in case you have a long processing loop in a macro - you may check periodically (here - at every iteration) for a certain key
Code:
private Declare Function GetAsyncKeyState& Lib "user32" (ByVal vKey&)

'............
sub SomeProcedure
   GetAsyncKeyState vbKeyReturn ' clear the ENTER (=Return in VBA) key state
   do 
      DoEvents
      if GetAsyncKeyState(vbKeyReturn) then ' Enter is (or was recently) pressed
         '......
      end if
   'do something
   '......
   loop
end sub
Reply With Quote
  #7  
Old 18-07-2007, 00:48
fiorn
Guest
 
Posts: n/a
Unhappy

Sorry man i can't try out .I want to let it quit from a Sub by a key press(once),but when i try(using GetAsyncKeyState) i find i have to keep the key pressed then it quit.
And here's new problem.this is my code:

Private Sub GlobalMacroStorage_SelectionChange()
Dim Gi As Integer
Gi = 0
If Not ActiveShape Is Nothing Then
If ActiveShape.Type = cdrTextShape Then
mString(Gi) = ActiveShape.Text.Story
UserForm2.TextBox1.Text = UserForm2.TextBox1.Text + mString(Gi)
Gi = Gi + 1
End If
End If
n = Gi - 1
End Sub

You can see what i want is when i select some text like "A","B"and "C" one by one,then "ABC" appears.But if i select "A" using pick tool,then i use hand tool to drag the picture to find "B",and then i choose pick tool(to pick "B"),the "A" appears repeatly in my TextBox! Is there any possible to avoid this case?
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
Get the position of the mouse gbottesi CorelDRAW/Corel DESIGNER VBA 3 17-07-2006 20:55
Getting the mouse position Rick Randall CorelDRAW/Corel DESIGNER VBA 1 04-12-2002 09:29


All times are GMT -5. The time now is 03:13.


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