Custom Query (3910 matches)
Results (52 - 54 of 3910)
| Ticket | Resolution | Summary | Owner | Reporter |
|---|---|---|---|---|
| #3993 | No Bug | _WinAPI_SetWindowTheme() - remove limits | ||
| Description |
Trying to change a color on a checkbox control I needed to remove the theme and found the limitation on the implementation of the wrapper. The request is to remove the "string or null, only" from the func., as zero is the value that is needed in this case. #include <WinAPITheme.au3>
Test()
Func Test()
GUICreate(@ScriptName)
GUICtrlCreateCheckbox("one", 10, 10, 200)
GUICtrlCreateCheckbox("two", 10, 30, 200)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlCreateCheckbox("three", 10, 50, 200)
_WinAPI_SetWindowTheme(GUICtrlGetHandle(-1)) ;, 0, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlCreateCheckbox("Four", 10, 70, 200)
_WinAPI_SetWindowTheme_mod(GUICtrlGetHandle(-1)) ;, 0, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUISetState()
While GUIGetMsg() <> -3
WEnd
GUIDelete()
EndFunc
Func _WinAPI_SetWindowTheme_mod($hWnd, $sName = Default, $sList = Default) ; #include <WinAPITheme.au3>
;~ If Not IsString($sName) Then $sName = Null ; <-- this limits what can get done with it.
;~ If Not IsString($sList) Then $sList = Null ; also, don't ask me why "Default" works !, I was going to use 0
Local $sResult = DllCall('UxTheme.dll', 'long', 'SetWindowTheme', 'hwnd', $hWnd, 'wstr', $sName, 'wstr', $sList)
If @error Then Return SetError(@error, @extended, 0)
If $sResult[0] Then Return SetError(10, $sResult[0], 0)
Return 1
EndFunc ;==>_WinAPI_SetWindowTheme
|
|||
| #3992 | Fixed | _WinAPI_DwmSetWindowAttribute() remove child proofing | ||
| Description |
_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 ; https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
; Case 2, 3, 4, 6, 7, 8, 10, 11, 12
; Case Else
; Return SetError(1, 0, 0)
;EndSwitch
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 https://www.autoitscript.com/forum/topic/211196-gui-title-bar-dark-theme-an-elegant-solution-using-dwmapi/?do=findComment&comment=1527581 , if _WinAPI_DwmSetWindowAttribute() was to be used, it'd fail, due to this filter. |
|||
| #3991 | Completed | _SQLite_ForeignKeys | ||
| Description |
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: https://www.autoitscript.com/forum/topic/211365-sqlite-foreign-keys/#comment-1529191
; 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)
Next
; $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)
EndIf
; $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)
Else
Return SetError(5, @error, $iExecRet)
EndIf
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 EndIf 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") _SQLite_Close($avRval[2]) Return SetError(-1, $avRval[0], 0) EndIf $__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] & '";') EndIf ; Foreign keys support ; ##################################### If $bFKEnable = Default Then $bFKEnable = False If $bFKEnable Then _SQLite_ForeignKeys($avRval[2], $bFKEnable) If @error Then Local $iError = @error _SQLite_Close($avRval[2]) Return SetError(4, $iError, 0) EndIf EndIf ; ##################################### 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. https://www.autoitscript.com/forum/topic/211365-sqlite-foreign-keys/#comment-1529191 |
|||
