Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / mouseclick() in windows bug

Author
Message
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th Nov 2007 20:12
Hi, I've made a minesweeper and I want to put it into windows form. I tried it but there was an error with mouseclick(): 'Mouseclick()=3' didn't work. I tried it in a simple program that just printed the mouseclick() status but the same error appeared.

I want to know whether this is just me or does anybody else have this problem. If so, is there a fix? I have searched carefully but I haven't found anything. Here's the code:



To find out what happens, press the left button, then the right, then release the left button.

Thanks.


Nothing is impossible...
No really, it is.
aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 24th Nov 2007 20:14
nothing problems from me.

alus.portbb.com go there.
Quote: A book. I hate books. book is stupid. I know that I need codes but I dont know the codes -zenicanin14 the stupidest user in the world
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th Nov 2007 20:22
I'm using the uninhanced version of Dark Basic. That might make a difference?


Nothing is impossible...
No really, it is.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Nov 2007 01:15
That is very strange
I'm using v1.2 and I get the same problem
It works fine without the window

I tried adding in a WAIT 40 before syncing but it didn't help
Tried adding WAIT 40 after CLS didn't help
Removed SYNC ON and SYNC, didn't help

I can't get it to work

"You must be someone's friend to make comments about them." - MySpace lied.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Nov 2007 04:09 Edited at: 26th Nov 2007 07:19
I ran into this a while ago. Because I wanted that extra state, I had to work around the problem by combining mouseclick()=2 with with a key press .

[EDIT]
I came up with a solution - read down a few posts

Enjoy your day.
aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 25th Nov 2007 04:37
i don't have dbc, but may I suggest using different operators like
if mouseclick() > 2?
I don't know, but crazy stuff like that works for me sometimes.

alus.portbb.com go there.
Quote: A book. I hate books. book is stupid. I know that I need codes but I dont know the codes -zenicanin14 the stupidest user in the world
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 25th Nov 2007 13:45
Thanks for your comments guys. Unfortunately, I cannot use a susbsitute because it's a minesweeper clone and I want to make it as similar to the original windows one as I can get. I guess it's back to the full screen version for me then...


Nothing is impossible...
No really, it is.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Nov 2007 21:52
I don't remember a two-buttoned click in minesweeper?

I ripped all the minesweeper graphics for a clone but never got started, I could send you them if you like. I've even accounted for tessellation

"You must be someone's friend to make comments about them." - MySpace lied.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 25th Nov 2007 22:18
The two buttoned click was the one where it shows whether there was a mine in the surrounding 8 squares. Made the game a lot easier. You just clicked at random didn't you

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Nov 2007 23:00
it just shows a blank 9x9 on mine

"You must be someone's friend to make comments about them." - MySpace lied.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 25th Nov 2007 23:16 Edited at: 25th Nov 2007 23:17
left-click on a couple of squares. Then once you've got it opened up a bit, if you click with both buttons on an uncovered space, it will either uncover the touching squares or, if there's a mine in that area, do nothing. Then you know whether you can click or not. I'm not very good at explaining this am I?


EDIT: or, apparently, typing a word right

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Nov 2007 01:54
@Nano

Here's a function that'll return mouseclick 3 with 2 buttons in windowed mode.



Enjoy your day.
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 26th Nov 2007 04:24
Clever Latch, nice work!

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Nov 2007 07:20
Thanks SFSW.

Enjoy your day.
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 26th Nov 2007 13:47
There isn't a problem with it on my DB and I have the new version OBese87.

Very clever Latch.

NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 26th Nov 2007 17:33
Thanks Latch! Nice one!


Nothing is impossible...
No really, it is.
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 27th Nov 2007 10:59
using the following code I tested your theory and interestingly enough I found that in window mode it did not return anything but values of 1 and 2 as well and the middle button did not return any value either.
perhaps this was a bug that did not get caught until recently ?





normally it works like this -
if no button is pressed mouseclick will return a value of 0
if The left mouse button if clicked will return a value of 1
if The right mouse button if clicked will return a value of 2
if The middle mouse button if clicked will return a value of 4
if there is a fourth button it will return a value of 8
IF the left AND right buttons are pressed at the same time the return value will be 3
in fact, if any two buttons are pressed at the same time it will return the added values of both

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Nov 2007 16:49
DB doesn't even read a middle click (4) in windowed mode!
Why doesn't windowed mode work properly?

"You must be someone's friend to make comments about them." - MySpace lied.
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Nov 2007 17:43
@Latch:
I tried your code. It works... 30% of the time. Unfortunately your program relies on the user pressing one of the bottons just before the other, but that does not always happen (or it happens too fast for the compueter to pick it up).

I tried calling the function more often in my program. It did improve it but it didn't make much better. Here is a code snippet which shows what I am trying to explain. Notice that sometimes when you press both buttons there is a single line of one colour and then box of another, but sometimes, there is just one colour.



@OBese:
I would be very grateful to have those graphics, thank you.


Nothing is impossible...
No really, it is.
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 27th Nov 2007 19:06 Edited at: 29th Nov 2007 18:57
Here's a routine that simply uses the Windows user32.dll to retrieve mouse input. It detects both buttons and will return a 3 when both buttons are pressed. Works 100% reliably in Windowed mode also:



NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Nov 2007 23:10
I think it's time I got the darkbasic expantion pack...


Nothing is impossible...
No really, it is.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Nov 2007 23:19 Edited at: 27th Nov 2007 23:22
@SFSW
OOOOOHH
I should probably learn how to use dll's

Here's the graphics >>>

I changed the big smiley button to a mine

"You must be someone's friend to make comments about them." - MySpace lied.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Nov 2007 02:58 Edited at: 28th Nov 2007 03:45
@SFSW

I get no response at all. The value on the screen remains 0.
The function is in the user32.dll file - I don't understand why it won't work on mine. I've been looking for just that code in the win32 api too.... Any other tests I could do to see why this dll call isn't working?

@Nano

I think 1.2 has the enhancement pack, but I'm not sure if it will upgrade with the enhanced features if you didn't have it previously installed. Most likely it will. 1.2 is a pretty painless upgrade.

There's one other alternative without the enhancement pack. Do not use SET WINDOW ON. Instead, use the setup.ini file with the startup flag window=1.

In your program, use SET WINDOW TITLE and SET WINDOW LAYOUT etc.

This is for the completed exe and the ini file has to be in the same folder as the exe.

If you want to test it in script mode, set the windowmode=1 under settings.

The problem with the ini settings for windowed mode(at least on my comp) is that the window doesn't seem to be able to be moved or sized with the mouse, but the the mouse buttons work fine.

Enjoy your day.
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 28th Nov 2007 04:03
I don't know why it wouldn't work. I just tested it on both Vista and XP, both ran it just fine. Perhaps your system is returning a different value for the call? Try <>0 perhaps, or maybe different flag values to check. It's a standard mouse input address, so it should work fine. Are you using a unique input device/mouse?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Nov 2007 04:34 Edited at: 28th Nov 2007 04:59
Checked the leftclick... came back -3276 something. So checking <> 0 did the trick! Thanks! That's nice.

Enjoy your day.
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 28th Nov 2007 05:10
Ah cool, glad that's all it was!

NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th Nov 2007 17:35
@Obese:
Thanks alot, I'm sure these will come in handy...

@Latch:
Thanks for the advise, I'll give it a try.


Nothing is impossible...
No really, it is.

Login to post a reply

Server time is: 2025-06-04 00:38:14
Your offset time is: 2025-06-04 00:38:14