コード例 #1
0
ファイル: TrayIcon.c プロジェクト: HerveRICHON/4D-Win32API
void processWindowMessage(LONG_PTR source, LONG_PTR hwnd, WPARAM wParam, LPARAM lParam)
{
    char							procVar[30] = ST_TRAYNOTIFICATION;
    LONG_PTR							procNbr = 0;
    PA_Variable						fourDVar;
    BOOL							bFuncReturn;


    bFuncReturn = SetForegroundWindow(windowHandles.fourDhWnd);
    switch (source)
    {
    case TRAY_ICON_FUNCTION :
        if( ( PA_Get4DVersion() & 0x0000FFFF ) < 0x00001100 ) {
            // REB #17503 8/8/08 in v11 we can no longer call PA_GetVariable from this subclass.
            //   Instead of setting the ST_TRAYNOTIFICATION variable, we will just do a call
            //   back to the monitoring process in 4D on double clicks.
            strcpy(procVar, ST_TRAYNOTIFICATION);
            fourDVar = PA_GetVariable(procVar);
            if (PA_GetVariableKind(fourDVar) == eVK_Longint) {
                PA_SetLongintVariable(&fourDVar, lParam);
                PA_SetVariable(procVar, fourDVar, 1);
                findIconID( &startPtr, (LONG_PTR)wParam, &procNbr); // find icon id and get process number
                PA_UpdateProcessVariable(procNbr);
            }
        } else {
            if((lParam==515)|(lParam==518)) {
                findIconID( &startPtr, (LONG_PTR)wParam, &procNbr); // find icon id and get process number
                PA_UpdateProcessVariable(procNbr);
            };
        };
        break;

    case RESPECT_TOOL_BAR_FUNCTION :
        // REB #16207 1/7/09 In v11 we can no longer call PA_GetVariable from this subclass.
        // Unfortunately we won't be able to support use of <>TB_NOTIFICATION anymore.
        if( ( PA_Get4DVersion() & 0x0000FFFF ) < 0x00001100 ) {
            strcpy(procVar, TB_NOTIFICATION);
            fourDVar = PA_GetVariable(procVar);
            if (PA_GetVariableKind(fourDVar) == eVK_ArrayLongint) {
                if (PA_GetArrayNbElements(fourDVar) == 4) {
                    if (toolBarRestrictions.leftProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 1, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.leftProcessNbr);
                    }
                    if (toolBarRestrictions.topProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 2, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.topProcessNbr);
                    }
                    if (toolBarRestrictions.rightProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 3, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.rightProcessNbr);
                    }
                    if (toolBarRestrictions.bottomProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 4, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.bottomProcessNbr);
                    }
                }
            }
        } else {
            // REB 3/29/10 #22878 Since we can't update the TB_NOTIFICATION array, just do a call to the toolbar processes.
            if (toolBarRestrictions.leftProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.leftProcessNbr);
            }
            if (toolBarRestrictions.topProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.topProcessNbr);
            }
            if (toolBarRestrictions.rightProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.rightProcessNbr);
            }
            if (toolBarRestrictions.bottomProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.bottomProcessNbr);
            }
        }

        break;

    }
}
コード例 #2
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);
}
コード例 #3
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);

}