Int_GetEvents, Int_GetMouseClickSubPixelPos, Int_GetMousePos, Int_PostMessage, Int_PostMouseMessage, Int_RegisterWindowForKeyDown, Int_WaitForEvent, Int_WaitForMouseEvent, MAKELPARAM
Description
Int_GetEvents( dword *lpKeyCodes
, intnumber
);
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
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 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
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
See Also
Int_GetMousePos
Description
Int_GetMousePos( int *lpX
, int *lpY
);
This function retrieves the mouse coordinates of the current position in the picture window.
Parameters
Return Values
See Also
Int_PostMessage
Description
Int_PostMessage( intiEvent
, intiParam
);
This function posts a message to a window's message queue. See the example below.
// 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.
Description
Int_PostMouseMessage( intInt_Event
, intInt_Coor
, intInt_DestinationWindow
);
This function posts a mouse message to a window's message queue. See the example below.
Parameters
See Also
Int_PostMessage
Description
Int_RegisterWindowForKeyDown( int *Int_Handle
, intInt_Enable
);
This function enables the user to register a window to receive input from keyboard and mouse (WM_KEYDOWN and WM_MOUSEWHEEL).
Parameters
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.
Return key | |
Escape key | |
BackSpace key | |
Tab key | |
F1 key | |
F1 key | |
F2 key | |
F3 key | |
F4 key | |
F5 key | |
F6 key | |
F7 key | |
F8 key | |
F9 key | |
F10 key | |
F11 key | |
F12 key | |
+ key | |
- key | |
Up key | |
Down key | |
Left key | |
Right key | |
PgUp key | |
PgDn key | |
Home key | |
End key | |
Primary mouse button | |
Secondary mouse button | |
Primary mouse button double click | |
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
Description
int Int_WaitForMouseEvent( intInt_Event
, intInt_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_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:
Post message indicating left button was pressed. | |
Post message indicating right button was pressed. | |
Post message indicating right or left button was pressed. | |
Post message indicating left button was double-clicked. | |
Post message indicating right button was double-clicked. | |
SHIFT key is pressed. | |
CTRL key is pressed. | |
ALT key is pressed. |
Description
MAKELPARAM( intInt_LoInt
, intInt_HiInt
);
This function creates a LONG value from two INT values.
Parameters
See Also
Int_PostMessage, LOWORD, HIWORD, LOBYTE, HIBYTE