I have created some buttons and now I want to link tehm with a function. When I click a botton at this coordinates x=120 to x= 200, y=85 to =95 i want that the programm ends
I have created some buttons and now I want to link tehm with a function. When I click a botton at this coordinates x=120 to x= 200, y=85 to =95 i want that the programm ends
Is this DOS or windows? And, try http://msdn.microsoft.com and look up the mouse functions. basically what you're going for here is a loop inside your main (or a seperate function) that will keep on looping until that area is clicked. Then the program can return 0.
PHP and XML
Let's talk about SAX
It is Dos 0x0013
so im assuming the hex is an address of the hardware int for the mouse? so, basically work with something like this:
im not guaranteeing that is bug free, but that's the general ideaCode:int * mouseClick; &mouseClick=0x0013;//address of mouseClick int returnClick=??;//whatever the mouseClick address will hold when the mouse has been clicked while (*mouseClick!=returnClick) { .... } return 0; }
PHP and XML
Let's talk about SAX
If the problem simply is to shut down your program from a function or procedure,
there's a function for that.
I think it's called, exit();
And you type: exit(1); to exit your program, I don't remember what header you have to use for this one, but that shouldn't be to hard to figure out!
-We're living in a illusion!
-Ok, if that's what you think!
I've did it on my own take a lot of time and my source code is now not to understand but it works and this is what i want. exit(1); is in stdlib.h
The theory is simply enough.
When your mouse button is released(!) check whether you're in the given area (x0=120 x1= 200 y0=85 y1=95).
Warning: axis origin is on the top-left corner of the screen (y-axis increases downwards!).
Given your mouse coordinates (mouse_x, mouse_y), check for worst case (pseudo_code)
if mouse_x < x0 return;
else
if mouse_x > x1 return;
else
if mouse_y < y0 return;
else
if mouse_y > y1 return;
else
do_exit (quit the main program loop and exit)
That's not the best way, don't you think?my source code is now not to understand but it works and this is what i want
Code clean and live long!
Last edited by Carlos; 01-30-2003 at 07:52 AM.
[R]evolution!
Programming related articles, downloads, demos
I rewrite it so that I understand it.
I know that a not clean code will me my death.
Good idea!
Is it Assembly you're coding?
Take a look at my HP, you might find some ideas and sources.
For this case (mouse handling under DOS using BIOS ints in ASM) check this one:AsmMenu
[R]evolution!
Programming related articles, downloads, demos
That was a cool solution, to se if the user has cklicked on the button, of should I say hasn't clicked it!
Haven't seen it before! :-)
But just one thing, if you want to have more then 1 button, how do you do then, with your method?
I would rather advice:
if(x>x0
&&x<x1
&&y>y0
&&y<y1)
exit(0);
(Or terminate the program in some way)
-We're living in a illusion!
-Ok, if that's what you think!
Oups, looked at your code again, I'm an idiot I admit it! :-)
I don't know how I thougt, but something got a little wrong in my head for a minute there, as I said sorry!
-We're living in a illusion!
-Ok, if that's what you think!
When I said you should rather check whether the user has released the mouse button I meant "released after click" -> that's the way windows does, too.
Just check it out, press the mouse while over a menu or button, then move your mouse outside that area, and release it - nothing happens! And this behaviour is all right, as the user might change his mind (they do it all the time, that's why we get end-user complains).
For every button you set up a check function.But just one thing, if you want to have more then 1 button, how do you do then, with your method?
The possibility that the mouse cursor is inside a button region is probably less then being somewhere else on the UI - except the case your interface is full with buttons, but this should not be the case
It's better to check the way I presented, from performance side and coding as well. Performance is higher, as not all bounds are checked -> when the mouse coord is outside the rectangle the function returns without performing the remaining checks.
Please check my link for a functional example.
...
Oh, I've just seen your next reply
Nevermind, we are ok then, isn't it?
Last edited by Carlos; 01-30-2003 at 10:27 AM.
[R]evolution!
Programming related articles, downloads, demos
Yea, sure!
Didn't think about that your way is faster, I'm not programming ASM you know! :-)
I will deffinately use your way the next time, I write something like this! ;-)
-We're living in a illusion!
-Ok, if that's what you think!
Optimizing for speed is not a matter of programming language, it is "allowed" even in C++ .Didn't think about that your way is faster, I'm not programming ASM you know! :-)
You would probably be very happy if your OS would load in 2 seconds instead of 20, isn't it?
We make faster and faster hardware, and ... bigger and slower software. Hope this trend will change in the future.
I'd like some projects like this one:
http://www.menuetos.org/
Check it out, it's COOOOOL!!!!!!
[R]evolution!
Programming related articles, downloads, demos
Yea, that seams to be a cool thing, I can't say that I fully get how it works etc. But it seams to be cool anyway!
But it seams to be a kind of a dangerous application, I mean in the documentation, every second line, they write something like:
However Menuet CAN access the hard drive (not by default) and can do serious damage if improperly used (and even when properly used)
But it seams to be cool anyway, if I can get my old P120, working, perhaps I should try it!
-We're living in a illusion!
-Ok, if that's what you think!