It's not a direct PB bug, but when I use the Scintilla function #SCI_SETDOCPOINTER for the PureBasic ScintillaGadget, PB crashes when I press Ctrl+A and Ctrl+X.
I have developed a new tool for PureBasic to use the SplitView function of Scintilla.
The tool works, but when I press Ctrl+A and Ctrl+X PureBasic crashes with an IMA error.
Example code to enable #SCI_SETDOCPOINTER and reproduce the error:
Code: Select all
EnableExplicit
Procedure GetCurrentScintillaHandle(hwnd, lParam)
Protected String$
If GetWindowLongPtr_(hwnd, #GWL_STYLE) & #WS_VISIBLE
String$ = Space(1024)
GetClassName_(hwnd, @String$, Len(String$))
If String$ = "Scintilla"
PokeI(lParam, hwnd)
ProcedureReturn #False
EndIf
EndIf
ProcedureReturn #True
EndProcedure
Procedure GetLastScintillaHandle(hwnd, lParam)
Protected String$
Protected ScintillaLength
If GetWindowLongPtr_(hwnd, #GWL_STYLE)
String$ = Space(1024)
GetClassName_(hwnd, @String$, Len(String$))
If String$ = "Scintilla"
ScintillaLength = SendMessage_(hwnd, #WM_GETTEXTLENGTH, 0, 0)
If ScintillaLength = 0
PokeI(lParam, hwnd)
ProcedureReturn #False
EndIf
EndIf
EndIf
ProcedureReturn #True
EndProcedure
Define PBHandle
Define PBScintillaHandle
Define PBSplitViewScintillaHandle
Define PBScintillaPointer
Define ExampleCode$
ExampleCode$ + "If OpenWindow(0, 0, 0, 500, 400, " + Chr(34) + "Window" + Chr(34) + ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)" + #LFCR$
ExampleCode$ + " Repeat" + #LFCR$
ExampleCode$ + " Select WaitWindowEvent()" + #LFCR$
ExampleCode$ + " Case #PB_Event_CloseWindow" + #LFCR$
ExampleCode$ + " End" + #LFCR$
ExampleCode$ + " EndSelect" + #LFCR$
ExampleCode$ + " ForEver" + #LFCR$
ExampleCode$ + "EndIf" + #LFCR$
SetClipboardText(ExampleCode$)
PBHandle = FindWindow_("WindowClass_2", 0)
If PBHandle
SendMessage_(PBHandle, #WM_COMMAND, 0, 0)
Delay(250)
keybd_event_(#VK_CONTROL, #Null, #Null, #Null)
keybd_event_(#VK_V, #Null, #Null, #Null)
keybd_event_(#VK_CONTROL, #Null, #KEYEVENTF_KEYUP, #Null)
keybd_event_(#VK_V, #Null, #KEYEVENTF_KEYUP, #Null)
Delay(250)
EnumChildWindows_(PBHandle, @GetCurrentScintillaHandle(), @PBScintillaHandle)
SendMessage_(PBHandle, #WM_COMMAND, 0, 0)
Delay(250)
EnumChildWindows_(PBHandle, @GetLastScintillaHandle(), @PBSplitViewScintillaHandle)
If PBScintillaHandle And PBSplitViewScintillaHandle
PBScintillaPointer = SendMessage_(PBScintillaHandle, #SCI_GETDOCPOINTER, 0, 0)
SendMessage_(PBSplitViewScintillaHandle, #SCI_SETDOCPOINTER, 0, PBScintillaPointer)
Else
Debug "ScintillaGadget not found"
EndIf
Else
Debug "PB window not found"
EndIf
1. start the code.
2. you now have two new tabs.
2.1 The first new tab is the original tab.
2.2 The second new tab is a pointer tab.
3. choose the original tab.
4. press Ctrl+A and Ctrl+X
Video: https://www.rsbasic.de/temp/PBScintillaBug.mp4
@Fred & @freak:
Is it possible to fix the error so that I can use my tool?