Ja, leider wahr.
Im Januar 2020 wurde mit Microsoft 365 RichEdit ein D2D/DirectWrite RichEdit Fenster Control mit den neuen Fensterklassen "RichEditD2D" und "RichEditD2DPT" eingeführt. Sie verwenden D2D/DirectWrite für Text und Bilder und den HDC des Fensters zum Rendern eingebetteter Objekte und zum Drucken. Der Windows 11 Notepad verwendet die Fensterklasse RichEditD2DPT mit einem aktuellen Microsoft 365 RichEdit.
Ich verwende immer noch ein offenes Notepad (mit einigen offenen Tabs), du kannst aber auch die zwei zeilen auskommentieren, dann öffnet sich ein neues Notepad.
Findet alle offenen Tab-basierten RichEdit-Controls (win11) in die du dann schreiben kannst.
Leider reichen mein Win32 Kenntnisse nicht mehr für den o.g. Kram. (Vielleicht ist es doch Zeit mal wieder Linux zu versuchen.... )
Code: Alles auswählen
EnableExplicit
Global NewMap hWnd() ; avoid double items
Global NewList hwndEditor() ; the tabs of the notepad
; ---------------------------------------------------------------------------------------------------------------------
Procedure.s GetClassName(hWnd) ; returns the Classname of the specified window
Protected className${#MAX_PATH}
GetClassName_(hWnd, @className$, #MAX_PATH)
ProcedureReturn className$
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
Procedure.s GetWindowText(hWnd) ; returns the window title (caption) of the specified window
Protected text${#MAX_PATH}
GetWindowText_(hWnd, @text$, #MAX_PATH)
ProcedureReturn text$
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
Procedure SendMessageToNotepad(hwnd, Message$)
SendMessage_(hWnd, #EM_SETSEL, $fffffff, $fffffff) ; no selection, caret at the end
SendMessage_(hWnd, #EM_REPLACESEL, 0, Message$) ; + #CRLF$
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
Procedure EnumChildProc(hWnd, lParam)
Protected PID
Protected title$, classname$
If Not FindMapElement(hWnd(), Str(hWnd))
GetWindowThreadProcessId_(hWnd, @PID) ; get the process id
title$ = GetWindowText(hWnd)
classname$ = GetClassName(hWnd)
AddGadgetItem(0, -1, "PID: " + Right("000" + Str(PID), 4) + " Window: " + Right("0000" + Hex(hWnd, #PB_Long), 8) + " " + #DQUOTE$ + title$ + #DQUOTE$ + " " + classname$, 0, lParam + 1)
; works on win11
;
If classname$ = "RichEditD2DPT"
AddElement(hwndEditor()) : hwndEditor() = hWnd ; : Debug " found tab --> hwnd == " + hwnd
EndIf
hWnd(Str(hWnd)) = 0 ; only to avoid double items
EndIf
EnumChildWindows_(hWnd, @EnumChildProc(), lParam + 1)
ProcedureReturn #True
EndProcedure
Procedure EnumDesktopChildProc(hwnd, lparam) ;*Result.INTEGER)
If hwnd
If GetClassName(hwnd) = "Notepad"
ClearMap(hwnd())
EnumChildWindows_(hwnd, @EnumChildProc(), 0)
EndIf
EndIf
ProcedureReturn 1 ; try again
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
Procedure main()
Protected hwnd
; start the notepad with the next two lines
; I use my open notepad with all tabs instead ....
; RunProgram("notepad.exe", "", "", #PB_Program_Open)
; Delay(500) ; give windows time to start the notepad ....
If OpenWindow(0, 0, 0, 600, 400, "Open Notpad with all Tabs ... ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(0, 0, 0, 600, 300, #PB_Tree_AlwaysShowSelection)
TextGadget(5, 160, 308, 120, 16, "Test to send")
StringGadget(1, 160, 324, 400, 20, "Textline to Notepad.")
TextGadget(4, 16, 308, 120, 16, "Tabs List (hwnd)")
ListViewGadget(2, 16, 324, 120, 64)
ButtonGadget(3, 220, 368, 160, 24, "Send to Notepad")
; init
;
ClearGadgetItems(0)
EnumChildWindows_(GetDesktopWindow_(), @EnumDesktopChildProc(), 0)
If CountGadgetItems(0) > 0
SetGadgetItemState(0, 0, #PB_Tree_Expanded)
SendMessage_(GadgetID(0), #TVM_SORTCHILDREN, #True, SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_ROOT, 0))
EndIf
If ListSize(hwndEditor()) > 0
ForEach(hwndEditor())
AddGadgetItem(2, -1, Str(hwndEditor()))
Next
SetGadgetState(2, 0)
Else
AddGadgetItem(2, -1, "Error: No running Notepad found.")
DisableGadget(3, 1)
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break ; say good bye
Case #PB_Event_Gadget
Select EventGadget()
Case 3 ; Button
If GetGadgetState(2) > -1
hwnd = Val(GetGadgetText(2))
EndIf
SendMessageToNotepad(hwnd, GetGadgetText(1) + #CRLF$)
EndSelect
EndSelect
ForEver
EndIf
ProcedureReturn 0
EndProcedure
End main()
; BoF