I'm trying to make a program that has a world map on it and when you click on a continent you get some basic information about that continent in a textbox. However I am trying to figure out how best to do this if all continents were perfectly square it would be oh so easy.

I've tried individual images of each continent with transparent backgrounds but you can still click on the transparent bits and had issues with overlap. Tried using an image for the form background and then seeing where the user clicks but it seems it would be insane to map coordinate ranges to each continent. Also tried different colours for each continent and blue for water and testing for pixel colour at cursor but that ran into memory issues.

Hoping there is a lovely simple solution (other than not using VB) that I'm just not seeing, any ideas?

I can't imagine why you would run into memory problems by just using different colours. Using the same colour for everything or a different colour per area should make no difference to the amount of memory used. For that matter, loading a picture with thousands of different colours into the picturebox makes no difference. Can you post some code?

Edited 3 Years Ago by Reverend Jim

I copied the pixel colour at cursor from the web

Private Sub PictureBox4_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseMove
    Dim TempBitmap As New Bitmap(PictureBox4.BackgroundImage)
    Dim MyColor As Color
    MyColor = TempBitmap.GetPixel(e.X, e.Y)
    Label1.Text = "Pixel x=" & e.X & ", y=" & e.Y & ", color=" & MyColor.ToString
End Sub

and I didn't spot that it doesn't dispose of the TempBitmap so it was quickly eating into memory, fixed that so it could work but it would mean a rather boring map I would rather use a satelite/real world looking map rather than big blocks of different colours.

Ah found the solution, using an invisible (mask) image with blocks of solid colour over another graphically pretty image and detecting the colour at the mouse pointer on the invisible image seems to work :)

This question has already been answered. Start a new discussion instead.