Example #1
1
// ------------------------------------------------
// 
//  FUNCTION: sys_GetRegKey( PA_PluginParameters params )
//
//  PURPOSE:  Get a key from the registry.
//        
//	DATE:	  MJG 12/4/03 (3.5.6)
//
void sys_GetRegKey( PA_PluginParameters params )
{
	LONG_PTR returnValue, regKey, retErr, dataSize, arraySize, expandDataSize;
	LONG_PTR i, len;
	char regSub[MAXBUF];
	char regName[MAXBUF];
	char *returnDataBuffer, *ptrData;
	HKEY hRootKey;
	HKEY hOpenKey;
	DWORD dwDataType;
	DWORD dwReturnLong;
	PA_Variable	paReturnArray;

	// AMS2 12/9/14 #41400 Initalized the dataSize variable. In 64 bit environments this can be randomly initalized to a size in bytes 
	// that is larger than malloc can allot, causing it to return null and crash when returning to 4D. Remember to always initialize your size variables.
	dataSize = 0;
	returnValue = regKey = retErr = arraySize = expandDataSize = 0; 
	hRootKey = hOpenKey = 0;
	ptrData = returnDataBuffer = NULL;
	memset(regSub, 0, MAXBUF);
	memset(regName, 0, MAXBUF);

	// Get the function parameters.
	regKey = PA_GetLongParameter( params, 1 );
	PA_GetTextParameter( params, 2, regSub );
	PA_GetTextParameter( params, 3, regName );

	// Convert the 4d registry constant into a Windows registry key.
	hRootKey = getRootKey( regKey );

	// Open the registry key.
	retErr = RegOpenKeyEx(hRootKey, regSub, 0, KEY_READ, &hOpenKey);
	
	if(retErr == ERROR_SUCCESS){

		// Get the value type and size.
		retErr = RegQueryValueEx(hOpenKey, regName, NULL, &dwDataType, NULL, &dataSize);

		if(retErr == ERROR_SUCCESS){

			switch(dwDataType){
			case REG_BINARY:
				returnDataBuffer = malloc(dataSize);
				retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, (LPBYTE) returnDataBuffer, &dataSize);

				if(retErr == ERROR_SUCCESS){
					PA_SetBlobParameter(params, 4, returnDataBuffer, dataSize);
					returnValue = 1;
				}

				free(returnDataBuffer);
				break;

			case REG_DWORD:
			case REG_DWORD_BIG_ENDIAN:
				dataSize = sizeof(dwReturnLong);
				retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, (LPBYTE) &dwReturnLong, &dataSize);

				if(retErr == ERROR_SUCCESS){
					PA_SetLongParameter(params, 4, dwReturnLong);
					returnValue = 1;
				}
				break;

			case REG_EXPAND_SZ:
				returnDataBuffer = malloc(dataSize);
				retErr = RegQueryValueEx (hOpenKey, regName, NULL, NULL, returnDataBuffer, &dataSize);
				
				if(retErr == ERROR_SUCCESS)
				{
					regExpandStr(&returnDataBuffer);
					PA_SetTextParameter(params, 4, returnDataBuffer, strlen(returnDataBuffer));
					returnValue = 1;
				}

				free(returnDataBuffer);
				break;


			case REG_MULTI_SZ:
				returnDataBuffer = malloc(dataSize);
				paReturnArray = PA_GetVariableParameter( params, 4 );

				retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, returnDataBuffer, &dataSize);

				if(retErr == ERROR_SUCCESS)
				{
					arraySize = regGetNumElements(returnDataBuffer);
					PA_ResizeArray(&paReturnArray, arraySize);

			
					for(i = 1, ptrData = returnDataBuffer; i <= arraySize; i++)
					{
						len = strlen(ptrData);
						PA_SetTextInArray(paReturnArray, i, ptrData, len);
						ptrData+=len+1;
					} 

					returnValue = 1;
					PA_SetVariableParameter( params, 4, paReturnArray, 0 );
				}

				free(returnDataBuffer);
				break;


			case REG_SZ:
				returnDataBuffer = (char*)malloc(dataSize);
				retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, returnDataBuffer, &dataSize);

				if(retErr == ERROR_SUCCESS){
					PA_SetTextParameter(params, 4, returnDataBuffer, dataSize-1);
					returnValue = 1;
				}

				free(returnDataBuffer);
				break;
			} 
		}
	}

	RegCloseKey( hOpenKey );
	PA_ReturnLong( params, returnValue );
}
Example #2
0
void sys_KillProcessByID( PA_PluginParameters params )
{
	HANDLE hProcess;                  // Handle to the process itself
	INT_PTR lPID;                         // Integer to hold the processID ($1)
	BOOL bCleanFirst = FALSE;         // Boolean to see if we should try to cleanly close the app
	                                  // before killing it mercilessly ($2)
	
	// Get the function parameters.
	lPID = PA_GetLongParameter(params, 1);
	bCleanFirst = (PA_GetLongParameter(params, 2) == 1 ? TRUE : FALSE);

	// Open a handle to the process
  hProcess = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, lPID); 
  
  // Check to see if we got it, and return an error if we didn't
	if(hProcess == NULL) {
    PA_ReturnLong(params, (LONG_PTR)GetLastError());
		return;
	}


	if(bCleanFirst)
	{
    // TerminateClean() posts WM_CLOSE to all windows whose PID
    // matches your process's.
    EnumWindows((WNDENUMPROC)TerminateClean, (LPARAM) lPID) ;

		if(WaitForSingleObject(hProcess, 500)!=WAIT_OBJECT_0)
		{
      bCleanFirst = TRUE;
			PA_ReturnLong(params, -1);
		}
	} // end if bCleanFirst

	if(!bCleanFirst)
	{    
	  // Kill the process
    if (TerminateProcess(hProcess, 1))
		{
	  	// Success! Return 0
	  	PA_ReturnLong(params, 0);
		} else {
	  	// Fail! Return the error
      PA_ReturnLong(params, (LONG_PTR)GetLastError());
		}
	} // end if !bCleanFirst

	// Clean up
	CloseHandle(hProcess);
}
Example #3
0
// ------------------------------------------------
// 
//  FUNCTION: sys_GetEnv( PA_PluginParameters params )
//
//  PURPOSE:  Get the value of an environment variable.
//        
//	DATE:	  MJG 12/2/03 (3.5.6)
//
void sys_GetEnv( PA_PluginParameters params )
{
	LONG_PTR returnValue;
	LONG_PTR envLength;
	char envName[MAXBUF], *envValue;

	envValue = NULL;
	memset(envName, 0, MAXBUF);

	envLength = PA_GetTextParameter( params, 1, envName );
	
	if(envLength > 0)
		envValue = getenv(envName);

	if(envValue == NULL)
	{
		returnValue = 0;
		PA_SetTextParameter(params, 2, "", 0);
	}
	else {
		returnValue = 1;
		PA_SetTextParameter(params, 2, envValue, strlen(envValue));
	}

	PA_ReturnLong( params, returnValue );
}
Example #4
0
void sys_LogonUser(PA_PluginParameters params)
{
	
	HANDLE hToken = NULL;
	BOOL bStatus = FALSE;
	char chUserID[MAXBUF] = "";   // String to hold the username
	char chDomain[MAXBUF] = "";   // String to hold the domain
	char chPassword[MAXBUF] = ""; // String to hold the password
	
	// Make sure that we've cleared out any previous errors
	SetLastError(0);

	// Get our parameters
	PA_GetTextParameter(params, 1, chUserID);
	PA_GetTextParameter(params, 2, chDomain);
	PA_GetTextParameter(params, 3, chPassword);

  // Authenticate the user
  bStatus = LogonUser(chUserID, chDomain, chPassword, LOGON32_LOGON_NETWORK, 
                      LOGON32_PROVIDER_DEFAULT, &hToken);

  if(bStatus)
	{
    // Authenticated
    // Close the handle
    if (hToken != NULL)
		{
      CloseHandle(hToken);
      hToken = NULL;
    }
  }

  PA_ReturnLong(params, (LONG_PTR)bStatus);
}
Example #5
0
// ------------------------------------------------
//
//  FUNCTION: gui_GetWindowState( PA_PluginParameters params)
//
//  PURPOSE:	Determine if window is minimized or maximized
//
//  COMMENTS:	Returns 0 if window is normal, 1 if minimized
//						and 2 if maximized.
//
//	DATE:			dcc 07/20/02 dcc
//
//	MODIFICATIONS:
//
void gui_GetWindowState(PA_PluginParameters params, BOOL isEx)
{
	HWND				hWnd;
	LONG			hWndIndex; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG			returnValue = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	hWndIndex = PA_GetLongParameter(params, 1); // WJF 9/1/15 #43731 We are now getting an index to an internal array

	if (isEx){ // WJF 9/16/15 #43731
		hWnd = handleArray_retrieve((DWORD)hWndIndex);
	}
	else {
		hWnd = (HWND)hWndIndex;
	}

	if (IsWindow(hWnd)) {
		if (IsIconic(hWnd)) {
			returnValue = IS_ICONIC;
		}
		else if (IsZoomed(hWnd)) {
			returnValue = IS_ZOOMED;
		}
	}

	PA_ReturnLong(params, returnValue);
}
Example #6
0
// ------------------------------------------------
// 
//  FUNCTION: gui_GetSysColor( PA_PluginParameters params )
//
//  PURPOSE:  Get the current color of the specified display element.
//        
//	DATE:	  MJG 12/1/03 (3.5.6)
//
void gui_GetSysColor( PA_PluginParameters params )
{
	LONG_PTR returnValue;
	LONG_PTR displayElement;
	LONG_PTR retRValue, retGValue, retBValue;
	DWORD dwResult;

	returnValue = 0;
	displayElement = PA_GetLongParameter( params, 1); 
	retRValue = retGValue = retBValue = 0;

	if(displayElement >= COLOR_SCROLLBAR && displayElement <= COLOR_GRADIENTINACTIVECAPTION && displayElement != COLOR_UNUSED){

		dwResult = GetSysColor(displayElement); 

		retRValue = GetRValue(dwResult);
		retGValue = GetGValue(dwResult);
		retBValue = GetBValue(dwResult); 

		returnValue = 1;
	}
    
	PA_SetLongParameter( params, 2, retRValue );
	PA_SetLongParameter( params, 3, retGValue );
	PA_SetLongParameter( params, 4, retBValue );

 
	PA_ReturnLong( params, returnValue );
}
Example #7
0
//  FUNCTION:   sys_LoggingStart(PA_PluginParameters params)
//
//  PURPOSE:	Start logging Win32API commands
//
//  COMMENTS:
//
//	DATE:		7/11/16 Win-20
void sys_LoggingStart(PA_PluginParameters params) {
	LONG returnValue = 0; // WJF 7/11/16 Win-20

	PA_GetTextParameter(params, 1, szLogsPath);
	lNumDays = PA_GetLongParameter(params, 2);
	
	returnValue = logOpenFile();

	PA_ReturnLong(params, returnValue); // WJF 7/11/16 Win-20
}
Example #8
0
void sys_DirectoryExists(PA_PluginParameters params){
	char *directory = NULL;
	LONG_PTR length;
	WIN32_FIND_DATA FindFileData;
	HANDLE hFindFile;
	LONG ret = 0; // assume directory doesn't exist // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	// retrieve the directory manual
	length = PA_GetTextParameter(params, 1, 0L);

	if (length > 0) {
		directory = malloc(length + 1); // WJF 7/13/16 Win-21 Removed typecasting on malloc to follow C best practices

		if (directory != NULL) {
			memset(directory, 0, length + 1);
			PA_GetTextParameter(params, 1, directory);
		}
	}

	// if the directory ends with a backslash it will fail and needs to be removed
	// if the directory is a disk root it will fail handle here in special case
	if (NULL != directory){
		if ((':' == directory[1]) && (length <= 3)) { // REB 8/2/10 #24474 Changed ( 3 == length) to (length <= 3)
			// drive since has only 3 chars, handle here
			ret = GetFileAttributes(directory);
			if (ret != INVALID_FILE_ATTRIBUTES){ // REB 8/2/10 #24474 Added check for invalid attributes.
				ret = (0 != (GetFileAttributes(directory) & FILE_ATTRIBUTE_DIRECTORY)); // set exists
				free(directory);
				directory = NULL; // we have a result so avoid to normal handler
			}
		}
		else if ('\\' == directory[length - 1]){
			directory[length - 1] = '\0';
		}
	}

	if (NULL != directory){
		hFindFile = FindFirstFile(directory, &FindFileData);

		// if a valid handle we should test whether it's a directory
		if (INVALID_HANDLE_VALUE != hFindFile){
			ret = (0 != (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); // set exists
			FindClose(hFindFile);	// close handle
		}
		freeTextParameter(directory);
	}

	PA_ReturnLong(params, ret);
}
Example #9
0
// ------------------------------------------------
// 
//  FUNCTION: gui_GetWindowState( PA_PluginParameters params)
//
//  PURPOSE:	Determine if window is minimized or maximized
//
//  COMMENTS:	Returns 0 if window is normal, 1 if minimized
//						and 2 if maximized.
//        
//	DATE:			dcc 07/20/02 dcc
//
//	MODIFICATIONS: 
//
void gui_GetWindowState( PA_PluginParameters params )
{
	HWND			hWnd;
	LONG_PTR			returnValue = 0;


	hWnd = (HWND) PA_GetLongParameter( params, 1);
	if (IsWindow(hWnd)) {
		if (IsIconic(hWnd)) {
			returnValue = IS_ICONIC;
		} else if (IsZoomed(hWnd)) {
			returnValue = IS_ZOOMED;
		}
	}

	PA_ReturnLong( params, returnValue );
}
Example #10
0
void gui_SubClassInit( PA_PluginParameters params ) 
{
	LONG_PTR				returnValue = 0, action = 0;
	//WNDCLASSEX			wndClassEx;
	//LPWNDCLASSEX		lpWndClassEx = &wndClassEx;
	//char				className[] = "ProToolsSubMDIWndClass";
	//HINSTANCE			hInst;
	
	// Put NDEBUF flag back into Preprocessor definitions
	action = PA_GetLongParameter( params, 1);
	toolBarRestrictions.toolBarOnDeck = 0; // added for gui_RespectToolBar 01/16/03
  
	if (action != RW_RELEASE) {
		if (processHandles.wpProToolsOrigProc == NULL) {

			processHandles.wpProToolsOrigProc = (WNDPROC) SetClassLongPtr(windowHandles.MDIs_4DhWnd, GCLP_WNDPROC, (LONG_PTR)ProToolsProc);
			returnValue = (LONG_PTR) processHandles.wpProToolsOrigProc;

			/*
			//hInst = (HINSTANCE) PA_Get4DHInstance(); // this doesn't work for 4D 6.5
			hInst = (HINSTANCE) GetWindowLong(windowHandles.fourDhWnd, GWL_HINSTANCE); // 09/10/02
			//hInst = (HINSTANCE)GetWindowLongPtr(windowHandles.MDIhWnd, GWL_HINSTANCE);


			wndClassEx.cbSize = sizeof(WNDCLASSEX);
			if (GetClassInfoEx(hInst, className, lpWndClassEx)) {
				wndClassEx.lpfnWndProc = &ProToolsProc;
				processHandles.wpProToolsOrigProc = (WNDPROC) SetClassLongPtr(windowHandles.MDIs_4DhWnd, GCLP_WNDPROC, (LONG_PTR)ProToolsProc);
				returnValue = (LONG_PTR) processHandles.wpProToolsOrigProc;
			}
			*/
		}
	} else {

		if (processHandles.wpProToolsOrigProc != NULL) {
			//SetClassLongPtr(windowHandles.fourDhWnd, GCLP_WNDPROC, (LONG_PTR)processHandles.wpProToolsOrigProc);
			SetClassLongPtr(windowHandles.MDIs_4DhWnd, GCLP_WNDPROC, (LONG_PTR)processHandles.wpProToolsOrigProc);
			processHandles.wpProToolsOrigProc = NULL;
			returnValue = 1;
		}
		clear_list(&startOfList);
	}
	PA_ReturnLong( params, returnValue );
}
Example #11
0
// ------------------------------------------------
// 
//  FUNCTION: sys_GetEnv( PA_PluginParameters params )
//
//  PURPOSE:  Set the value of an environment variable.
//        
//	DATE:	  MJG 12/2/03 (3.5.6)
//
void sys_SetEnv( PA_PluginParameters params )
{
	LONG_PTR returnValue;
	char envName[MAXBUF], envValue[MAXBUF];

	returnValue = 0;
	memset(envName, 0, MAXBUF);
	memset(envValue, 0, MAXBUF);

	PA_GetTextParameter( params, 1, envName );
	PA_GetTextParameter( params, 2, envValue );
	
	strncat(envName, "=", MAXBUF);
	strncat(envName, envValue, MAXBUF);
	
	returnValue = !(putenv(envName));

	PA_ReturnLong( params, returnValue );
}
Example #12
0
// ------------------------------------------------
// 
//  FUNCTION: sys_GetRegType( PA_PluginParameters params )
//
//  PURPOSE:  Get a key from the registry.
//        
//	DATE:	  MJG 12/4/03 (3.5.6)
//
void sys_GetRegType( PA_PluginParameters params )
{
	LONG_PTR returnValue, regKey, retErr;
	char regSub[MAXBUF];
	char regName[MAXBUF];
	char *returnDataBuffer;
	HKEY hRootKey;
	HKEY hOpenKey;
	DWORD dwDataType;

	returnValue = regKey = retErr = 0;
	hRootKey = hOpenKey = 0;
	returnDataBuffer =  NULL;
	memset(regSub, 0, MAXBUF);
	memset(regName, 0, MAXBUF);

	// Get the function parameters.
	regKey = PA_GetLongParameter( params, 1 );
	PA_GetTextParameter( params, 2, regSub );
	PA_GetTextParameter( params, 3, regName );

	// Convert the 4d registry constant into a Windows registry key.
	hRootKey = getRootKey( regKey );

	// Open the registry key.
	retErr = RegOpenKeyEx(hRootKey, regSub, 0, KEY_READ, &hOpenKey);
	
	if(retErr == ERROR_SUCCESS){

		// Get the value type and size.
		retErr = RegQueryValueEx(hOpenKey, regName, NULL, &dwDataType, NULL, NULL);

		if(retErr == ERROR_SUCCESS){

			returnValue = get4dRegType(dwDataType);

		}
	}

	RegCloseKey( hOpenKey );
	PA_ReturnLong( params, returnValue );
}
Example #13
0
// ------------------------------------------------
// 
//  FUNCTION: sys_IsAppLoaded( PA_PluginParameters params )
//
//  PURPOSE:	Check if a program is loaded
//
//  COMMENTS:	Win98 uses different approach than NT4 and up
//						Function pointers used for OS specific functions.
//        
//	DATE:			dcc 08/23/02
//
//	MODIFICATIONS: 
//
void sys_IsAppLoaded( PA_PluginParameters params )
{
	LPFNENUMPROC				lpfnEnumProc = NULL;
	LPFNENUMPROCMODS		lpfnEnumProcMods = NULL;
	LPFNGETMODFNAME			lpfnGetModFName = NULL;
	HINSTANCE						hPSapiDLL;
	BOOL								bFuncReturn, bUseToolHelp = FALSE;
	char								appName[100]; 
	LONG_PTR								appName_len;

	appName_len						 = PA_GetTextParameter( params, 1, appName );
	appName[appName_len]	 = '\0';

	hPSapiDLL = (HINSTANCE) getPSapiPointers(&lpfnEnumProc, &lpfnEnumProcMods, &lpfnGetModFName);

	bFuncReturn = reviewProcesses(hPSapiDLL, lpfnEnumProc, lpfnEnumProcMods, lpfnGetModFName,
								appName, bUseToolHelp);

	PA_ReturnLong( params, bFuncReturn);
}
Example #14
0
// ------------------------------------------------
// 
//  FUNCTION: gui_SetSysColor( PA_PluginParameters params )
//
//  PURPOSE:  Set the color of the specified display element.
//        
//	DATE:	  MJG 12/1/03 (3.5.6)
//
void gui_SetSysColor( PA_PluginParameters params )
{
	LONG_PTR returnValue;
	INT_PTR displayElement[1];
	COLORREF rgbValue[1];
	BYTE rValue, gValue, bValue;

	returnValue = 0;
	displayElement[0] = (INT_PTR) PA_GetLongParameter( params, 1); 
	rValue = (BYTE) PA_GetLongParameter( params, 2);
	gValue = (BYTE) PA_GetLongParameter( params, 3);
    bValue = (BYTE) PA_GetLongParameter( params, 4);

	rgbValue[0] = RGB(rValue, gValue, bValue);

    returnValue = SetSysColors(1, displayElement, rgbValue);

	if(returnValue != 0)
		returnValue = 1;
 
	PA_ReturnLong( params, returnValue );
}
Example #15
0
void sys_FileExists(PA_PluginParameters params){
	char *file = NULL;
	WIN32_FIND_DATA FindFileData;
	HANDLE hFindFile;
	BOOL ret = FALSE; // assume file doesn't exist  // WJF 6/30/16 Win-21 LONG_PTR -> BOOL

	file = getTextParameter(params, 1);

	if (NULL != file){
		hFindFile = FindFirstFile(file, &FindFileData);

		// if a valid handle we should test whether it's not a directory
		if (INVALID_HANDLE_VALUE != hFindFile){
			ret = (0 == (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); // set exists
			FindClose(hFindFile);	// close handle
		}

		freeTextParameter(file);
	}

	PA_ReturnLong(params, ret);
}
Example #16
0
void sys_SetPluginLanguage( PA_PluginParameters params )
{
	LONG_PTR language;
		// Get the function parameters.
	language = PA_GetLongParameter( params, 1 );

	switch( language )
	{
		case LANG_ENGLISH :
			message = &message_list_english;
			break;

		case LANG_DUTCH: 
			message = &message_list_dutch;
			break;

		default :
			language = LANG_ENGLISH;
			message = &message_list_english;
			break;
	}

	PA_ReturnLong( params, language );
}
Example #17
0
void gui_SetWindowStyle(PA_PluginParameters params, BOOL isEx)
{
	LONG				StyleCurr = 0, StyleNew = 0, action = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	HWND				hWnd = NULL;
	HMENU				hSysMenu;
	pLL					thisLink = NULL, previousLink = NULL;
	LONG				hWndIndex = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	hWndIndex = PA_GetLongParameter(params, 1); // WJF 9/1/15 #43731 We are now getting an index to an internal handle array
	action = PA_GetLongParameter(params, 2);

	if (isEx){ // WJF 9/16/15 #43731
		hWnd = handleArray_retrieve((DWORD)hWndIndex);
	}
	else {
		hWnd = (HWND)hWndIndex;
	}

	if (IsWindow(hWnd)) {
		StyleCurr = GetWindowLong(hWnd, GWL_STYLE);
		StyleNew = StyleCurr;

		if (0 != (action & RW_DISABLE_MIN)){
			StyleNew = StyleNew & ~WS_MINIMIZEBOX;
		}

		if (0 != (action & RW_ENABLE_MIN)){
			StyleNew = StyleNew | WS_MINIMIZEBOX;
		}

		if (0 != (action & RW_DISABLE_MAX)){
			StyleNew = StyleNew & ~WS_MAXIMIZEBOX;
		}

		if (0 != (action & RW_ENABLE_MAX)){
			StyleNew = StyleNew | WS_MAXIMIZEBOX;
		}

		if (0 != (action & RW_DISABLE_CLOSE)){
			hSysMenu = GetSystemMenu(hWnd, 0);
			if (hSysMenu != NULL) {
				EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
			}
		}

		if (0 != (action & RW_ENABLE_CLOSE)){
			hSysMenu = GetSystemMenu(hWnd, 0);
			if (hSysMenu != NULL) {
				EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
			}
		}

		if (0 != (action & RW_DISABLE_RESIZE)){
			// subClass procedure must be in place
			if (processHandles.wpProToolsOrigProc == NULL) {
				PA_ReturnLong(params, -2);
				return;
			}

			if (startOfList == NULL) {
				init_list(&startOfList);
			}

			// insert item in linked list -- if not already there
			if (!search_list(&startOfList, &thisLink, &previousLink, LL_hWnd, LL_Restrict, (LONG_PTR *)&hWnd)) {
				thisLink = (pLL)insert_list(&startOfList);
				if (thisLink == NULL) {
					PA_ReturnLong(params, -2);
					return;
				}
				else {
					thisLink->hWnd = hWnd;
					thisLink->dataLong1 = RW_NO_SIZE; // sub proc uses other number
					thisLink->type = LL_Restrict;
					thisLink->wpProc = processHandles.wpProToolsOrigProc;
				}
			}
		}

		if (0 != (action & RW_ENABLE_RESIZE)){
			// no subclass or no list head, we're done
			if ((NULL != processHandles.wpProToolsOrigProc) && (NULL != startOfList)) {
				delete_list(&startOfList, LL_hWnd, LL_Restrict, (LONG_PTR *)&hWnd);
			}
		}

		if (StyleNew != StyleCurr){
			if (0 == SetWindowLong(hWnd, GWL_STYLE, StyleNew)){
				PA_ReturnLong(params, -2);
				return;
			}
			else {
				// notify windows we changed the style
				SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
			}
		}
	}
	// when we end up here all is oke
	PA_ReturnLong(params, 0);
}
Example #18
0
void gui_RestrictWindow( PA_PluginParameters params )
{
	LONG_PTR				action = 0, returnValue = 0, styleChg = 0, numDeleted = 0;
	HWND				hWnd = NULL;
	HMENU				hSysMenu;
	WNDPROC			wpProc = NULL;
	pLL					thisLink = NULL, previousLink = NULL;


	// subClass procedure must be in place
	if (processHandles.wpProToolsOrigProc == NULL) {
			PA_ReturnLong( params, -2 );
			return;
	}

	hWnd  = (HWND) PA_GetLongParameter( params, 1 );
	action = PA_GetLongParameter( params, 2);

	if (IsWindow(hWnd)) {  // 09/09/02 more action values now so removed restriction
		returnValue = GetWindowLong(hWnd, GWL_STYLE);

		// eliminate sizing cursor and Window's sizing border
		switch (action)
		{
			case (RW_NO_MIN) :
				if ((returnValue & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) {
					styleChg = returnValue ^ WS_MINIMIZEBOX;
					returnValue = SetWindowLong(hWnd, GWL_STYLE, styleChg);
				}
				break;

			case (RW_NO_MAX) :
				if ((returnValue & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) {
					styleChg = returnValue ^ WS_MAXIMIZEBOX;
					returnValue = SetWindowLong(hWnd, GWL_STYLE, styleChg);
				}
				break;

			case (RW_NO_CLOSE) :
				hSysMenu = GetSystemMenu(hWnd,0);
				if (hSysMenu != NULL) {
					EnableMenuItem (hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
				}
				break;

			case (RW_RESTORE_CLOSE) :
				hSysMenu = GetSystemMenu(hWnd,0);
				if (hSysMenu != NULL) {
					EnableMenuItem (hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
				}
				break;
		}

		if (startOfList == NULL) {
			init_list(&startOfList);
		}
		// insert item in linked list -- if not already there
		if (!search_list( &startOfList, &thisLink, &previousLink, LL_hWnd, LL_Restrict, (LONG_PTR *) &hWnd)) {
			thisLink = (pLL) insert_list(&startOfList);
			if (thisLink == NULL) {
				PA_ReturnLong( params, -1 ); // could not add to list - get out
				return;
			}
		} else {
			PA_ReturnLong( params, (LONG_PTR)hWnd ); // return window handle if already in list
			return;
		}

		thisLink->hWnd = hWnd;
		thisLink->dataLong1 = action;
		thisLink->type = LL_Restrict;
		thisLink->wpProc = processHandles.wpProToolsOrigProc;
		returnValue = length_list(startOfList);

	}

	PA_ReturnLong( params, returnValue );
}
Example #19
0
// ------------------------------------------------
//
//  FUNCTION: sys_GetCommandLine( PA_PluginParameters params)
//
//  PURPOSE:	Gets command line used to start 4D
//
//  COMMENTS:	Parse command line. Ends at a negative character value.
//						Returns an array of parameters.
//						Params should be passed unquoted. There can be a space or NULL
//						between parameters. 1st param is delimited by space.  Rest are NULL.
//
//	DATE:			dcc 04/03/02 dcc
//
//	MODIFICATIONS: Rewritten 06/20/02 to make more concise, less convoluted, etc.
//                 Modified 7/29/03
void sys_GetCommandLine(PA_PluginParameters params)
{
	char				commandLineStr[MAXBUF];
	char                paramElement[MAXBUF];
	char				executableString[MAXBUF];
	char				*pMarker;
	LONG				returnValue = 0, commandLine_len = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG_PTR			charsToCopy;
	LPTSTR				pCommandLineStr, pTemp;
	PA_Variable			parameters;
	BOOL				bInQuotes = FALSE, bDone = FALSE;
	LONG				paramCount = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG				action = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	memset(commandLineStr, 0, MAXBUF);
	memset(paramElement, 0, MAXBUF);
	memset(executableString, 0, MAXBUF);

	parameters = PA_GetVariableParameter(params, 1);
	action = PA_GetLongParameter(params, 2);

	pCommandLineStr = GetCommandLine();

	if (pCommandLineStr == NULL) {
		returnValue = 0;
	}
	else {
		pMarker = pTemp = pCommandLineStr;

		//if first char a doublequote, skip it
		if (*pMarker == '"') {
			pMarker++;
			bInQuotes = TRUE;
		}

		// Find the executable name.
		while (!((*(++pTemp) == ' ' && !bInQuotes) || (*pTemp == '"' && bInQuotes) || *pTemp == '\0'));

		charsToCopy = (pTemp - pMarker);
		strncpy(executableString, pMarker, charsToCopy);
		commandLine_len = (LONG)charsToCopy; // WJF 6/30/16 Win-21 Cast to LONG
		executableString[charsToCopy] = '\0';

		//skip next quotes and spaces if they are there
		while ((*pTemp == '"') || (*pTemp == ' ')) {
			if ((*pTemp == '"') && (action == CL_DRAGDROP)) {
				bInQuotes = !bInQuotes; // toggle flag
			}
			commandLine_len += 1;
			pTemp++;
		}

		pMarker = pTemp;

		if (action == CL_DRAGDROP) {
			if (bInQuotes) {
				while ((*pTemp != '"') || ((*pTemp != '\0') && (*(pTemp + 1) != '\0'))) {
					pTemp++;
				}
			}
			else {
				while (*pTemp != '\0') {
					pTemp++;
				}
			}

			strncpy(paramElement, pMarker, pTemp - pMarker);
			paramElement[pTemp - pMarker] = '\0';
			if (strlen(paramElement) == 0) {
				PA_ResizeArray(&parameters, 1);
				strcpy(commandLineStr, executableString);
				returnValue = 1;
			}
			else {
				PA_ResizeArray(&parameters, 2);
				PA_SetTextInArray(parameters, 2, paramElement, strlen(paramElement));
				strcpy(commandLineStr, executableString);
				strcat(commandLineStr, " ");
				strcat(commandLineStr, paramElement);
				returnValue = 2;
			}
		}
		else {
			paramCount = 1;
			strcpy(commandLineStr, executableString);
			PA_ResizeArray(&parameters, paramCount);

			while (!bDone) {
				strcpy(paramElement, "");
				while (*pTemp >= 0) {
					pTemp++;
					//two nulls in a row also end
					//replace nulls with spaces
					if ((*(pTemp) == '\0') || (*(pTemp) == ' ')) {
						if ((*(pTemp + 1) == '\0') || (*(pTemp + 1) == ' ')){
							bDone = TRUE;
							paramCount++;
							break;
						}
						else {
							paramCount++;
							break;
						}
					}
				} // end while

				strncpy(paramElement, pMarker, pTemp - pMarker);
				paramElement[pTemp - pMarker] = '\0';
				if (strlen(paramElement) > 0) {
					PA_ResizeArray(&parameters, paramCount);
					PA_SetTextInArray(parameters, paramCount, paramElement, strlen(paramElement));
					pMarker = pTemp + 1;
					strcat(commandLineStr, " ");
					strcat(commandLineStr, paramElement);
				}
				else {
					bDone = TRUE;
				}
			} // end while !done
			returnValue = PA_GetArrayNbElements(parameters);
		}

		PA_SetTextInArray(parameters, 1, executableString, strlen(executableString));
		PA_SetTextInArray(parameters, 0, commandLineStr, strlen(commandLineStr));
		PA_SetVariableParameter(params, 1, parameters, 0);
	} // (pCommandLineStr == NULL)

	PA_ReturnLong(params, returnValue);
}
Example #20
0
void gui_RestrictWindow(PA_PluginParameters params, BOOL isEx)
{
	LONG				action = 0, returnValue = 0, styleChg = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	HWND				hWnd = NULL;
	HMENU				hSysMenu;
	pLL					thisLink = NULL, previousLink = NULL;
	LONG				hWndIndex = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	// subClass procedure must be in place
	if (processHandles.wpProToolsOrigProc == NULL) {
		PA_ReturnLong(params, -2);
		return;
	}

	hWndIndex = PA_GetLongParameter(params, 1); // WJF 9/1/15 #43731 We are now getting an index to an internal array
	action = PA_GetLongParameter(params, 2);

	if (isEx){ // WJF 9/16/15 #43731
		hWnd = handleArray_retrieve((DWORD)hWndIndex);
	}
	else {
		hWnd = (HWND)hWndIndex;
	}

	if (IsWindow(hWnd)) {  // 09/09/02 more action values now so removed restriction
		returnValue = GetWindowLong(hWnd, GWL_STYLE);

		// eliminate sizing cursor and Window's sizing border
		switch (action)
		{
		case (RW_NO_MIN) :
			if ((returnValue & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) {
				styleChg = returnValue ^ WS_MINIMIZEBOX;
				returnValue = SetWindowLong(hWnd, GWL_STYLE, styleChg);
			}
			break;

		case (RW_NO_MAX) :
			if ((returnValue & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) {
				styleChg = returnValue ^ WS_MAXIMIZEBOX;
				returnValue = SetWindowLong(hWnd, GWL_STYLE, styleChg);
			}
			break;

		case (RW_NO_CLOSE) :
			hSysMenu = GetSystemMenu(hWnd, 0);
			if (hSysMenu != NULL) {
				EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
			}
			break;

		case (RW_RESTORE_CLOSE) :
			hSysMenu = GetSystemMenu(hWnd, 0);
			if (hSysMenu != NULL) {
				EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
			}
			break;
		}

		if (startOfList == NULL) {
			init_list(&startOfList);
		}
		// insert item in linked list -- if not already there
		if (!search_list(&startOfList, &thisLink, &previousLink, LL_hWnd, LL_Restrict, (LONG_PTR *)&hWnd)) {
			thisLink = (pLL)insert_list(&startOfList);
			if (thisLink == NULL) {
				PA_ReturnLong(params, -1); // could not add to list - get out
				return;
			}
		}
		else {
			PA_ReturnLong(params, (LONG)hWnd); // return window handle if already in list // WJF 6/30/16 Win-21 Changed cast from LONG_PTR -> LONG
			return;
		}

		thisLink->hWnd = hWnd;
		thisLink->dataLong1 = action;
		thisLink->type = LL_Restrict;
		thisLink->wpProc = processHandles.wpProToolsOrigProc;
		returnValue = length_list(startOfList);
	}

	PA_ReturnLong(params, returnValue);
}
Example #21
0
// ------------------------------------------------
//
//  FUNCTION: gui_GetWindowStyle( PA_PluginParameters params)
//
//  PURPOSE:	Get window styles
//
//  COMMENTS:	outputs in array the applicable styles for the window
//						Returns via return code the LONG_PTR representing the value
//
//	DATE:			dcc 07/18/02 dcc
//
//	MODIFICATIONS:
//
void gui_GetWindowStyle(PA_PluginParameters params, BOOL isEx)
{
	PA_Variable					styles;
	LONG						returnValue = 0, testValue = 0, i; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	HWND						hWnd;
	char						styleText[40];
	BOOL						bFoundOne;
	LONG						hWndIndex = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG

	hWndIndex = PA_GetLongParameter(params, 1); // WJF 9/1/15 #43731 We are now getting an index to an internal array

	if (isEx){ // WJF 9/16/15 #43731
		hWnd = handleArray_retrieve((DWORD)hWndIndex);
	}
	else {
		hWnd = (HWND)hWndIndex;
	}

	if (IsWindow(hWnd)) {
		styles = PA_GetVariableParameter(params, 2);

		returnValue = GetWindowLong(hWnd, GWL_STYLE);
		testValue = returnValue;

		//and all styles to see what the window uses
		i = 1;
		while ((testValue != 0) && (i <= NUMBER_STYLES))
		{
			bFoundOne = FALSE;

			if ((testValue & WS_THICKFRAME) == WS_THICKFRAME) {
				strcpy(styleText, "WS_THICKFRAME");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_THICKFRAME;
			}
			else if
				((testValue & WS_POPUP) == WS_POPUP) {
				strcpy(styleText, "WS_POPUP");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_POPUP;
			}
			else if
				((testValue & WS_CHILD) == WS_CHILD) {
				strcpy(styleText, "WS_CHILD");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CHILD;
			}
			else if
				((testValue & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) {
				strcpy(styleText, "WS_MINIMIZEBOX");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_MINIMIZEBOX;
			}
			else if
				((testValue & WS_VISIBLE) == WS_VISIBLE) {
				strcpy(styleText, "WS_VISIBLE");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_VISIBLE;
			}
			else if
				((testValue & WS_DISABLED) == WS_DISABLED) {
				strcpy(styleText, "WS_DISABLED");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_DISABLED;
			}
			else if
				((testValue & WS_CLIPSIBLINGS) == WS_CLIPSIBLINGS) {
				strcpy(styleText, "WS_CLIPSIBLINGS");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CLIPSIBLINGS;
			}
			else if
				((testValue & WS_CLIPCHILDREN) == WS_CLIPCHILDREN) {
				strcpy(styleText, "WS_CLIPCHILDREN");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CLIPCHILDREN;
			}
			else if
				((testValue & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) {
				strcpy(styleText, "WS_MAXIMIZEBOX");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_MAXIMIZEBOX;
			}
			else if
				((testValue & WS_CAPTION) == WS_CAPTION) {
				strcpy(styleText, "WS_CAPTION");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CAPTION;
			}
			else if
				((testValue & WS_BORDER) == WS_BORDER) {
				strcpy(styleText, "WS_BORDER");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_BORDER;
			}
			else if
				((testValue & WS_DLGFRAME) == WS_DLGFRAME) {
				strcpy(styleText, "WS_DLGFRAME");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_DLGFRAME;
			}
			else if
				((testValue & WS_VSCROLL) == WS_VSCROLL) {
				strcpy(styleText, "WS_VSCROLL");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_VSCROLL;
			}
			else if
				((testValue & WS_HSCROLL) == WS_HSCROLL) {
				strcpy(styleText, "WS_HSCROLL");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_HSCROLL;
			}
			else if
				((testValue & WS_SYSMENU) == WS_SYSMENU) {
				strcpy(styleText, "WS_SYSMENU");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_SYSMENU;
			}

			if (bFoundOne) {
				PA_ResizeArray(&styles, i);
				PA_SetTextInArray(styles, i, styleText, strlen(styleText));
			}
			i++;
		} // end while

		if (testValue == 0) {
			strcpy(styleText, "WS_OVERLAPPED");
			PA_ResizeArray(&styles, i);
			PA_SetTextInArray(styles, i, styleText, strlen(styleText));
		}

		PA_SetVariableParameter(params, 2, styles, 0);
	}
	PA_ReturnLong(params, returnValue);
}
Example #22
0
// ------------------------------------------------
//
//  FUNCTION: sys_GetDocumentList( PA_PluginParameters params )
//
//  PURPOSE:  Return a list of files in a directory.
//
//	DATE:	  MJG 6/4/04 (3.6)
//
//  UPDATES:  MJG 7/5/05 (3.6.2)  Updated to set the 4D variable, Error,
//								  when an error occurs.
//
//			  AMS 9/16/14 #40405 (6.4)  Updated to return the oldest entries first
//		   								 and take in a starting index for specifying
//										 where the list of returned files begins.
//
//
// ------------------------------------------------
void sys_GetDocumentList(PA_PluginParameters params)
{
	LONG lReturnValue = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG lFileCount = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG lArraySize = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG lEndIndex = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG lCount = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	const LONG lFileLimit = 1000;
	char fullPath[MAXBUF];
	WIN32_FIND_DATA fFindData;
	DWORD ret = 0;
	DWORD lastError = 0;
	HANDLE NextFind = 0;
	BOOL bGetAllFiles = FALSE;
	WIN32_FIND_DATA fileList[1000];

	// parameter variables
	char *patPathName = NULL;
	char *patFilePattern = NULL;
	LONG palMaxFilesToReturn = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG palFileSort = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	LONG palStartIndex = 0; // WJF 6/30/16 Win-21 LONG_PTR -> LONG
	PA_Variable paReturnFileList;

	// Get the function parameters.
	patPathName = getTextParameter(params, 1);
	patFilePattern = getTextParameter(params, 2);
	paReturnFileList = PA_GetVariableParameter(params, 3);
	palMaxFilesToReturn = PA_GetLongParameter(params, 4);
	palFileSort = PA_GetLongParameter(params, 5);  // AMS2 9/30/14 #40405  Moved the sort parameter to be before start index
	palStartIndex = PA_GetLongParameter(params, 6);  // AMS2 9/16/14 #40405

	// Clear out the return array.
	PA_ResizeArray(&paReturnFileList, 0);

	// AMS2 9/19/14 #40405 Passing in the start index is optional, if a value is passed in then it is assumed that the user put in a number relative to a starting index of 1 instead of 0 for c/c++ arrays
	if ((palStartIndex != 0) || (palStartIndex > 0)) // WJF 6/24/16 Win-21 NULL -> 0
	{
		palStartIndex--;
	}
	else{
		palStartIndex = 0;
	}

	// WJF 4/7/15 #41624 If they haven't chosen a valid sort option, set to default
	if ((palFileSort != 1) && (palFileSort != 2))
	{
		palFileSort = 0;
	}

	if (patPathName != NULL && patFilePattern != NULL)
	{
		// Check if the path is valid.
		ret = GetFileAttributes(patPathName);

		if ((ret & FILE_ATTRIBUTE_DIRECTORY) != 0 && ret != INVALID_DIRECTORY)
		{
			// Build the full path name.
			if (patFilePattern[0] == '\0')
			{
				snprintf(fullPath, MAXBUF, "%s%s*.*", patPathName, patPathName[strlen(patPathName) - 1] == PATHCHAR ? "" : PATHSTR);
			}
			else
			{
				snprintf(fullPath, MAXBUF, "%s%s%s", patPathName, patPathName[strlen(patPathName) - 1] == PATHCHAR ? "" : PATHSTR, patFilePattern);
			}

			// Get the first file.
			NextFind = FindFirstFile(fullPath, &fFindData);

			if (NextFind != INVALID_HANDLE_VALUE)
			{
				// AMS2 9/18/14 #40405  Loop through the files in the directory and build a list to sort. Currently the max files that can be stored from a directory is 1000.
				lastError = ERROR_NO_MORE_FILES;
				bGetAllFiles = (palMaxFilesToReturn <= 0);

				while ((NextFind != INVALID_HANDLE_VALUE) && (lFileCount < lFileLimit))
				{
					if ((fFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
					{
						// AMS2 9/19/14 #40405 When a file match is found, insert it into the file list array.
						fileList[lFileCount] = fFindData;
						lFileCount++;   // Count the number of files that match the pattern.
					}
					if (!FindNextFile(NextFind, &fFindData))
					{
						lastError = GetLastError();
						break;
					}
				} // end while

				// AMS2 9/18/14 #40405 Sort the array using compareFileTimeCreation which takes in two win32 find data variables and compares their creation dates.
				if (palFileSort == 1)
				{
					qsort(fileList, lFileCount, sizeof(WIN32_FIND_DATA), (int(*)(const void*, const void*))compareFileTimeCreation);
				}
				else if (palFileSort == 2) // WJF 4/7/15 #41624 Sorty by alphabetical order
				{
					qsort(fileList, lFileCount, sizeof(WIN32_FIND_DATA), (int(*)(const void*, const void*))compareAlphabetical);
				}

				// AMS2 9/18/14 #40405 Get all of the files if 0 is passed for the max files parameter.
				if (palMaxFilesToReturn == 0)
				{
					palMaxFilesToReturn = lFileCount;
				}

				// AMS2 9/18/14 #40405 If the start index or end index is out of range, then set them to the file count.
				if (palStartIndex > lFileCount)
				{
					palStartIndex = lFileCount;
				}

				lEndIndex = palMaxFilesToReturn + palStartIndex;

				if (lEndIndex > lFileCount)
				{
					lEndIndex = lFileCount;
				}

				// AMS2 9/22/14 #40405 As long as the end index is within the file limit, insert the requested file names into the return array
				// starting at the specified start index  and end at the start index + the max number of files to return.
				if (lEndIndex <= lFileLimit)
				{
					for (int i = palStartIndex; i < lEndIndex; i++)
					{
						lCount++;
						if (lCount > lArraySize)
						{
							// Increase the size of the array.
							lArraySize = lCount + ARRAY_LOAD_VALUE;
							PA_ResizeArray(&paReturnFileList, lArraySize);
						}

						PA_SetTextInArray(paReturnFileList, lCount, fileList[i].cFileName, strlen(fileList[i].cFileName));
					}
				}
			}
			else
			{
				lastError = GetLastError();
			}

			FindClose(NextFind);
		}
		else
		{
			lastError = GetLastError();
		}
	}

	if (lastError == ERROR_NO_MORE_FILES || lastError == ERROR_FILE_NOT_FOUND)
	{
		setError(0);
		PA_ResizeArray(&paReturnFileList, lCount);  // AMS2 9/22/14 #40405 When the file selection has finished with no more files in the dir or a file has not been found, resize the return array to the number of files inserted into the array.
		lReturnValue = 1;
	}
	else
	{
		setError(lastError);
		PA_ResizeArray(&paReturnFileList, 0);
	}

	PA_SetVariableParameter(params, 3, paReturnFileList, 0);

	freeTextParameter(patPathName);
	freeTextParameter(patFilePattern);

	PA_ReturnLong(params, lReturnValue);
}
Example #23
0
//
//  FUNCTION: gui_SetTrayIcon( PA_PluginParameters params )
//
//  PURPOSE:	Put an icon in system tray
//
//  COMMENTS:	Flags and action determine what happens: Add, modify, delete, tool tip etc
//						Not available for pre-6.7 4D
//	IMPORTANT	NOTE: This and sys_GetPrintJob use the same subclassed window procedure.
//									You cannot arbitrarily delete the function newProc
//									without breaking sys_GetPrintJob.
//
//	DATE:			dcc 08/04/01
//
void gui_SetTrayIcon( PA_PluginParameters params )
{
    UINT							iconHndl = 0;
    NOTIFYICONDATA		nid;
    PNOTIFYICONDATA		pnid;
    LONG_PTR							returnValue = 0, iconID = 0, flags = 0, action = 0;
    char							szTipParam[60], szBalloonInfo[255], szBalloonTitle[60];
    char							*pBalloonIconFlag;
    LONG_PTR							arraySize = 0, procNbr = 0, storedProcNbr = 0, nbrParams = 0;
    LONG_PTR							index;
    LONG_PTR							errCode = 0;
    BOOL							bFuncReturn = FALSE;
    BOOL							shellOK = FALSE;
    //HWND							hWnd;
    LONG_PTR count = -10;

    activeCalls.bTrayIcons = TRUE;

    pnid = &nid;

    count = count % 5;

    if ((sIsPriorTo67)) { // does not work with 6.5 plugin
        PA_ReturnLong( params,  -1 );
        return;
    }

    //hWnd = (HWND)PA_GetHWND(PA_GetWindowFocused());  // 3/2/04 Unnecessary

    nbrParams = getTrayIconParams(params, &action, &flags, &iconID, &procNbr,
                                  &iconHndl, szTipParam, szBalloonInfo, szBalloonTitle);
    index = findIconID( &startPtr, iconID, &storedProcNbr );
    if (index == 0) { // not found

        if (isEmpty(startPtr)) {
            //processHandles.wpFourDOrigProc = (WNDPROC) SetWindowLong(windowHandles.fourDhWnd, GWL_WNDPROC, (LONG) newProc);
            // MJG 3/26/04 Replaced code above with function call.
            subclass4DWindowProcess();
        }

        //add element to array
        bFuncReturn = insertIcon( &startPtr, iconID, procNbr);

    } else {
        if ((action == NIM_MODIFY) & (storedProcNbr != procNbr)) {
            // process nbr changed and modify request has been explicitly made
            bFuncReturn = updateIconIdProcNbr( &startPtr, iconID, procNbr );
        }
    } //end if (index == 0)

    // must have version 5 of shell 32 for balloon feature
    // NOTIFYICONDATA structure is larger for balloon feature
    // also must be W2K for balloons
    if(GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(5,00))
    {
        shellOK = TRUE;
    }

    if (shellOK) {
        if ((action >= 0) & (flags >= 0x010)) {
            nid.dwInfoFlags = 0;
            strcpy(nid.szInfo, szBalloonInfo);

            switch (szBalloonTitle[0]) // leading 1, 2, 0r 3 causes addition of icon
            {
            case '1' :
                pBalloonIconFlag = &szBalloonTitle[1];
                if (*pBalloonIconFlag != '\0') {
                    strcpy(nid.szInfoTitle, pBalloonIconFlag);
                    nid.dwInfoFlags = NIIF_INFO;
                }
                break;

            case '2' :
                pBalloonIconFlag = &szBalloonTitle[1];
                if (*pBalloonIconFlag != '\0') {
                    strcpy(nid.szInfoTitle, pBalloonIconFlag);
                    nid.dwInfoFlags = NIIF_WARNING;
                }
                break;

            case '3' :
                pBalloonIconFlag = &szBalloonTitle[1];
                if (*pBalloonIconFlag != '\0') {
                    strcpy(nid.szInfoTitle, pBalloonIconFlag);
                    nid.dwInfoFlags = NIIF_ERROR;
                }
                break;
            default :
                strcpy(nid.szInfoTitle, szBalloonTitle);
            }

            nid.uTimeout = 10;

            if (flags & NIF_HIDE) {
                flags = flags & 0x001F;
                flags = flags | NIF_STATE;
                nid.dwState = NIS_HIDDEN;
                nid.dwStateMask = NIS_HIDDEN;
            } else {
                if (flags & NIF_SHOW) {
                    flags = flags & 0x001F;
                    flags = flags | NIF_STATE;
                    nid.dwState = 0;
                    nid.dwStateMask = NIS_HIDDEN;
                }
            }
        }
    } else {
        flags = (flags & 0xF); // must not send balloon flag when version not Win2K or above
    }

    nid.cbSize = sizeof(NOTIFYICONDATA);
    nid.hWnd = windowHandles.fourDhWnd;
    nid.uID = iconID;
    strcpy(nid.szTip, szTipParam); // can use this if balloon feature not available or not wanted
    nid.uVersion = 0; // REB 3/3/09 #16207
    nid.uFlags = flags; // REB 2/18/10 #22656

    switch (action)
    {
    case NIM_ADD :
    case NIM_MODIFY :
    case NIM_SETFOCUS :
    case NIM_SETVERSION :
        nid.uFlags = flags;
        nid.hIcon = (HICON)iconHndl;
        if (flags & NIF_MESSAGE) {
            nid.uCallbackMessage = WM_USER + 0x0021; // hex 21 is purely arbitrary
        } else {
            nid.uCallbackMessage = WM_NULL;
        }
        break;

    case NIM_DELETE :
        //if (index != 0) { // MJG 3/2/04 The element will still exist even if index is zero.
        returnValue = deleteIcon(&startPtr, iconID);
        //}
    }

    //bFuncReturn = Shell_NotifyIcon(NIM_SETVERSION,  pnid); // REB 3/3/09 #16207 Force Win95 icon handling.
    bFuncReturn = Shell_NotifyIcon(action,  pnid);

    //errCode = GetLastError();
    //PA_ReturnLong( params, errCode );
    PA_ReturnLong( params, (LONG_PTR)bFuncReturn );

}
Example #24
0
void sys_PrintDirect2Driver( PA_PluginParameters params )
{
	PRINTDLG pd;                      // Structure to hold information about printer
	DOCINFO di;                       // Structure to hold "document" information
	char printerName[MAXBUF] = "";    // String to hold the printerName param ($1)
	char data[MAXLABELBUF] = "";      // String to hold the data param ($2) REB 6/5/08 #17022 Changed MAXBUF to MAXLABELBUF which is twice as big.
	char *origDefault;                // String to hold the original default printer
	INT_PTR printerName_len;              // Int to hold maximum length of printer name
	INT_PTR ret;                          // Int to hold return value of functions                 
	INT_PTR iErrCode = 0;                 // Int to hold the error code.
	ULONG_PTR ulBytesNeeded;      // Holds size information

	// Set needed bytes to default value
	ulBytesNeeded = MAXLABELBUF; // REB 6/5/08 #17022 Changed MAXBUF to MAXLABELBUF

	// Set this to 255.
	printerName_len = 255;

	// Get the function parameters.
	PA_GetTextParameter(params, 1, printerName);
	PA_GetTextParameter(params, 2, data);

	// Allocate memory for Storing string for Original Default Printer & pBuf
	origDefault = (char *)malloc(ulBytesNeeded);
	memset(origDefault, 0, ulBytesNeeded);
	
    // Get name of current Default Printer
	GetDefaultPrinter(origDefault, &ulBytesNeeded);
    
	// Set the new Default Printer to our label printer, with the name obtained from the registry
	ret = SetDefaultPrinter((char *)printerName);
	
	// We set the default printer just fine, now let's do the printing.
	if (ret != 0)
	{
		            
  	// Allocate memory for PRINTDLG structure
	  memset( &pd, 0, sizeof( pd ) );

	  // Define properties of the PRINTDLG structure
	  pd.lStructSize = sizeof( pd );

	  // PD_RETURNDEFAULT causes the PrintDlg function to automatically use the properties from
	  // the default printer.  PD_RETURNDC causes the function to return the device context
	  // for the printer.  This device context allows us to print a label
	  pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;

		// These two structures must be NULL to use the PD_RETURNDC flag.
		// Do this explicitly, just in case
		pd.hDevMode = NULL;
		pd.hDevNames = NULL;
			
	  // Retrieve the Device Context.  It will be accessible as a member of the PRINTDLG structure
	  if(!PrintDlg( &pd ))
		{
			// Get the error from the common dialog box
			// Error code will not work properly with FormatMessage, so use this instead.
		  iErrCode = CommDlgExtendedError();
		}
		
		if(iErrCode == 0)
		{
      // Initialize the DOCINFO structure
      memset(&di, 0, sizeof(di));
      di.cbSize = sizeof(DOCINFO);
	  	di.lpszDocName = "Label"; 
      di.lpszOutput = (LPTSTR) NULL; 
      di.lpszDatatype = "raw";
      di.fwType = 0; 
    	
	  	// Start a document in the print spooler
	  	if(!StartDoc(pd.hDC, &di))
			{
	  	  iErrCode = GetLastError();
			} // end if
		}
					
		if(iErrCode == 0)
		{
		  // Start a new page in the print spooler
	    if(!StartPage(pd.hDC))
			{
			  iErrCode = GetLastError();
			} // end if !
		}

		if(iErrCode == 0)
		{
		  if(!TextOut(pd.hDC, 1, 1, data, strlen(data)))
			{
			  iErrCode = GetLastError();
			}
		}

		// De-allocate commandList
		
		// Let the print spooler know that the page is done
		EndPage(pd.hDC);
			
    // Let the print spooler know that the document is done
	  EndDoc(pd.hDC);
			
		
		// Delete the Device Context
		DeleteDC(pd.hDC);
			
		
		// Now reset our default printer.
    
		// Set the Default Printer back to the original.
  		ret = SetDefaultPrinter(origDefault);

		PA_ReturnLong(params, (LONG_PTR)iErrCode); 
	} else {
	  PA_ReturnLong(params, (LONG_PTR)GetLastError());
	}	// end if
}//end function
Example #25
0
// ------------------------------------------------
// 
//  FUNCTION: sys_GetRegEnum( PA_PluginParameters params )
//
//  PURPOSE:  Get a key from the registry.
//        
//	DATE:	  MJG 12/4/03 (3.5.6)
//
void sys_GetRegEnum( PA_PluginParameters params )
{
	LONG_PTR returnValue, regKey, retErr;
	char regSub[MAXBUF];
	LONG_PTR regBufSize = MAX_REG_SIZE;
	CHAR regBuf[MAX_REG_SIZE]; 

	FILETIME ftLastWriteTime;
	HKEY hRootKey;
	HKEY hOpenKey;
	DWORD dwSubKeys;
	DWORD dwValues;
	DWORD i, j;
	PA_Variable paReturnArray1;
	PA_Variable paReturnArray2;

	dwSubKeys = dwValues = 0;
	returnValue = regKey = retErr = 0;
	hRootKey = hOpenKey = 0;
	memset(regSub, 0, MAXBUF);

	// Get the function parameters.
	regKey = PA_GetLongParameter( params, 1 );
	PA_GetTextParameter( params, 2, regSub );
	paReturnArray1 = PA_GetVariableParameter( params, 3 );
	paReturnArray2 = PA_GetVariableParameter( params, 4 );
	
	PA_ResizeArray(&paReturnArray1, 0);
	PA_ResizeArray(&paReturnArray2, 0);

	// Convert the 4d registry constant into a Windows registry key.
	hRootKey = getRootKey( regKey );

	// Open the registry key.
	retErr = RegOpenKeyEx(hRootKey, regSub, 0, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE , &hOpenKey);
	
	if(retErr == ERROR_SUCCESS){
		
		retErr = RegQueryInfoKey(hOpenKey, NULL, NULL, NULL, &dwSubKeys, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL); 
		
		if( retErr == ERROR_SUCCESS)
		{
			// Enumerate the subkey names.
			
			if (dwSubKeys)
			{
				retErr = ERROR_SUCCESS;
				PA_ResizeArray(&paReturnArray1, dwSubKeys);
				
				for (i=0,j=0; i<dwSubKeys; i++) 
				{ 
					regBufSize = MAX_REG_SIZE;
					retErr = RegEnumKeyEx(hOpenKey, i, regBuf, &regBufSize, NULL, NULL, NULL, &ftLastWriteTime); 
					
					if (retErr == ERROR_SUCCESS) 
					{
						PA_SetTextInArray(paReturnArray1, ++j, regBuf, regBufSize);
					}
				}
			} 
			
			// Enumerate the key value names. 
			if (dwValues) 
			{
				retErr = ERROR_SUCCESS;
				PA_ResizeArray(&paReturnArray2, dwValues);
				
				for (i=0,j=0; i<dwValues; i++) 
				{ 
					regBufSize = MAX_REG_SIZE;
					regBuf[0] = '\0'; 
					retErr = RegEnumValue(hOpenKey, i, regBuf, &regBufSize, NULL, NULL, NULL, NULL);
					
					if (retErr == ERROR_SUCCESS ) 
					{ 
						PA_SetTextInArray(paReturnArray2, ++j, regBuf, regBufSize);
					} 
				}
			}

			returnValue = 1;
		}
	} 
	
	PA_SetVariableParameter( params, 3, paReturnArray1, 0 );
	PA_SetVariableParameter( params, 4, paReturnArray2, 0 );
	
	RegCloseKey( hOpenKey );

	PA_ReturnLong( params, returnValue );
}
Example #26
0
void sys_KillProcessByName( PA_PluginParameters params )
{
	HANDLE hProcessSnap;              // Handle to the process snapshot
	HANDLE hProcess;                  // Handle to the process itself
	PROCESSENTRY32 pe32;              // ProcessEntry to get info about processes
  char processName[MAXBUF] = "";    // String to hold the printerName param ($1)
	LONG_PTR lMode = 1;                   // Long to hold the working mode ($2)
	                                  // 1 = just first process matching name
	                                  // 2 = all processes matching name
	BOOL bCleanFirst = FALSE;         // Boolean to see if we should try to cleanly close the app
	                                  // before killing it mercilessly
	BOOL bOrigCleanFirst = FALSE;     // Keeps track of original bCleanFirst value
	                                  // to reset between loop iterations ($3)
	BOOL bDone = FALSE;               // This will keep track of whether or not we are finished
	                                  // Looping through processes.
	// Get the function parameters.
	PA_GetTextParameter(params, 1, processName);
	lMode = PA_GetLongParameter(params, 2);
	bOrigCleanFirst = (PA_GetLongParameter(params, 3) == 1 ? TRUE : FALSE);

  // Take a snapshot of all processes in the system.
	// If we fail, return the error code
  hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  if(hProcessSnap == INVALID_HANDLE_VALUE)
  {
    PA_ReturnLong(params, (LONG_PTR)GetLastError());
		return;
  }

	// Set the size of the structure before using it.
  pe32.dwSize = sizeof( PROCESSENTRY32 );

  // Retrieve information about the first process,
  // If we can't do it, then return the error code
  if(!Process32First( hProcessSnap, &pe32))
  {
    CloseHandle( hProcessSnap );     // Must clean up the snapshot object!
    PA_ReturnLong(params, (LONG_PTR)GetLastError());
		return;
  }

  // Now walk the snapshot of processes, and
  // display information about each process in turn
  do
  {
    
		// Check the name
		if (strcmp(pe32.szExeFile, processName) == 0)
		{

			bCleanFirst = bOrigCleanFirst;
		  // Get the process
		  // We need to make sure that we have the TERMINATE right
      hProcess = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pe32.th32ProcessID);
			
			// Couldn't get the process
			// Clean up the handle
			// and return the error
      if(hProcess == NULL) {
				CloseHandle(hProcessSnap);
        PA_ReturnLong(params, (LONG_PTR)GetLastError());
			  return;
			}

			if(bCleanFirst)
			{
        // TerminateClean() posts WM_CLOSE to all windows whose PID
        // matches your process's.
        EnumWindows((WNDENUMPROC)TerminateClean, (LPARAM) pe32.th32ProcessID) ;

				if(WaitForSingleObject(hProcess, 500)!=WAIT_OBJECT_0)
				{
          bCleanFirst = TRUE;
				}
			}

			if(!bCleanFirst)
			{
        // Kill the process
        if(TerminateProcess(hProcess, 1)) {;
			    // Success!
			    // If we're in mode 1 then we are finished
			    // If not, then we will need to keep going
  			  if(lMode == 1) {
	  			  bDone = TRUE;
					} // end 
				} else {
          // Fail!
				  // Clean up and return the error
          CloseHandle(hProcess);
				  CloseHandle(hProcessSnap);
				  PA_ReturnLong(params, (LONG_PTR)GetLastError());
				  return;
				}
			}

			// Close our handle
      CloseHandle(hProcess);
    } // end if
		Process32Next(hProcessSnap, &pe32); // WJF 6/2/15 #42839 Moved out of while condition

  } while((GetLastError()!=18) && (!bDone)); // WJF 6/2/15 #42839 Added GetLastError Check, corrected logical or syntax, and added inversion to bDone

	// Close the handle and return success
  CloseHandle(hProcessSnap);
  PA_ReturnLong(params, -1 * (LONG_PTR)bCleanFirst);
}
Example #27
0
void sys_EnumProcesses( PA_PluginParameters params )
{
	HANDLE hProcessSnap;              // Handle to the process snapshot
	PROCESSENTRY32 pe32;              // ProcessEntry to get info about processes
  
	PA_Variable paNameArray;          // Array to store process names ($1)
	PA_Variable paIDArray;            // Array to store process IDs ($2)

	INT_PTR iSize = 0;                    // Int to control size of array

  // Get variables representing passed in arrays
	paNameArray = PA_GetVariableParameter(params, 1);
	paIDArray = PA_GetVariableParameter(params, 2);
	
	// Resize arrays to 0
	PA_ResizeArray(&paNameArray, iSize);
	PA_ResizeArray(&paIDArray, iSize);

  // Take a snapshot of all processes in the system.
	// If we fail, return the error code
  hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  if(hProcessSnap == INVALID_HANDLE_VALUE)
  {
    PA_ReturnLong(params, (LONG_PTR)GetLastError());
		return;
  }

	// Set the size of the structure before using it.
  pe32.dwSize = sizeof( PROCESSENTRY32 );

  // Retrieve information about the first process,
  // If we can't do it, then return the error code
  if(!Process32First( hProcessSnap, &pe32))
  {
    CloseHandle( hProcessSnap );     // Must clean up the snapshot object!
    PA_ReturnLong(params, (LONG_PTR)GetLastError());
		return;
  }

  // Now walk the snapshot of processes, and
  // Insert an array element in each array, one for name and one for ID.
  do
  {
    iSize++; 
		PA_ResizeArray(&paNameArray, iSize);
	  PA_ResizeArray(&paIDArray, iSize);
		PA_SetTextInArray(paNameArray, iSize, pe32.szExeFile, strlen(pe32.szExeFile));
		PA_SetLongintInArray(paIDArray, iSize, pe32.th32ProcessID);
		
	} while(Process32Next(hProcessSnap, &pe32));

	// Close the handle and return success
  CloseHandle(hProcessSnap);

	// Set return arrays
	PA_SetVariableParameter(params, 1, paNameArray, 0);
	PA_SetVariableParameter(params, 2, paIDArray, 0);

	// Return error code.
	PA_ReturnLong(params, 0);
}
Example #28
0
// ------------------------------------------------
// 
//  FUNCTION: gui_SelectColor( PA_PluginParameters params)
//
//  PURPOSE:  Displays the color common dialog
//
//  COMMENTS:	
//						
//        
//	DATE:	  dcc 11/25/02 (3.5.3)
//
//	MODIFICATIONS:
//
void gui_SelectColor( PA_PluginParameters params)
{
	CHOOSECOLOR			cColor;
	static COLORREF		acrCustColor[16];
	static DWORD		rgbCurrent;
	LONG_PTR				rParam, gParam, bParam, returnValue = 0, i, hasCustom;
	PA_Variable			custColorArray;
	
	rParam = PA_GetLongParameter( params, 1); 
	gParam = PA_GetLongParameter( params, 2); 
	bParam = PA_GetLongParameter( params, 3);
	hasCustom   = PA_GetLongParameter( params, 4);

	if (rParam > 255) rParam = 0;
	if (gParam > 255) gParam = 0;
	if (bParam > 255) bParam = 0;

	if (hasCustom == 1) {
		custColorArray = PA_GetVariableParameter( params, 5 );
		if(PA_GetVariableKind(custColorArray) == eVK_ArrayLongint) {
			for (i = 0; i < PA_GetArrayNbElements(custColorArray); i++)
			{
				acrCustColor[i] = PA_GetLongintInArray(custColorArray, i + 1);
			}
		}
	}
	ZeroMemory(&cColor, sizeof(CHOOSECOLOR));
	cColor.lStructSize		= sizeof(CHOOSECOLOR);
	cColor.hwndOwner			= windowHandles.fourDhWnd;
	cColor.lpCustColors		= (LPDWORD) acrCustColor;
	cColor.rgbResult			= rgbCurrent;

	if ((rParam > 0) || (gParam > 0) || (bParam > 0)) {
		cColor.rgbResult = RGB(rParam, gParam, bParam);
		cColor.Flags = CC_FULLOPEN | CC_RGBINIT;
	} else {
		cColor.Flags = CC_FULLOPEN;
	}
	
	if (ChooseColor(&cColor)== TRUE) {
		rgbCurrent = cColor.rgbResult;

		rParam = GetRValue(rgbCurrent);
		gParam = GetGValue(rgbCurrent);
		bParam = GetBValue(rgbCurrent);
		
		PA_SetLongParameter( params, 1, rParam );
		PA_SetLongParameter( params, 2, gParam );
		PA_SetLongParameter( params, 3, bParam );

		if (hasCustom == 1) {
			PA_ResizeArray(&custColorArray, 16);
			for (i = 0; i < 16; i++)
			{
				PA_SetLongintInArray(custColorArray, i + 1, acrCustColor[i]);
			}
			PA_SetVariableParameter( params, 5, custColorArray, 0);
		}
		returnValue = 1;
	}

	PA_ReturnLong( params, returnValue);

}
Example #29
0
// ------------------------------------------------
// 
//  FUNCTION: gui_GetWindowStyle( PA_PluginParameters params)
//
//  PURPOSE:	Get window styles
//
//  COMMENTS:	outputs in array the applicable styles for the window
//						Returns via return code the LONG_PTR representing the value
//        
//	DATE:			dcc 07/18/02 dcc
//
//	MODIFICATIONS: 
//
void gui_GetWindowStyle	( PA_PluginParameters params )
{
	PA_Variable			styles;
	LONG_PTR						returnValue = 0, testValue = 0, i;
	HWND						hWnd;
	char						styleText[40];
	BOOL						bFoundOne;


	hWnd = (HWND) PA_GetLongParameter( params, 1); 
	if (IsWindow(hWnd)) {
		styles = PA_GetVariableParameter( params, 2 );

		returnValue = GetWindowLong(hWnd, GWL_STYLE);
		testValue = returnValue;

		//and all styles to see what the window uses
		i = 1;
		while ((testValue != 0) && (i <= NUMBER_STYLES))
		{
			bFoundOne = FALSE;
		
			if ((testValue & WS_THICKFRAME) == WS_THICKFRAME) {
				strcpy(styleText, "WS_THICKFRAME");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_THICKFRAME;
			} else if 
				((testValue & WS_POPUP) == WS_POPUP) {
				strcpy(styleText, "WS_POPUP");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_POPUP;
			} else if
				((testValue & WS_CHILD) == WS_CHILD) {
				strcpy(styleText, "WS_CHILD");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CHILD;
			} else if
				((testValue & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) {
				strcpy(styleText, "WS_MINIMIZEBOX");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_MINIMIZEBOX;
			} else if
				((testValue & WS_VISIBLE) == WS_VISIBLE) {
				strcpy(styleText, "WS_VISIBLE");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_VISIBLE;
			} else if
				((testValue & WS_DISABLED) == WS_DISABLED) {
				strcpy(styleText, "WS_DISABLED");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_DISABLED;
			} else if
				((testValue & WS_CLIPSIBLINGS) == WS_CLIPSIBLINGS) {
				strcpy(styleText, "WS_CLIPSIBLINGS");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CLIPSIBLINGS;
			} else if
				((testValue & WS_CLIPCHILDREN) == WS_CLIPCHILDREN) {
				strcpy(styleText, "WS_CLIPCHILDREN");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CLIPCHILDREN;
			} else if
				((testValue & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) {
				strcpy(styleText, "WS_MAXIMIZEBOX");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_MAXIMIZEBOX;
			} else if
				((testValue & WS_CAPTION) == WS_CAPTION) {
				strcpy(styleText, "WS_CAPTION");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_CAPTION;
			} else if
				((testValue & WS_BORDER) == WS_BORDER) {
				strcpy(styleText, "WS_BORDER");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_BORDER;
			} else if
				((testValue & WS_DLGFRAME) == WS_DLGFRAME) {
				strcpy(styleText, "WS_DLGFRAME");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_DLGFRAME;
			} else if
				((testValue & WS_VSCROLL) == WS_VSCROLL) {
				strcpy(styleText, "WS_VSCROLL");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_VSCROLL;
			} else if
				((testValue & WS_HSCROLL) == WS_HSCROLL) {
				strcpy(styleText, "WS_HSCROLL");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_HSCROLL;
			} else if
				((testValue & WS_SYSMENU) == WS_SYSMENU) {
				strcpy(styleText, "WS_SYSMENU");
				bFoundOne = TRUE;
				testValue = testValue ^ WS_SYSMENU;
			} 

			if (bFoundOne) {
				PA_ResizeArray (&styles, i);
				PA_SetTextInArray (styles, i, styleText, strlen(styleText));
			}
			i++;
		} // end while

		if (testValue == 0) {
			strcpy(styleText, "WS_OVERLAPPED");
			PA_ResizeArray (&styles, i);
			PA_SetTextInArray (styles, i, styleText, strlen(styleText));
		}

		PA_SetVariableParameter( params, 2, styles, 0 );
	}
	PA_ReturnLong( params, returnValue );

}
Example #30
0
// ------------------------------------------------
// 
//  FUNCTION: gui_RespectToolBar( PA_PluginParameters params )
//
//  PURPOSE:  Function to intecept maximize event in the 
//						ProToolsProc.  There the window maximized 
//						size is reduced by the number of pixels
//						passed into the function. 
//
//  COMMENTS:	This has been experimented with but should be tested
//						more thoroughly.  Some situations still cause a max'd
//						window to resize under a toolbar. Noticed in particular
//						when a new process window pops up over another process's 
//						max'd window.  This is left for an excersize for some adventurous
//						soul.
//        
//	DATE:			dcc 01/16/03 (3.5.4)
//
//	MODIFICATIONS:
//
void gui_RespectToolBar( PA_PluginParameters params )
{
	LONG_PTR					position_len = 0, tbRestriction = 0;
	LONG_PTR					trackingRestriction = 0, processNbr;
	char					position[2];
	INT_PTR						theChar;


	tbRestriction	 = PA_GetLongParameter( params, 1); 
	position_len			 = PA_GetTextParameter( params, 2, position );
	position[position_len]	 = '\0';
	if (position_len > 1) {
		position[1] = '\0';
	}
	_strlwr(position);

	if (position_len == 0) {	// pass a negative in and turns it all off
		toolBarRestrictions.toolBarOnDeck = 0;
		//restoreOrig4DWindowProcess(); // MJG 3/26/04 The 4D window will remain subclassed until the plug-in is unloaded.
		PA_ReturnLong( params, toolBarRestrictions.toolBarOnDeck);
		return;
	}

	trackingRestriction = PA_GetLongParameter( params, 3);
	toolBarRestrictions.trackingRestriction  = trackingRestriction;

	if ((tbRestriction != 0) &&  (strpbrk(position, "ltrb") != NULL)) {
		toolBarRestrictions.toolBarOnDeck = 1;
		theChar = (INT_PTR) position[0];
	}

	processNbr = PA_GetCurrentProcessNumber();

	switch (theChar)
	{
		case 'l' :
			toolBarRestrictions.left = tbRestriction;
			toolBarRestrictions.leftProcessNbr = processNbr;
			break;

		case 't' :
			toolBarRestrictions.top = tbRestriction;
			toolBarRestrictions.topProcessNbr = processNbr;
			break;
		case 'r' :
			toolBarRestrictions.right = tbRestriction;
			toolBarRestrictions.rightProcessNbr = processNbr;
			break;

		case 'b' :
			toolBarRestrictions.bottom = tbRestriction;
			toolBarRestrictions.bottomProcessNbr = processNbr;
			break;
	}

	toolBarRestrictions.appBeingMaxed = 0;
  
	//if (processHandles.wpFourDOrigProc == NULL) {
	//	processHandles.wpFourDOrigProc = (WNDPROC) SetWindowLong(windowHandles.fourDhWnd, GWL_WNDPROC, (LONG) newProc);
	//}
	// MJG 3/26/04 Replaced code above with function call.
	subclass4DWindowProcess();

	PA_ReturnLong( params, toolBarRestrictions.toolBarOnDeck);
}