Message

Int_GetEvents, Int_GetMouseClickSubPixelPos, Int_GetMousePos, Int_PostMessage, Int_PostMouseMessage, Int_RegisterWindowForKeyDown, Int_WaitForEvent, Int_WaitForMouseEvent, MAKELPARAM

Int_GetEvents

Description 

 Int_GetEvents(
   dword *lpKeyCodes,
   int  number
);

This function checks the keyboard and mouse whether specified keys or buttons are pressed. If they are pressed the function returns their code. Key codes are doublewords. It is necessary to engage the Enable_Interrupt_InScript function before and after the Int_GetEvents function is called. Please see the example.

Parameters

dword *lpKeyCodes

Pointer to the list of keys you want to check. The list of keys is an array of DWORDs. One keycode is made by bitwise OR operation between key constant (for characters and numbers their ASCII code, for special keys their constants) and, optionally, additional key constant (VK_SHIFT,VK_CTRL or VK_ALT). When you want to clear the inner message buffer set pKeys=NULL.

int number

Number of keycodes in the list.

Return Values

If a pointer to a list of keys is invalid, the function returns FALSE.

   int      x, y;
   int      xfin,yfin; 
   dword    key, keys[10];
   keys[0] = VK_LBUTTON;
   keys[1] = VK_ESC;
   Enable_Interrupt_InScript(1);
   while(key != keys[1])
   {
      key = Int_GetEvents(keys, 2);      
      if(key == keys[0])
      {
         Int_GetMousePos(&x,&y);                   
         xfin=x+50; yfin=y+50;
         Int_DrawLine(LINE_FREEPREDRAW,RGB_BLUE,0,0,0, &x, &y, &xfin, &yfin, 2);
      }
   }
   Enable_Interrupt_InScript(2);

Note

See Return Values in the Int_WaitForEvent function for key and mouse constants. The Int_GetEvents function is not waiting for the key (or mouse button) being pressed (as opposite to Int_WaitForEvent) so the function must be called in the loop when you want to check the keyboard or mouse input permanently.

See Also 
Int_DrawCircle

Int_GetMouseClickSubPixelPos

Description 

int Int_GetMouseClickSubPixelPos(
   double *Int_DblMouseX,
   double *Int_DblMouseY
);

Waits for the user to click in the current image. This function returns the position in the image coordinates, but detects the cursor position in the current zoom factor (sub-pixel resolution).

Parameters

double *Int_DblMouseX

Pointer to variable that will receive x coordinate of mouse click.

double *Int_DblMouseY

Pointer to variable that will receive y coordinate of mouse click.

Return Values

int

Returns 0 when successful, nonzero result when user aborted the function.

See Also 
Int_GetMousePos

Int_GetMousePos

Description 

 Int_GetMousePos(
   int *lpX,
   int *lpY
);

This function retrieves the mouse coordinates of the current position in the picture window.

Parameters

int *lpX

Variable is filled with the current x coordinate.

int *lpY

Variable is filled with the current y coordinate.

Return Values

The function returns x (LOWORD) and y (HIWORD) coordinates of a picture window packed in DWORD value.

See Also 
Int_PostMessage

Int_PostMessage

Description 

 Int_PostMessage(
   int  iEvent,
   int  iParam
);

This function posts a message to a window's message queue. See the example below.

Parameters

int iEvent

Keystroke.

int iParam

Additional keystroke data.

Return Values

Unused.

// Int_PostMessage example - shows how to simulate clicking primary mouse button.
dword   keys[2], key; 
int     x_start, y_start;
int     width, height;
char    buf[256], buf1[256];
long    coor;  
SetCommandText("Working...");
strcpy(buf, "   NIS-Elements API Example - Int_PostMessage\tPress primary mouse button to draw a rectangle with fixed center.\tPress ESC to stop drawing.   ");
strcpy(buf1, "   Drag the rectangle from the center, release mouse button to finish drawing.");
Int_CreateTextWindow(buf,0,RGB(0,0,128),RGB_WHITE,100);  
keys[0] = VK_ESC;
keys[1] = VK_LBUTTON;
while(TRUE)
   {
   key = Int_GetEvents(&keys,2);
   if(key == keys[0]) break;
   if(key == keys[1])
   {
   Int_CreateTextWindow(buf1,0,RGB(0,0,128),RGB_WHITE,100);  
   Int_GetMousePos(&x_start, &y_start);
   coor = MAKELPARAM(x_start, y_start);
   Int_PostMessage(VK_LBUTTON, coor);
   Int_DrawRectangle(RECT_FIXEDCENTER, RGB_DEFAULT, &x_start, &y_start, &width, &height, TRUE);
   Int_CreateTextWindow(buf,0,RGB(0,0,128),RGB_WHITE,100);  
   }
   }
Int_CloseTextWindow();
// Clear temporary drawings.
// If this macro should run on both color and gray system, it should ask,
// which of functions ViewColor or ViewGray exists.
if(ExistProc("ViewColor")) ViewColor();
else ViewGray();

Note

The string can be defined by the sprintf function or simply like a constant, to mark the tabs use /t symbol.

Int_PostMouseMessage

Description 

 Int_PostMouseMessage(
   int  Int_Event,
   int  Int_Coor,
   int  Int_DestinationWindow
);

This function posts a mouse message to a window's message queue. See the example below.

Parameters

int Int_Event

The low-order word specifies the mouse message to post. The value can be only one of the following values.

1

Post message indicating left button was pressed.

2

Post message indicating right button was pressed.

5

Post message indicating left button was double-clicked.

6

Post message indicating right button was double-clicked.

1

SHIFT key is pressed.

2

CTRL key is pressed.

4

ALT key is pressed.

int Int_Coor

The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.

int Int_DestinationWindow

Identifier of the destination window.

MOUSE_PIC_VIEW

Post message to the picture window.

MOUSE_MAIN_WINDOW

Post message to application main window.

MOUSE_PICVIEW_PICTURE

Post message to the picture window and transform coordinates from image coordinates to view coordinates.

See Also 
Int_PostMessage

Int_RegisterWindowForKeyDown

Description 

 Int_RegisterWindowForKeyDown(
   int *Int_Handle,
   int  Int_Enable
);

This function enables the user to register a window to receive input from keyboard and mouse (WM_KEYDOWN and WM_MOUSEWHEEL).

Parameters

int *Int_Handle

Handle to a window.

int Int_Enable

Window registration.

0

unregister

1

register

Return Values

UM_KEYDOWN /*33769*/

UM_MOUSEWHEEL /*33773*/

Int_WaitForEvent

Description 

 Int_WaitForEvent();

This function is waiting until some key or mouse button is pressed and returns its value. The list of all keys and mouse events are described bellow.

Return Values

This function returns the value of pressed key or mouse button. The return value for numbers is their ASCII code, for letters the return value is the ASCII code of the uppercase version of the pressed key. Other possible values are listed below.

VK_RETURN (13)

Return key

VK_ESC (27)

Escape key

VK_BACK (8)

BackSpace key

VK_TAB (9)

Tab key

VK_F1 (112)

F1 key

VK_F1 (112)

F1 key

VK_F2 (113)

F2 key

VK_F3 (114)

F3 key

VK_F4 (115)

F4 key

VK_F5 (116)

F5 key

VK_F6 (117)

F6 key

VK_F7 (118)

F7 key

VK_F8 (119)

F8 key

VK_F9 (120)

F9 key

VK_F10 (121)

F10 key

VK_F11 (122)

F11 key

VK_F12 (123)

F12 key

VK_ADD (107)

+ key

VK_SUBTRACT (109)

- key

VK_UP (38)

Up key

VK_DOWN (40)

Down key

VK_LEFT (37)

Left key

VK_RIGHT (39)

Right key

VK_PGUP (33)

PgUp key

VK_PGDN (34)

PgDn key

VK_HOME (36)

Home key

VK_END (35)

End key

VK_LBUTTON (1)

Primary mouse button

VK_RBUTTON (2)

Secondary mouse button

VK_LBUTTONDBLCLK (5)

Primary mouse button double click

VK_RBUTTONDBLCLK (6)

Secondary mouse button double click

//   Int_WaitForEvent example - the system is waiting for input and checks, if you have pressed End button or have not.
int     key;
char    buf[256]; 
SetCommandText("Int_WaitForEvent example. Working...");
strcpy(buf, "   NIS-Elements API Example - Int_WaitForEvent\tPress END key to continue.   ");
Int_CreateTextWindow(buf,0,RGB(0,0,128),RGB_WHITE,100);  
Int_SetFocus(WINDOW_MAIN);           
wait:
key = Int_WaitForEvent();
if(key == VK_END)
   WaitText(1.,"The End key has been pressed.");
else
   {
   WaitText(1.,"The End key has not been pressed.");             
   goto wait;
   }
Int_CloseTextWindow();

See Also 
Int_GetEvents

Int_WaitForMouseEvent

Description 

int Int_WaitForMouseEvent(
   int  Int_Event,
   int  Int_Timeout,
   double *Int_DblMouseX,
   double *Int_DblMouseY
);

This function waits for the specified mouse event (VK_LBUTTON, VK_RBUTTON, VK_LBUTTONDBLCLK, VK_RBUTTONDBLCLK).

Parameters

int Int_Event

The low-order word specifies the mouse message to post. The value can be only one of the Post message values. The high-order word specifies the special (CTRL, ALT, SHIFT) keys state. The value can be any combination of the SHIFT/CTRL/ALT values:

1

Post message indicating left button was pressed.

2

Post message indicating right button was pressed.

3

Post message indicating right or left button was pressed.

5

Post message indicating left button was double-clicked.

6

Post message indicating right button was double-clicked.

1

SHIFT key is pressed.

2

CTRL key is pressed.

4

ALT key is pressed.

int Int_Timeout

The timeout [s] which the function waits for user action.

0

The function waits forever.

double *Int_DblMouseX

Pointer to variable that will receive x coordinate of mouse click.

double *Int_DblMouseY

Pointer to variable that will receive y coordinate of mouse click.

Return Values

int

Post message indicating pressed key

0

When the user pressed ESC key.

-1

When the user does not respond within the interval.

MAKELPARAM

Description 

 MAKELPARAM(
   int  Int_LoInt,
   int  Int_HiInt
);

This function creates a LONG value from two INT values.

Parameters

int Int_LoInt

Specifies the low-order word of the new long.

int Int_HiInt

Specifies the high-order word of the new long.

Return Values

This function returns a LONG value made from two INT values.

See Also 
Int_PostMessage, LOWORD, HIWORD, LOBYTE, HIBYTE