May 20, 2024, 12:08:07 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Working with large bitmaps

Started by Egil, July 12, 2009, 06:28:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

I have in my posession a nice little piece of shareware called ShipPlotter. The program is able to load BMP and JPG files much larger than the client window, so only a small portion is shown at the time. To navigate within the picture, I hold down the left mouse button and drag the bitmap around.

Does anyone know how to do something similar with EB?
Support Amateur Radio  -  Have a ham  for dinner!

sapero

July 12, 2009, 08:10:48 AM #1 Last Edit: July 12, 2009, 08:17:13 AM by sapero
It's simple, just allocate five additional global variables (pos_x, pos_y, click_x, click_y, LeftDown) for each image, and respond to messages this way: (pos_x, pos_y must be signed)
@IDLBUTTONDOWN - save mouse position in click_x and click_y, set LeftDown to TRUE
@IDLBUTTONUP - set LeftDown to FALSE
@IDMOUSEMOVE - do nothing if LeftDown is not TRUE, else compute signed delta x and y: delta_* = @MOUSE* - click_*. Subtract delta's from pos_x and pos_y, ensure pos_* is in the valid range (0 <= pos_x <= image.width-visible.width), then callShowImage(win, image, type, pos_x, pos_y, visible_width, visible_height)

If you call SetCapture(hwnd) api inside @IDLBUTTONDOWN handler, you will be able to move the image even after the mouse leaves the window, but don't forget to call ReleaseCapture() inside @IDLBUTTONUP.

Egil

Support Amateur Radio  -  Have a ham  for dinner!