Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   General Discussions (http://forums.winamp.com/forumdisplay.php?f=1)
-   -   Visual basic... (http://forums.winamp.com/showthread.php?t=196754)

squakMix 19th October 2004 00:09

Visual basic...
 
I'm using this code to detect right mouse up on a command button:

code:
Private Sub cmdTopLeft_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then MsgBox "Right Button released"
End Sub



I'm trying to make right click look the same as normal click on a cmd button, but with this the button doesnt physically look like it's getting pressed. Is there any way that I can make the button display it's buttonDown image?

yenerich 19th October 2004 02:56

What you have to do is to make that the rightclick trigger the click, i mean, the righclick should make the button is pushed, then you will get it looks like a normal click.

squakMix 19th October 2004 03:12

I need a specific set of things to happen on a right click.

CaboWaboAddict 19th October 2004 03:21

Let me see if I have the idea...

You want the button to depress when you right click just like it does when you left click.

You also want different events to fire so you can do different things for left and right clicks.

Is this correct?

squakMix 19th October 2004 03:22

Yes, exactly (sorry if it wasnt clear).

CaboWaboAddict 19th October 2004 03:24

I don't have my tools here - besides its getting late. I'll try to play with this a little tomorrow. I'll let you know if I come up with something.

edit : is it VB 6?

squakMix 19th October 2004 03:25

Ok... thanks for the help :)

(yep, vb 6.)

yenerich 19th October 2004 03:28

AFAIK a program must be intuitive, what means that has to works as windows uses to work, then the user could easily understand how to use it... then, using a rightclick in a button is quite strange... why use a RC in a button? %)

CaboWaboAddict 19th October 2004 03:31

I was wondering that too. I suggest if this is for others to use, that you document in detail any 'unusual' behavior like this.

yenerich 19th October 2004 03:36

However the solution is the same i put before: detect righclick, do something, THEN trigger the button click.

CaboWaboAddict 19th October 2004 03:40

If you just trigger the button click event at the end, then you will get:
left click => left event
right click => right event then left event.

He doesn't want the left event to happen in the second case. He just wants the button to appear depressed.

squakMix 19th October 2004 03:41

Quote:

Originally posted by yenerich
AFAIK a program must be intuitive, what means that has to works as windows uses to work, then the user could easily understand how to use it... then, using a rightclick in a button is quite strange... why use a RC in a button? %)
It's for a game.

Edit: I'm thinking now, I could just use something like:

code:
Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
Command1.Picture = LoadPicture("c:\MyPicture.jpg")
ElseIf Button = vbLeftButton Then
'Display anoter picture maybe?
End If
End Sub



...and replace it with an image of the button pressed ( a screenshot taken).

well, if there is text on the button that wont work too well... Maybe I will use your idea.

Btw: How would I trigger click? Isnt the click sub only what happends when it is clicked?

CaboWaboAddict 19th October 2004 03:53

Its not good programming practice, but you can *cough* call the click event yourself.

edit: why not try making your own ActiveX control? Its not very difficult at all and then you can define all of the button's behavior.

squakMix 19th October 2004 03:57

Eh. :down: I want to steer away from stuff like that.

Same reason my code isnt backed with goto statements :p

CaboWaboAddict 19th October 2004 04:01

What about the ActiveX? Nuttin' wrong with that.

yenerich 19th October 2004 04:01

This is the code to trigger the left click:

code:

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
Dim pt As POINTAPI, curX As Long, curY As Long
Dim dstX As Long, dstY As Long
ScaleMode = vbPixels
pt.X = Command2.Width / 2
pt.Y = Command2.Height / 2
ClientToScreen Command1.hwnd, pt
dstX = pt.X * 65535 / ScaleX(Screen.Width, vbTwips, vbPixels)
dstY = pt.Y * 65535 / ScaleY(Screen.Height, vbTwips, vbPixels)
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE + _
MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, dstX, _
dstY, 0, 0
End If

End Sub


squakMix 19th October 2004 04:07

Quote:

Originally posted by CaboWaboAddict
What about the ActiveX? Nuttin' wrong with that.
:blah:

CaboWaboAddict 19th October 2004 04:09

OK serious question...

I suggest using an ActiveX and you react to it as if its noob shit. Why?

squakMix 19th October 2004 04:21

nono, it's nothing. Somewhat of a personal joke I guess.

btw: I dont know how to make/use activeX.

yenerich 19th October 2004 16:56

But an activex is finally just some code, so if you find a way to achieve it, its the same using an activex or directly the code.

ActiveX is some kind of library (something like a dll, but Object Oriented).

CaboWaboAddict 20th October 2004 19:46

1 Attachment(s)
Quote:

Originally posted by yenerich
But an activex is finally just some code, so if you find a way to achieve it, its the same using an activex or directly the code.

ActiveX is some kind of library (something like a dll, but Object Oriented).

Not quite, you can do a lot of things really easily using an ActiveX that would be very cumbersome using in-line code.

Squak, I made a demo in VB6 of what you wanted using an ActiveX DLL that I made up. The whole thing took about 15 minutes from start to finish (including a phone interruption:D).

I used a button but you could use an image control instead and place your own images in place the exact same way that I did with the text. Hope this helps.

Nolita 10th November 2004 15:10

I don't want to be super snarky or anything, as I myself am only just starting to learn programming languages, but have you considerred buying a book? I have Core's book for learning Visual Basic 5. It's a really big book, and like I said I'm just starting out. I only came here because I'm trying to see how visual basic could be used to make visualisations for winamp. I'm probably being silly, but the answers you got to this question really are answerred in this book I have, and because it's for an older version, I got it dirt cheap, like five bucks.

My point is, you don't have to shell out big bucks to get the info you need. And I think a book would actually save you time, because if there's something you can't figure out, flip to the back and look it up in the index. As opposed to asking a question here, then waiting for someone to answer, and hoping that what they came up with works.

I just realized I probably sound all preachy. I'm not trying to be, I just think you could save a ton of time with a book is all.

mysterious_w 10th November 2004 15:17

There's only one thing I know how to do in VB, and that's this Word Macro

code:

do until 1 = 2
beep
loop


:p

CaboWaboAddict 10th November 2004 15:24

squakMix, I agree with the idea of buying a book... You can get books on VB6 real cheap now.

BTW: Did you try the code I posted?

squakMix 10th November 2004 23:23

Eh, I figured out a work around

Bizzeh 12th November 2004 09:47

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
if Button = vbRightButton Then
'call the button with left, instead of right
'and pass on the other 3 params for good measure
Command1_MouseUp vbLeftButton, Shift, X, Y
else
'left button stuff

end if
end sub


All times are GMT. The time now is 10:19.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.