Hey everybody!

I recently added menu commands to zoom in/out a document. For example, there is an option to Zoom 33%, 50%, 100%, 200%, 400%. Although this works fine I've got two problems with this:

1) For each zoom 33%, 50%, etc. I have defined a IDM_ZOOM_xx command which is part of my menu resource. These messages are in turn processed by the WM_COMMAND message individually. What I'd rather do is process one message (say WM_ZOOM) with a parameter that defines the zoom percentage. Can I do this through a menu, or do I have to break it down into several different messages like I am?

2) Ultimately, the Zoom message is passed to a document child window where the real processing happens. So I'd rather the menu send the message to the child window instead. Is that possible?

Thanks for any insight

Posted on 2002-05-17 13:13:26 by chorus
edit: I've explained it with ZOOM_* as messages, but should have been IDs. Doesn't matter though..

1) A menu item can have a command ID, but no parameters. However you can use a range of messages:

ZOOM_BASE equ 1000 ; some resource ID

ZOOM_100 equ ZOOM_BASE+2
ZOOM_200 equ ZOOM_BASE+3
ZOOM_400 equ ZOOM_BASE+4


ZOOM_BASE is the base value of all messages
ZOOM_MAXRANGE is the maximum value for all zoom messages. Do not use any other values inside that range for other menu items.

Then when processing the messages:

mov eax, uMsg
; zoom message
sub eax, ZOOM_BASE
; eax is index of zoom menu option now

You can use this index to look up the zoom value for example:

zoomArray dd 33,50,100,200,400
to look up:
mov eax, [zoomArray][4*eax]

2) If it's a MDI app, there's some message (forgot which) to get the active child window. When the message is sent to the main window, just get the active child window and forward it.

Posted on 2002-05-17 13:23:43 by Thomas