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 04-11-2008, 15:50
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default Sending mouse coordinates after click

Got this kinda weird interface idea which involves clicking on a button, dragging a little and letting go. And then giving the procedure which gets called by pressing that button the coordinates of that first click and those at the moment it was let go. So, say, a click was made at 223,450 and then the mouse was let go on 245,453 (+22,+3 would also work just fine). So getting 4 coordinates and giving them to a procedure would be really nice.

Since my amazing coding abilities reside somewhere near what was taught in grade school using ancient Russian machines (BK basic, yeah!) coming up with the right code presents a problem. Any suggestions? Sounds like MouseDown is the way to go, but how...?

And as a more demanding version (or maybe not) one that would do something (simple, like setting a value based on a calculation) for as long as the mouse is held down while receiving its current coordinates.

And since we are talking about interfaces - how to get the focus away from the VBA form after a button is clicked? Nothing I could find here seems to work (like BringWindowToTop) in CorelDraw X4.

Thanks!
Reply With Quote
  #2  
Old 04-11-2008, 16:39
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Might get you started...

There is no direct support for mouseup or down....but here are a couple posts that might get you started.

Cursor Position
MousePosition

Best of luck,

-Shelby
Reply With Quote
  #3  
Old 04-11-2008, 16:46
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Yeah, seems like that might work, just found another sample of using GetCursorPos form the user32 lib as well (Slowly reading all of the posts here in backwards sequence).

The idea is pretty crazy, kinda like packing 10 buttons and a spinner inside just one button. Put it down on paper here, now gotta try and put it into some code.
Reply With Quote
  #4  
Old 04-11-2008, 16:57
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Another one...

Here is another one:

Fun with API

-Shelby
Reply With Quote
  #5  
Old 04-11-2008, 17:31
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Thanks for all the info, kinda bumped me in the right direction and yet it turned out to be insanely simple for this purpose, check this out:

Code:
Private Sub CommandButton2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    'X and Y as starting coordinates
End Sub

Private Sub CommandButton2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    'X and Y as ending coordinates
End Sub
And all that needs to be done is storing that first set of X and Y coordinates (now just to learn to properly use global variables) and then read them when the second set comes in. As an added bonus Shift and Ctrl keys can be checked as well.

Gonna try and implement this properly tomorrow, should be a fun little thing.
Reply With Quote
  #6  
Old 05-11-2008, 02:40
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Having slept on it I realized that there's no real need for the first one, since the coordinates are always relative to the control - so all you need to do is give the coordinates after the mouse goes up to a Function (wrote my first VBA function finally - so very proud ) and let it do the rest.

Do what? You might ask. Well, something like this for example.

May not be everyone's cup of tea, but I like it and intend to replace most "multi-button" controls with something like this. Should save some room for other functions AND make several things more intuitive once you know how to do them.

The only thing that remains is getting the focus back to the workspace after pressing a button, say "Select all text". And, perhaps, do something while the mouse is still in motion. My thought was:

Code:
Do While MouseDown = True 'THIS IS CLEARLY WRONG and the tripping stone so far
    AwesomeCalculationFunction (X,Y)
    DoEvents
    Loop
So have to find out how to constantly do something While the mouse is held down.

Last edited by Joe; 05-11-2008 at 02:45.
Reply With Quote
Reply

Tags
coordinates, focus, mouse


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
Sending document size to printer tacarey CorelDRAW/Corel DESIGNER VBA 5 16-05-2008 01:09
Get the position of the mouse gbottesi CorelDRAW/Corel DESIGNER VBA 3 17-07-2006 20:55
forum fails in sending notification s_federici Web site suggestions 2 08-11-2004 02:47
Getting the mouse position Rick Randall CorelDRAW/Corel DESIGNER VBA 1 04-12-2002 09:29
Sending document size to printer tacarey Macros/Add-ons 4 31-12-1969 18:40


All times are GMT -5. The time now is 02:46.


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