Custom Query


Show under each result:

Results (4 - 6 of 3856)

1 2 3 4 5 6 7 8 9 10 11 12
Ticket Resolution Summary Owner Reporter
#3992 Fixed _WinAPI_DwmSetWindowAttribute() remove child proofing Jpm argumentum <argumentum@…>

_WinAPI_DwmSetWindowAttribute() does not come with an example so is not used much. Looking at it, it would not work nowadays, because only functional enumerators of the time of coding are permitted.

Func _WinAPI_DwmSetWindowAttribute($hWnd, $iAttribute, $iData)
	;Switch $iAttribute ;
	;	Case 2, 3, 4, 6, 7, 8, 10, 11, 12
	;	Case Else
	;		Return SetError(1, 0, 0)
	Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _
			'dword*', $iData, 'dword', 4)
	If @error Then Return SetError(@error, @extended, 0)
	If $aCall[0] Then Return SetError(10, $aCall[0], 0)
	Return 1
EndFunc   ;==>_WinAPI_DwmSetWindowAttribute

I ask to remove the $iAttribute filter.

In , if _WinAPI_DwmSetWindowAttribute() was to be used, it'd fail, due to this filter.

#3991 Completed _SQLite_ForeignKeys Jpm Andreik

Foreign keys are supported by default by pretty much all important relational database engines and it would be nice to have it by default in SQLite as well or at least a way to enable support when a connection it's made. For this I propose this function _SQLite_ForeignKeys() that enable/disable foreign keys support in SQLite or retrives current foreign_key setting if $bFKEnable is set to Default.

; #FUNCTION# ======================================================================================================================
; Name: 		_SQLite_ForeignKeys
; Description: 		Enable or disable foreign key support in SQLite.
; Syntax: 		_SQLite_ForeignKeys([$hDB = Default[, $bFKEnable = Default]])
; Parameters: 		$hDB - a database handle (by default it's used the handle of the last opened database).
;			$bFKEnable - enable foreign key support if this is set to True or disable foreign key support if this is set to False.
; Return value: 	Success - Returns current foreign key setting.
;                  	Failure - Returns a value that can be compared against $SQLITE_* constants.
;					@error = 1 - Cannot retrieve SQLite library version.
;					@error = 2 - Invalid format of SQLite library version.
;					@error = 3 - Current SQLite library version does not support foreign keys.
;					@error = 4 - Cannot retrieve current foreign keys setting (@extended contains the error code returned by _SQLite_QuerySingleRow).
;					@error = 5 - Cannot set foreign keys setting (@extended contains the error code returned by _SQLite_Exec).
; Author: 		Andreik
; Remarks: 		This function can be used to retrieve the current foreign key support in SQLite if $bFKEnable is set to Default.
; Link:
; Example: 		Yes
; ===============================================================================================================================
Func _SQLite_ForeignKeys($hDB = Default, $bFKEnable = Default)
	If $hDB = Default Then $hDB = -1
	; Check if SQLite version it's at least 3.6.19 (minimum version that supports foreign key constraints)
	Local $sVersion = _SQLite_LibVersion()
	If @error Then Return SetError(1, @error, $SQLITE_ERROR)
	Local $aMinVersion = StringSplit('3.6.19', '.')
	Local $aLibVersion = StringSplit($sVersion, '.')
	If $aLibVersion[0] <> 3 Then Return SetError(2, 0, $SQLITE_ERROR)
	For $Index = 1 To $aLibVersion[0]
		If Int($aLibVersion[$Index]) > Int($aMinVersion[$Index]) Then ExitLoop
		If Int($aLibVersion[$Index]) < Int($aMinVersion[$Index]) Then Return SetError(3, 0, $SQLITE_ERROR)
	; $bFKEnable = Default - Return current PRAGMA foreign_keys setting
	If $bFKEnable = Default Then
		Local $aRow
		Local $iQueryRet = _SQLite_QuerySingleRow($hDB, 'PRAGMA foreign_keys', $aRow)
		If @error Then Return SetError(4, @error, $iQueryRet)
		Return SetError(0, 0, $aRow[0] = 1 ? True : False)
	; $bFKEnable = True - Enable foreign keys
	; $bFKEnable = False - Disable foreign keys
	Local $iExecRet = _SQLite_Exec($hDB, 'PRAGMA foreign_keys = ' & ($bFKEnable ? 'ON' : 'OFF') & ';')
    If $iExecRet = $SQLITE_OK Then
        Return SetError(0, 0, $bFKEnable ? True : False)
        Return SetError(5, @error, $iExecRet)
EndFunc   ;==>_SQLite_ForeignKeys

Since this feature must be enable each time at runtime and it's persistent for connection, I propose a new parameter ($bFKEnable) in _SQLite_Open() that can be set to enable foreign keys when a database it's opened. By default this parameter won't modify the actual behavior of _SQLite_Open() unless the $bFKEnable is set to True. So the _SQLite_Open() in this variant should look like this:

Func _SQLite_Open($sDatabase_Filename = Default, $iAccessMode = Default, $iEncoding = Default, $bFKEnable = Default)
	If Not $__g_hDll_SQLite Then Return SetError(3, $SQLITE_MISUSE, 0)
	If $sDatabase_Filename = Default Or Not IsString($sDatabase_Filename) Then $sDatabase_Filename = ":memory:"
	Local $tFilename = __SQLite_StringToUtf8Struct($sDatabase_Filename)
	If @error Then Return SetError(2, @error, 0)
	If $iAccessMode = Default Then $iAccessMode = BitOR($SQLITE_OPEN_READWRITE, $SQLITE_OPEN_CREATE)
	Local $bOldBase = FileExists($sDatabase_Filename) ; encoding cannot be changed if base already exists
	If $iEncoding = Default Then
		$iEncoding = $SQLITE_ENCODING_UTF8
	Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_open_v2", "struct*", $tFilename, _ ; UTF-8 Database filename
			"ptr*", 0, _ ; OUT: SQLite db handle
			"int", $iAccessMode, _ ; database access mode
			"ptr", 0)
	If @error Then Return SetError(1, @error, 0) ; DllCall error
	If $avRval[0] <> $SQLITE_OK Then
		__SQLite_ReportError($avRval[2], "_SQLite_Open")
		Return SetError(-1, $avRval[0], 0)

	$__g_hDB_SQLite = $avRval[2]
	__SQLite_hAdd($__g_ahDBs_SQLite, $avRval[2])
	If Not $bOldBase Then
		Local $aEncoding[3] = ["8", "16", "16be"]
		_SQLite_Exec($avRval[2], 'PRAGMA encoding="UTF-' & $aEncoding[$iEncoding] & '";')
	; Foreign keys support
	; #####################################
	If $bFKEnable = Default Then $bFKEnable = False
	If $bFKEnable Then
		_SQLite_ForeignKeys($avRval[2], $bFKEnable)
		If @error Then
			Local $iError = @error
			Return SetError(4, $iError, 0)
	; #####################################
	Return SetExtended($avRval[0], $avRval[2])
EndFunc   ;==>_SQLite_Open

It preserves the code and behavior of the actual function, the only addition it's the last part of the function between # symbols.

Here I wrote two examples about how this is suppose to work with this parameter set and unset.

#3990 Completed _IsPressed() add "indicate whether the key has been pressed since the last query" Jpm argumentum
Func _IsPressed($sHexKey, $vDLL = "user32.dll")
    Local $aCall = DllCall($vDLL, "short", "GetAsyncKeyState", "int", "0x" & $sHexKey)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError(0, $aCall[0] = 0xFFFF8000, BitAND($aCall[0], 0x8000) <> 0)
EndFunc   ;==>_IsPressed

The change adds some extra information that I found was needed using a Bluetooth headset. The chatter about its use is at . Does not brake prior script code.

1 2 3 4 5 6 7 8 9 10 11 12
Note: See TracQuery for help on using queries.