Function call order
VSM_WF_GET_WIDTH

Returns block width.

arg1: Block handle
arg2: Current character width

 

case VSM_WF_GET_WIDTH:

{

  int x = (int)lParam;

  return (LPSTR)(23 * x);

}

VSM_WF_GET_HEIGHT

Returns block sizes packed as LOWORD (block width); HIWORD (block height).

arg1: Block handle
arg2:
LOWORD: current character width; HIWORD:current character height

 

case VSM_WF_GET_HEIGHT:

{

  int y = HIWORD(lParam);

  int x = LOWORD(lParam);

  return (LPSTR)MAKELPARAM(23 * x, 6 * y);

}

VSM_WF_WINDOW_STYLES

Gets the block window style. The styles correspond to the description of the CWnd::CreateEx function.

arg1: &style
arg2:
hDC

 

case VSM_WF_WINDOW_STYLES:

{

  DWORD* flags = (DWORD*)wParam;

  DWORD* exFlags = (DWORD*)lParam;

  // *flags &= ~(WS_CAPTION);

  return (LPSTR)true;

}

VSM_WF_CREATE_WINDOW

After getting the styles, Embed creates a block window using the CWnd::CreateEx function. Immediately after the block window is created, Embed invokes the Window function with arguments:

HWND: Block window handle
arg1: Block handle

At this stage, the provided block window handle should be stored in the block-associated data structure. You can customize the block window—for example, change its title—or create child windows using the provided handle as a parent window handle.

 

case VSM_WF_CREATE_WINDOW:

{

  HWND hParent = h;

  Display_INFO* pi =
  (Display_INFO*)vissimRequest(VR_GET_BLOCK_PARAMS,
  wParam, 0);

  pi->hwnd = h;

  SetWindowText(pi->hwnd, "New Title");

  return (LPSTR)true;

}

 

As shown above, the identifier Display_INFO defines the user block data structure.

Embed then tries to resize the block window due to Windows mechanics. In this case, Embed resends the VSM_WF_GET_WIDTH and VSM_WF_GET_HEIGHT requests again.

VSM_WF_RECTANGLE

Once a block window is inserted in the diagram, the block plotting function from Embed uses the VSM_WF_RECTANGLE request to provide the exact window sizes to add-on module.

arg1: width
arg2:
height

The parameters should be stored within the add-on module for a subsequent printing call, if it is needed.

VSM_WF_RECTANGLE is also sent before printing.

 

case VSM_WF_RECTANGLE:

  // This message is sent right before
  VSM_WF_PRINT_WINDOW, thus the values stay correct

  nWidthForPrinting = wParam;

  nHeightForPrinting = lParam;

  break;

 

VSM_WF_RECTANGLE, VSM_WF_PLOT_WINDOW, VSM_WF_SELECT_WINDOW

Immediately after VSM_WF_RECTANGLE, Embed sends either:

      A pair of requests VSM_WF_PLOT_WINDOW and VSM_WF_SELECT_WINDOW

      VSM_WF_PRINT_WINDOW

The above requests have similar arguments:

HWND: parent’s handle
arg1: Block handle
arg2: Device context for painting (hDC)

The add-on must paint the content of the windows as a response to the VSM_WF_PLOT_WINDOW request. If the block has been selected in Embed, it is highlighted by changing the block background color. However, if the block created by the add-on covers the entire area of block window, you  must update the block window as a response to VSM_WF_SELECT_WINDOW.

 

case VSM_WF_PLOT_WINDOW:

{

  Display_INFO* pi =
  (Display_INFO*)vissimRequest(VR_GET_BLOCK_PARAMS,
  wParam, 0);

  HDC = (HDC)lParam;

  << some plotting using h, hdc, and pi >>

  return (LPSTR)true;

}

VSM_WF_RECTANGLE and VSM_WF_PLOT_WINDOW

During simulation, Embed sends two requests VSM_WF_RECTANGLE and VSM_WF_PLOT_WINDOW on each simulation step.

VSM_WF_DESTROY_WINDOW

Before destroying the block window, Embed sends the VSM_WF_DESTROY_WINDOW request with arguments:

HWND: Block window handle
arg1: Block handle

In response, the add-on must remove everything that uses the block window as a parent window. Also, the block widow handle within the add-on should be changed to NULL. The block window itself is destroyed by Embed.

 

case VSM_WF_DESTROY_WINDOW:

{

  Display_INFO* pi =
  (Display_INFO*)vissimRequest(VR_GET_BLOCK_PARAMS,
  wParam, 0);

  pi->hwnd = NULL;

  return (LPSTR)true;

}

VSM_WF_REORG

If you change settings that affect the entire diagram, such as the font or the current magnification, the add-on receives the VSM_WF_REORG request with arguments:

arg1: Block handle
arg2: LOWORD: current character width; HIWORD:current character height