Right mouse button detecting

Little example:
I have a treeview with shurtcut menu's
I want to popup the shortcut menu on a rightclick on a node

now i use the mosemove method so i now wich button is pressed but i want to use the node_click method and still now wich button is pressed

Can anybody help me out how to read mouse actions without the normal method parameters?
LVL 2
telebasicsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caraf_gCommented:
I'm afraid the answer is not going to be deadly simple, but I'm going to assume that you're not unfamiliar with the TreeView, so instead of written out code, I'll point you in the right direction.

First of all, in the MouseDown, keep the information of the button clicked, and the X and Y position

Private mintButtonClicked As Integer
Private mdblXClicked As Double
Private mdblYClicked As Double

YourTreeView_MouseDown(...Button, X, Y, etcetera)
mintButtonClicked = Button
mdblXClicked = X
mdblYClicked = Y

Now in the Node_Click procedure you can use mintButtonClicked and the other variables. You could use mdblXClicked and mdblYClicked in the .HitTest procedure, and so on and so forth.

Hope this helps

Pino
0
GordonpCommented:
Why do you want to use NodeClick event.
Is it because you want the node the mouse is over.

If you stick with the MouseMove/ MouseDown event you can still get hold of the node thats been clicked on using the HitTest Method.

Private Sub TreeView1_MouseDown(Button as Integer, Shift as Long, X as Single, Y as Single)

Dim OverNode as Node
Set OverNode = TreeView1.HitTest(x,y)

If OverNode is Nothing then
  'Mouse Pointer not Over any node

else
  'Mouse Pointer is over OverNode

end if

Alternatively use the SelectItem property if you want the currently selected node.

If you have another reason for wanting to use the NodeClick event then so bit it but this method avoids API calls and sticks to pure VB

Hope this helps

Gordon

0
telebasicsAuthor Commented:
Your answer was correct for this example but i really asked for an way to detect it without using the normal method
The same goes for gordonp's answer, they are both good ideas (didn't think of it myself) and i hadn't seen the hittest method yet.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

PiNCommented:
I don't get your point, telebasic...if there is no such think like detecting the mouse button, then use the mouse_up,mouse_down whatever goddamnit...you can certainly try to detect the mousebutton while hangin' around in nodeclick, but why would one want to reinvent the wheel...
The answers given above make perfect sense and are btw the recommended ways to do that.

PiN
0
caraf_gCommented:
"a way to detect it without using the normal method"

Sorry, there is none.... I'm afraid VB has its limitations, and this is one of them...
0
telebasicsAuthor Commented:
Well i am an ex Turbo Pascal programmaer and i had to read interrupts to see what the mouse was doing so, it is simpler like this though but less options.
Giving the points to caraf_g for the nice example how to use the limitations
sorry, GrodonP your answer as as good as his but he was first
0
caraf_gCommented:
Thanks!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
caraf_gCommented:
:-( The fact that VB has limitations is not my fault, so why a "C"?
0
telebasicsAuthor Commented:
Well my problem isn't realt solved is it?
And no it isn't your fault, but i still can't detect the mouse whenever i want to.
0
caraf_gCommented:
Your problem isn't solved, but you did get a correct and helpful answer. Of course you are entitled to grade the answers you receive as you see fit, but I would appreciate it if you could read the following discussion I had with Linda about the matter.

 http://www.experts-exchange.com/jsp/qShow.jsp?ta=commspt&qid=10220959  

Regards

Pino

Anyway - still thanks for the points ;-)
0
telebasicsAuthor Commented:
OK i have read the discussion, but remember (i am an expert to, in other fields that is) when i except an answer that meens i am satisfied not that i think the answer is bad. I grade from the four option's i have (they have strange name's i agree) i give an A when my answer is answered and giving a great URL or tool or i really learned something from it.
I give a B when my question is answered and i learned a little bit
I give a C when an answer is given and the brought my attention to something i didm't notice yet
I give an D when an answer is given and just that.
All grade are possitive, otherwise i wouldn't have given you any points atall.

I think that's what the grades are for, if i think the answer sucks i wouldn't accept it at all.

Sorry, ;-)
0
telebasicsAuthor Commented:
Addition,

sorry just three option
0
PiNCommented:
Looking at your definition of grades you should have given at leat a B to caraf_g.
I think you learned a little bit.
(By the way: there is no real difference in your definition of B and C. You should perhaps think it over again.)
No offense meant.

PiN
0
caraf_gCommented:
Thanks PiN

telebasics,

Like I said, you're free to grade the answer any way you see fit, so no offence taken. In the same vein, I am free to ignore any questions I see fit, for example questions that are rated less than the standard minimum amount of points (50) or on which I feel I run the risk of receiving a bad grade.
0
telebasicsAuthor Commented:
I still don't think i gave a bad grade i gave an AVERAGGE not BAD.

There is a big difference between B & C bringing someones attention to a method or control is something different than learning something ( i know how to use controls but still learn everyday ) in B i ask for the answer for my problem. in C i accept an answer that doesn't answer my problem but answers the question.

I KNOW there are way's doing that.
But they are not default to VB so...
If i create a general dll wich reads the current mouse pos. i can ask that DLL what my mouse is doing any given time...Just create a dll in C and DONE.
If he would have given me a DLL doing just that he would have gotten a A if he tould me just the way how a B saying it is NOT POSSIBLE is not a GREAT or GOOD answer!!!!!!!!!!!!!!!!!!!
Its Acceptable

Remeber i am not an newbie to programming, maybe to Experts-Exchange and VB.

NOTHING is IMPOSSIBLE with programming.
So that's why people give C's when you say it can't be done with VB
0
caraf_gCommented:
"NOTHING is IMPOSSIBLE with programming."? You can't seriously believe that. And if you do I challenge you to come up with a fast and efficient method to solve the travelling salesman problem.

Yes, of course, I could have given you reams of convoluted code using the Windows API to determine the current mouse location (O, no, you don't need any C for that), and then translate that into a node in your TreeView. IMHO, that solution is far less desirable, efficient, or elegant as the solution I proposed. The same goes for C dlls. But, let's just agree to disagree on this account.
0
PiNCommented:
Oops, you are quite excited about all this, telebasic...

As this is the VB section, i guess most people expect hints to solve their problems in VB.
There is not way to solve your problem in VB in a reasonable frame of time and/or effort (You CAN do it via API callbacks).

I'm glad to hear that you are such a good programmer but, in that case, why do you come across with strange questions like this (which do not even make sense, because there are opportunities that solve your problem just in different ways.)
Remember: a good programmer tries to SOLVE problems, not CREATE problems where there are none.
If you get multiple orgasms by making api-calls or code c then do so, but do not inadequatly reduce the grade just because people give you more elegant and easy (and most likely more reliable) ways to solve your problem, because thats what we're here for.
If you'd like something in c, then post in the c section.

What you described above is not a problem, it's a strange idea with no justification. Programmers should not concentrate on that.

btw nobody said you're a newbie. You seem to be pretty afraid that somebody might think so.

;-)  

Sorry, but I'm LOL. ;-)
0
PiNCommented:
I'm leaving this strange discussion now.

Good day everyone ;-)
0
caraf_gCommented:
Have a nice day PiN! ;-)
0
PiNCommented:
CU caraf_g ;-)
0
telebasicsAuthor Commented:
Just saying that base for an answer is C and if provided more than just a answer i reward you by giving a B and if you give me miltiple orgasms you will get an A

Thats that,

Using Pascal 7.0 i am used to using API call backs, since i am now using Vb 6.0 since a week this options seems to be no langer availible to me. Ok maybe i should have taken up vc but i didn't (so shoot me). I asked for something to be abel to use it again, i didn't get it...
That's the point. So my normal grade stands, a C

Ok there are way's to work around this problem, but the problem still exists.

I understand that if someone is used to programming in vb this is not a problem. But for me it is.

This discussion isn't about if using a dll api callback was the sollution, its about the grade.

He gave a workaround i didn't notice yet OK thanks, he told me what i wanted isn't available in VB. OK stop looking. But my problem is still there whats excellent about it? what's Good about it?
It's enough so i gave him the points.

Be glad i didn't rejected the answer. I know being an expert getting C in your answer list sucks but I would be lying if i give you an EXCELLENT. It just isn't.
If you didn't want the points just say so i would have given them to gordonP

By the way where here to solve problems NOT to get good grades!
0
caraf_gCommented:
"By the way where here to solve problems NOT to get good grades"

Funny, but true. On the other hand though I do like to see my efforts appreciated. Especially since I bothered looking at this question at all. With merely 25 points allocated to it most experts would simply ignore it.

You asked a question and you got exactly what you asked for. You got a good, simple and elegant solution. What more did you want? A post-doctoral essay?
0
caraf_gCommented:
PS - I actually would prefer for my answer to be rejected rather than given a bad grade. If you weren't completely satisfied with my answer, why didn't you ask for more information?
0
telebasicsAuthor Commented:
More information about "It is not possible"? And again i disagree it is a bad grade

Maybe we should leave this deiscussion alone, you think a c is bad I think its acceptable.

It is now a matter of differnd views on that single grade.

Still wonder what the problem is with having a "Average" for this one single answer
0
PiNCommented:
Can I disable this notification email ? The turbo-pascal guru is still feeding my inbox.

;-)
0
caraf_gCommented:
Never mind. Like you said, we don't agree. You've are entitled to your opinion, and I'm entitled to mine. So let's leave it at that.

I don't think I'll bother answering more of your questions though, no offence.

<caraf_g crawls into the corner, whining>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.