|
-
July 26th, 1999, 02:55 AM
#1
Clickable Region Bitmap ...any ideas?
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,
[email protected]
<IMG SRC="http://www.geocities.com/SiliconVall...42/Dee_Wiz.jpg">
-
July 27th, 1999, 03:07 AM
#2
Re: Clickable Region Bitmap ...any ideas?
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
-
January 6th, 2004, 12:36 AM
#3
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...
All consequences are eternal in some way.
-
January 6th, 2004, 12:56 AM
#4
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):
Code:
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: [email protected]
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
All consequences are eternal in some way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|