Click to See Complete Forum and Search --> : Clickable Region Bitmap ...any ideas?


d_wzrdv_z
July 26th, 1999, 02:55 AM
Task: A picture of a machine containing clickable buttons, so you can click on a button and bring up a list of functions to assign to the button...
I've thought of having a weird shaped toolbar, but that wants the buttons to be square - these buttons can be any shape. It would be easy enough in a website, just use a hypermap, but in Visual C++....I'm a bit stumped. Any help much appreciated,
henOne@hushmail.com

<IMG SRC="http://www.geocities.com/SiliconValley/Bay/1542/Dee_Wiz.jpg">

d_wzrdv_z
July 27th, 1999, 03:07 AM
One of the many legends on this site, Dan you know who you are, has given me a few clues - so I should bother him anymore! He reckons I should make a mask, a transparent monochrome bmp with the buttons on it and somehow superimpse this over the picture of the phone. I have looked into the CBitmap button thing, but really its just a small part of a config program that will not be used much, so it doesn't have to be brilliant, but not too quick or dirty either. I understand your algorithm, just need a tad more clarification on what we have here: OK, obviously a dialog. The bitmap is either pasted on as the background or contained in a picture box. Then we have a mask. The mask is a second bitmap (?) which contains only the button regions to be clicked. Somehow the regions are converted to polygon lists. Each 'square', or set of points making up a square is assigned an ID. (In the rc2 file?) When a point on the dialog (or form) is clicked, a message is routed to the algorithm, which find which ID has 'caught' the message, at which point I do my stuff. I'm not sure how, but is this where the mask comes in - to superimpose the button over the bitmap....I'll answer this myself when its solved - anyone else?
...Clear as mud


\_|_|_|_/
oOOOOOo
(*^@ @^*)
| O |
\&_&/
__-__
/?;|;?\

D_WZRDV_Z

bubu
January 5th, 2004, 11:36 PM
I'm facing this problem also...
I want to make a game where it would generate a map.
This map is nothing more than shapes and I need to get these shapes to be clickable!!!
My guess is: Make a mask as you said, but make it with at least 256 colors and asign each shape a different color. The color would be the ID of each shape.

I'll work around it and if I gett he answer i'll be posting here...

bubu
January 5th, 2004, 11:56 PM
Look, I found this in Allapi.net. It might be usefull... It uses WinAPI to create Regions of any shape and detect if the mouse is over or not.... You just have to explore it (paste in a new project and execute):


Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function CreateEllipticRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim mRGN As Long, R As RECT, x As Long, y As Long
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Set the rectangle's values
SetRect R, 0, 0, 50, 100
'Create an elliptical region
mRGN = CreateEllipticRgnIndirect(R)
For x = R.Left To R.Right
For y = R.Top To R.Bottom
'If the point is in the region, draw a green pixel
If PtInRegion(mRGN, x, y) <> 0 Then
'Draw a green pixel
SetPixelV Me.hdc, x, y, vbGreen
ElseIf PtInRect(R, x, y) <> 0 Then
'Draw a red pixel
SetPixelV Me.hdc, x, y, vbRed
End If
Next y
Next x
'delete our region
DeleteObject mRGN
End Sub