Blame | Last modification | View Log | Download
/**************************************************************** Object : pvb_util.dll** File : mouse.c** Purpose : Mouse handling for FactoyyLink, usage of functions* with PVB.***************************************************************/#include <stdlib.h>#include <stdio.h>#include <windows.h>#include <commctrl.h>HWND status_hwnd = NULL;/**************************************************************** Function: short WINAPI pvb_win_topmost( char *title,* short activate)** Purpose: Set a window to topmost.** Parameter: title - Name of the window to set topmost.* activate - if not eqaul to zero, the window is* set topmost and activated, otherwise* the window is only set topmost.** Return : 0 - Success* -1 - Failure**************************************************************/short WINAPI pvb_win_topmost( char *title, short activate){HWND hwnd,after = HWND_TOPMOST;unsigned int flags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;/* locate the specified window */if ((hwnd = FindWindow( NULL, title)) != NULL){/* set the active flag */if (!activate)flags |= SWP_NOACTIVATE;/* change teh window properties */if (SetWindowPos( hwnd,HWND_TOPMOST,0,0,0,0,flags) == TRUE)return 0;elsereturn -1;}elsereturn -1;} /* pvb_win_topmost *//**************************************************************** Function: short WINAPI pvb_win_notopmost( char *title,* short bottom)** Purpose: Remove the topmost property for a window.** Parameter: title - Name of the window to reset topmost.* bottom - if not eqaul to zero, the window is* set normal (not topmost) and de-activa-* ted, otherwise the window is only set* normal (but can still be active).** Return : 0 - Success* -1 - Failure**************************************************************/short WINAPI pvb_win_notopmost( char *title, short bottom){HWND hwnd;/* locate the specified window */if ((hwnd = FindWindow( NULL, title)) != NULL){/* remove topmost property */if (SetWindowPos( hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOACTIVATE) == TRUE){/* change the z-order if specified */if (bottom){if (SetWindowPos( hwnd,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOACTIVATE) == TRUE)return 0;elsereturn -1;}return 0;}elsereturn -1;}elsereturn -1;} /* pvb_win_notopmost *//**************************************************************** Function: short WINAPI pvb_win_maximize( char *title,* short activate)** Purpose: Maximize the window.** Parameter: title - Name of the window to maximize.* activate - if not eqaul to zero, the window is* maximized and moved to top, otherwise* the window is only maximized.** Return : 0 - Success* -1 - Failure**************************************************************/short WINAPI pvb_win_maximize( char *title, short activate){HWND hwnd;int flags = SW_MAXIMIZE;short ret = 0;/* locate the specified window */if ((hwnd = FindWindow( NULL, title)) != NULL){if (activate)flags = SW_SHOWMAXIMIZED;if (ShowWindow( hwnd, flags) != TRUE)ret = -1;}elsereturn -1;return ret;}/**************************************************************** Function: short WINAPI pvb_win_minimize( char *title,* short activate)** Purpose: Minimize the window.** Parameter: title - Name of the window to minimize.* deactivate - if not eqaul to zero, the window is* minimized and removed from top, otherwise* the window is only minimized.** Return : 0 - Success* -1 - Failure**************************************************************/short WINAPI pvb_win_minimize( char *title, short deactivate){HWND hwnd;int flags = SW_MINIMIZE;short ret = 0;/* locate the specified window */if ((hwnd = FindWindow( NULL, title)) != NULL){if (!deactivate)flags = SW_SHOWMINNOACTIVE;if (ShowWindow( hwnd, flags) != TRUE)ret = -1;}elsereturn -1;return ret;}/**************************************************************** Function: short WINAPI pvb_win_disable( char *title)** Purpose: Diable all the system menu options** Parameter: title - Name of the window to minimize.* deactivate - if not eqaul to zero, the window is* minimized and removed from top, otherwise* the window is only minimized.** Return : 0 - Success* -1 - Failure**************************************************************/short WINAPI pvb_sys_disable( char *title){HWND hwnd;HMENU sysmenu;/* locate the specified window */if ((hwnd = FindWindow( NULL, title)) != NULL){if ((sysmenu = GetSystemMenu( NULL, FALSE)) != NULL){/* remove all system menu options */EnableMenuItem( sysmenu, 0, MF_BYPOSITION | MF_DISABLED);EnableMenuItem( sysmenu, 1, MF_BYPOSITION | MF_DISABLED);EnableMenuItem( sysmenu, 2, MF_BYPOSITION | MF_DISABLED);EnableMenuItem( sysmenu, 3, MF_BYPOSITION | MF_DISABLED);EnableMenuItem( sysmenu, 4, MF_BYPOSITION | MF_DISABLED);return 0;}}return -1;} /* pvb_sys_disable */