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.

Newcomers DBPro Corner / use of the POINT command in dbpro

Author
Message
jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 15th Oct 2012 19:39
Hi people.
I would like to return a number representing the colour under the mouse when I click it. I can't get it to work.
I know that point is relatively slow, but it is frustrating when commands don't seem to work! Can you help please?

cc as DWORD
sync on
set current bitmap 0
BOX 50,50,100,100
sync
repeat
if mouseclick()
cc=POINT(mousex(),mousey())
print cc
wait key
endif
sync
wait key
until spacekey()
end
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Oct 2012 23:01 Edited at: 15th Oct 2012 23:02
Don't know what exactly you're doing with that, but this here works:



TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th Oct 2012 12:31
Quote: "

"

Hi,OP, the error in your code (well, what glares at me is your SYNCing and WAIT KEY relationship. Since you put SYNC ON, you manually have to refresh the screen. So your problem is WAIT KEY is called before your next update. Consequently the PRINT cc statement will not actually show on the screen until after the WAIT KEY, meaning you'll see nothing the first iteration and you'll be 1 cycle behind visually than what you see physically - if it'll display correctly. Have a look at the following example on structuring your program more dynamically (The example only prints the colour's numeric value and not the R, G, B, or hex-value (since that example's been posted already):


Quote: "I would like to return a number representing the colour"

As you'll notice from my example, the numeric value is not much use for the human understanding of colour. I would recommend hex (because it is the most standardised way). If hex makes you uncomfy, try setting colours with the RGB() function and recieving them with RGBR(), RGBG() and RGBB().

Also, you really need to put your code in code snippets, like so:

btw: you can use the "lang=" tag to specify language if you want.

jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 18th Oct 2012 22:37
Thank you TheComet and nonZero.

Login to post a reply

Server time is: 2024-11-22 00:38:15
Your offset time is: 2024-11-22 00:38:15