Jump to content

shineworld

Members
  • Content Count

    321
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by shineworld

  1. Hi all, I've many TFrame objects which can implement one or more interfaces, depends. There is a Delphi way to check if a frame implements an interface? E.g: procedure UpdateTheme(Obj: TFrame); begin if "Obj implements ITheme" then (Obj as ITheme).UpdateTheme; end;
  2. shineworld

    Touch Screen VCL

    For every component is possible, in gesture options, disable the long press event (PRESSANDHOLD) to not enter in "simulated right mouse click" and perform what you need. You can also perform that in WndProc (for e.g. in custom components) when you use old Dephi versions (e.g BDS2006 or any version with don't have gesture management): procedure TAggButton.WndProc(var Message: TMessage); const WM_TABLET_DEFBASE = $02C0; WM_TABLET_QUERYSYSTEMGESTURESTATUS = (WM_TABLET_DEFBASE + 12); const TABLET_DISABLE_PRESSANDHOLD = $00000001; TABLET_DISABLE_PENTAPFEEDBACK = $00000008; TABLET_DISABLE_PENBARRELFEEDBACK = $00000010; TABLET_DISABLE_TOUCHUIFORCEON = $00000100; TABLET_DISABLE_TOUCHUIFORCEOFF = $00000200; TABLET_DISABLE_TOUCHSWITCH = $00008000; TABLET_DISABLE_FLICKS = $00010000; TABLET_ENABLE_FLICKSONCONTEXT = $00020000; TABLET_ENABLE_FLICKLEARNINGMODE = $00040000; TABLET_DISABLE_SMOOTHSCROLLING = $00080000; TABLET_DISABLE_FLICKFALLBACKKEYS = $00100000; TABLET_ENABLE_MULTITOUCHDATA = $01000000; {** * NOTE * ==== * https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-cursorinfo * * CI.flags: * * 0 The cursor is hidden. * CURSOR_SHOWING 0x00000001 The cursor is showing. * CURSOR_SUPPRESSED 0x00000002 Windows 8: The cursor is suppressed. * This flag indicates that the system is not drawing the cursor because the user is * providing input through touch or pen instead of the mouse. * * Minimum supported client Windows 2000 Professional [desktop apps only]. * **} function IsMouseCursorVisible: Boolean; var CI: TCursorInfo; begin CI.cbSize := SizeOf(CI); Result := GetCursorInfo(CI) and (CI.flags = CURSOR_SHOWING); end; begin case Message.Msg of CM_TEXTCHANGED: Invalidate; CM_VISIBLECHANGED: begin Invalidate; end; CM_ENABLEDCHANGED: begin FSVGSupportChanged := True; Invalidate; end; CM_MOUSEENTER: begin if not FMouseInControl then begin FMouseInControl := IsMouseCursorVisible; if FMouseInControl then Invalidate; end; end; CM_MOUSELEAVE: begin if FMouseInControl then begin FMouseInControl := False; Invalidate; end; end; WM_ERASEBKGND: begin Message.Result := 1; Exit; end; WM_MOUSELEAVE: begin end; WM_TABLET_QUERYSYSTEMGESTURESTATUS: begin Message.Result := ( TABLET_DISABLE_PRESSANDHOLD or TABLET_DISABLE_PENTAPFEEDBACK or TABLET_DISABLE_PENBARRELFEEDBACK or TABLET_DISABLE_TOUCHUIFORCEON or TABLET_DISABLE_TOUCHUIFORCEOFF or TABLET_DISABLE_TOUCHSWITCH or TABLET_DISABLE_FLICKS or TABLET_DISABLE_SMOOTHSCROLLING or TABLET_DISABLE_FLICKFALLBACKKEYS ); Exit; end; end; inherited WndProc(Message); end; In this case you have also to enable touch management with: procedure CreateWnd; override; procedure DestroyWnd; override; procedure TAggButton.CreateWnd; begin inherited; if csLoading in ComponentState then Exit; if not FTouchInitialized and TOSVersion.Check(6, 1) and RegisterTouchWindow(Handle, 0) then FTouchInitialized := True; end; procedure TAggButton.DestroyWnd; begin if FTouchInitialized then begin UnregisterTouchWindow(Handle); FTouchInitialized := False; end; inherited; end;
  3. shineworld

    Gesture igZoom works in FMX but not in VCL

    Hi all, I'm trying to use igZoom gesture in a VCL application but doesn't work. It works perfectly in an FMX application. 1] Create an FMX empty application for WIN. 2] Add GestureManager 3] Add a Panel and assign the GestureManager 4] Add igZoom feature in Panel Touch Interactive Gestures 5] Add an event handler for Panel OnGesture 6] Increment a counter and show in the caption for every OnGesture event: var Count: Integer; procedure TForm8.Panel1Gesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); begin Inc(Count); Caption := IntToStr(Count); end; 1] Create a VCL empty application 2 to 6 as made for FMX application At this point the two applications, FMX and VCL are the same. Running FMX application when I put two fingers on the touch screen the zoom in/out movements creates a continuous flow of OnGesture: OK works fine. Running VCL application when I put two fingers on the touch screen the zoom in/out movements don't create OnGesture event but is created only when I remove the fingers. I don't know why FMX works: till I'm zooming I've got a lot of OnGesture events to track the zoom IN/OUT activity, but with VCL I've got ONLY one event with ID = 0 when I leave the fingers from the touch screen. Thank you for help !!!
  4. shineworld

    Gesture igZoom works in FMX but not in VCL

    FOUND !!! VCL and FMX gesture managements are different. I've found an document that say: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Gesturing_Overview
  5. Hi to all, I've moved a lot of code from BDS2006 to Sydney and now it's time to finish DLL interfacing. Support DLLs are at moment in AnsiString so input parameters are as PAnsiChar, but overall calling code is ready to use Unicode strings (I'm waiting the right time to convert the DLL). When strings are emptied a nil pointer must be sent to DLL arguments. As a workaround I've two solutions, one fine to see but I don't know if will work in all cases. The second way could work fine always: { first mode } function StringToAnsiCPointer(const S: string): PAnsiChar; inline; function StringToAnsiCPointer(const S: string): PAnsiChar; begin if Length(S) = 0 then Result := nil else Result := PAnsiChar(AnsiString(S)); end; function CompilerEncryptFile(const TextFileName: string; Key: TCNCEncryptKey; const EncryptedFileName: string): Longint; begin Result := _CompilerEncryptFile // DLL CALL ( StringToAnsiCPointer(TextFileName), @Key, StringToAnsiCPointer(EncryptedFileName) ); end; { SECOND MODE } function CompilerEncryptFile(const TextFileName: string; Key: TCNCEncryptKey; const EncryptedFileName: string): Longint; begin Result := _CompilerEncryptFile ( IIf(Length(TextFileName) = 0, nil, PAnsiChar(AnsiString(TextFileName))), @Key, IIf(Length(EncryptedFileName) = 0, nil, PAnsiChar(AnsiString(EncryptedFileName))) ); end; My dubs in the first mode are concerning the LIFE of temporary cast to AnsiString in the line: PAnsiChar(AnsiString(S) as a result of the external function. Do you have some ideas about it?
  6. shineworld

    Interfacing Unicode string to DLL PAnsiChar

    Thanks all for the help. The suggested way working perfectly !!!
  7. Hi developers, I am moving a project from BDS2006 to Sydney. I have strange behavior when debugging with Sydney, the program slows down a lot, and becomes almost unusable. In BDS2006 there is no noticeable difference between running a program in debug or without debugging which helps a lot in the development. In Sydney, this is not the case, and to understand if some changes bring about performance improvements or not, all that remains is to run without debugging and disseminate the log code ... Frustrating. I am attaching a video that highlights how the behavior changes between the two ways of running a program. When running in Sydney the system becomes so slow that the thread sending data via TCP / IP to the connected device cannot keep up with the data request. Everything is slowed down and jerky. Do you have any idea what might go wrong? PS: During the installation of the IDE I also installed the Parnassus Debugger, doesn't this considerably increase the load in the execution of programs in Debug? I obviously use a lot of threads but not a lot to bring the process to its knees. As you can see, when it is not debugged, the CPU used by the program aligns itself on 1-2%. Thanks in advance for the suggestions. https://youtu.be/eLTVhPkn0NA
  8. shineworld

    TTouchKeyboard layout

    Hi all. I'm on a PC with the Italian language and an Italian true keyboard. In the VCL software, I would like to use the TTouchKeyboard. Is a technical software where I need to force TTouchKeyoard to display US keyboard layout, because chars as [ ] | # etc are mandatory instead of accented èéòàù of specific Italian layout. I've imported the Vcl.Touch.Keyboard.pas in project to add minor graphics changes, which works fine, but I'm not able to understand how to force English layout. I've tried to change CreateKeyboard method to say "use alwyas 'en' but doesn't works. function TCustomTouchKeyboard.CreateKeyboard(const Language: string): Boolean; var Index, RowIndex, ColIndex: Integer; Button: TCustomKeyboardButton; LeftPosition, TopPosition: Integer; KeyboardState: TKeyboardState; KeyboardLayout: TVirtualKeyLayout; Row: TVirtualKeys; FoundCaps: Boolean; _Language: string; begin Result := False; FoundCaps := False; for Index := 0 to FButtons.Count - 1 do FButtons[Index].Free; FButtons.Clear; FDeadKey := VKey(-1, -1); TopPosition := 0; _Language := 'en'; if _Language <> '' then FLanguage := _Language; The result is always: There is a way to force it ?
  9. shineworld

    TTouchKeyboard layout

    Yes, I've already tried that, but, end-user will have a touch keyboard to enter code in the display panel + a physical keyboard (Japanese or Russian in this case) to enter texts in native Unicode mode. I need to have Windows working with Japanese or Russian native user language but the touch keyboard with the US for fast code editing in the display keybaord. I'm trying to understand TTouchKeyboard to "overload" how works o I will move to a custom keyboard component created from zero.
  10. shineworld

    TTouchKeyboard layout

    This is the "English" layout that I mean: I can obtain this layout "forcing" the entire system to use US keyboard layout language instead of "IT" with: ActivateKeyboardLayout(67699721 {en-US}, 0); Application.ProcessMessages; TouchKeyboard1.Redraw; but I wouldn't change how the physical keyboard works, overall the native customer keyboard, for eg. is Japanese and would use a physical keyboard to edit strings, but only the TTouchKeyboard component layout.
  11. I'm creating some UI controls using AggPasMod in a touchscreen application. Some of these controls don't have the Press and Hold feature to simulate Right Mouse click. How to disable this gesture option in them? Is the square visible when I keep pressed touch for a while in the knob. Thank you in advance for your replies. 2021-04-02 09-08-24.7z
  12. shineworld

    Disable press and hold in touch screen for a control

    For BDS2006, I've found this solution to disable the press and hold only to required components. For Sydney there is Touch.TabletOptions does the same things. procedure TAggKnob.WndProc(var Message: TMessage); const WM_TABLET_DEFBASE = $02C0; WM_TABLET_QUERYSYSTEMGESTURESTATUS = (WM_TABLET_DEFBASE + 12); const TABLET_DISABLE_PRESSANDHOLD = $00000001; TABLET_DISABLE_PENTAPFEEDBACK = $00000008; TABLET_DISABLE_PENBARRELFEEDBACK = $00000010; TABLET_DISABLE_TOUCHUIFORCEON = $00000100; TABLET_DISABLE_TOUCHUIFORCEOFF = $00000200; TABLET_DISABLE_TOUCHSWITCH = $00008000; TABLET_DISABLE_FLICKS = $00010000; TABLET_ENABLE_FLICKSONCONTEXT = $00020000; TABLET_ENABLE_FLICKLEARNINGMODE = $00040000; TABLET_DISABLE_SMOOTHSCROLLING = $00080000; TABLET_DISABLE_FLICKFALLBACKKEYS = $00100000; TABLET_ENABLE_MULTITOUCHDATA = $01000000; var P: TPoint; begin case Message.Msg of WM_TABLET_QUERYSYSTEMGESTURESTATUS: begin Message.Result := ( TABLET_DISABLE_PRESSANDHOLD or TABLET_DISABLE_PENTAPFEEDBACK or TABLET_DISABLE_PENBARRELFEEDBACK or TABLET_DISABLE_TOUCHUIFORCEON or TABLET_DISABLE_TOUCHUIFORCEOFF or TABLET_DISABLE_TOUCHSWITCH or TABLET_DISABLE_FLICKS or TABLET_DISABLE_SMOOTHSCROLLING or TABLET_DISABLE_FLICKFALLBACKKEYS ); P.X := TWMMouse(Message).XPos; P.Y := TWMMouse(Message).YPos; P := ScreenToClient(P); MouseDown(mbLeft, [], P.X, P.Y); Exit; end; end; inherited WndProc(Message); end;
  13. shineworld

    PaxCompiler

    I'm used to PascalScript from RemObjects. It is a great extendable environment. I'm using it with OpenGL and 2D graphics support... https://github.com/remobjects/pascalscript
  14. shineworld

    TTouchKeyboard when in modal dialog

    Hi all, I'm trying to make an only-touch screen application with Sydney. In the bottom zone, I've placed a TTouchKeyboard from Sydney VCL components. That works fine in normal cases, but not works when I open a modal dialog (for example Program Settings in the attached photo). When I click a keyboard button the system voice a "DONG" and the keyboard doesn't work. Any suggestion about it? Is possible to have always active the touch keyboard also when needed in modal dialogs? Best Regards.
  15. shineworld

    TTouchKeyboard when in modal dialog

    Doesn't works also when edit fields are focused. Seems that I've to move my TProgramSettingsForm contents, place it in a TFrame and remain in MainForm where TTouchKeyboard is instanced, or perhaps I've to free the TTouchKeyboard from Main form, re-create it in the TProgramSettings modal Form and assign as Parent the container in MainForm so look doesn't change but is in same message pool.
  16. shineworld

    How to compare performance between Delphi versions?

    Do you have the tweaks rules to run Delphi 2006 on W10 ? Would be amazing for me can use that in W10. I've do modify a program which uses pro-cameras with PCI camera board and in this case I need to develop in VM (XP), copy the exe in W10 and try without debug... inserting tons of logs but it is very hard...
  17. shineworld

    How to compare performance between Delphi versions?

    I was used with the development in VMWare VM's with BDS2006 for simple reasons: - BDS2006 doesn't work with W10 (my guest) and I need to run it on XP (host). - Often I need to save the entire VM because the update of 3rd party libraries in time adds incompatibilities to old projects. So I save a full image related to a big project to restore it when I need to re-open and modify that project. I never tried to install RIO or SYDNEY in VM, I don't know if is permitted...
  18. shineworld

    How to compare performance between Delphi versions?

    I run 10.3 at home and 10.4.1 at the office (I'm always working.... but this is another question). At skin 10.3 32-bits exe are a lot slower than 10.4.1, with same libraries (almost all at least) but I will create test units to check better... Either PCs are I7 with 16GB of ram and W10 20H2. Unfortunately, a double SSD corruption, for a damaged motherboard SATA compart, finished my Delphi installations count, so when I'm not at the office, I need to use the old 10.3 in-home laptop. In this case, I need to keep different versions of DFM (incompatible when from Rio I open Sydney modified files).
  19. Hi all, I've migrated my application to the latest Indy10 sources. A very good library, congrats to developers. Now I would like to improve my research devices on the net feature. In few words, my IoT devices implement a UDP service to respond to a broadcast UDP request of identification. When IoT sends a reply to discover software uses the IoT IP address so after I can, for example, use other messages to change the IoT device programmed IP. Actually, the system works BUT depends on what network adapter will route the discover software broadcast message. For example, I've collected the Network Adapters in my system before to send discover UPD packet as a broadcast message: At this point clicking on the Change IP button a form make the broadcast search using this code: procedure TConfiguratorView.SearchClick(Sender: TObject); var S: string; procedure AddInteger(var Buffer: string; Value: Integer); var ValueData: array [0..3] of Byte absolute Value; begin Buffer := Buffer + Char(ValueData[3]); Buffer := Buffer + Char(ValueData[2]); Buffer := Buffer + Char(ValueData[1]); Buffer := Buffer + Char(ValueData[0]); end; begin // shows advice message about network routing question if Sender <> nil then begin case ShowCustomMessage ( _('Info About Search'), _('Select desired option:'), _('Search Message could be routed by OS in a wrong Network Interface so if, after a Search, you don''t find any ' + 'CNC Board try again disabling any Network Interface not connected with the CNC Board.\n\n' + 'PS: If you are in a Virtual Machine the Network Adapter must be in BRIDGED MODE.'), '', [ _('Continue'), _('Abort') ] ) of 101: Exit; end; end; // stores serial number selected if GetActiveQMoveInfo = nil then FSerialNumberSelected := 0 else FSerialNumberSelected := GetActiveQMoveInfo.SerialNumber; // clears qmove list content QMoveListClear; // inits and starts searching phase FUDPServer.Bindings.Clear; with FUDPServer.Bindings.Add do begin IP := '0.0.0.0'; Port := 5001; end; FUDPServer.Active := True; SearchTimer.Interval := SEARCH_TIME; SearchTimer.Enabled := True; // sends broadcast find command if FSerialNumber = 0 then FUDPServer.Broadcast(QMOVE_ETHERNET_HEAD + Char(QMOVE_ETHERNET_VERSION) + QMOVE_EHTERNET_FIND_COMMAND, QMOVE_ETHERNET_SEARCHING_PORT, '', IndyTextEncoding(enc8Bit)) else begin S := ( QMOVE_ETHERNET_HEAD + Char(QMOVE_ETHERNET_VERSION) + QMOVE_EHTERNET_FIND_COMMAND + #226#64 ); AddInteger(S, FSerialNumber); FUDPServer.Broadcast(S, QMOVE_ETHERNET_SEARCHING_PORT, '', IndyTextEncoding(enc8Bit)); FSerialNumber := 0; end; // refreshes objects RefreshObjects; end; When the PC has only one Network Adapter (eg: the LAN) the system work always. When there are more than one Network Adapter depends on where the windows "route" the UDP packets so I need to require to end-user to manually disable temporarily any other Network Adapter (eg: WIFI, VMWare Network Adapters, etc.). There is a way to specify to UDP server to send a broadcast to a specific network adapter (eg: 192.168.x.x) instead to use an unknown default? Thank you in advance for your suggestions Silverio
  20. shineworld

    INDY UDP broadcast to a specific Network

    Sorry I've made a mistake to write a demo code manually. What I have: - A PC with many network adapters (actually there are 4 LAN ports, 1 wifi, and adapters from VMWare and Virtual Box). - The IoT devices will be placed by customers in some of the available Network Adapters (I don't know what and perhaps also the customers don't know exactly what LAN will be). - Any IoT device has a UDP client who listening to a port (1460) for discovery. - Any IoT device has IP/MASK/IP Ports and TCP Clients ports bound to them. - A user starts the IoT device Discovery in all the net. - The Discovery System uses a TIdUPDServer bind to the port 5001 to any net - no net address (0.0.0.0) to receive any UDP packet from any network returning to the 5001 port. At this point, I can call: for I := 0 to FNetworksList.Count - 1 do FUDPServer.Broadcast(S, QMOVE_ETHERNET_SEARCHING_PORT, FNetworksList[I].BroadCastIPForThisNA , IndyTextEncoding(enc8Bit)); The UDP Server sent the UDP discovery packet to any Network Adapter and if in the network adapter there is an IoT device it will respond to discovery software using a UDP packet at port 5001 (where discovery software is listening for any net) using the destination IP (where discovery software lives) contained in the received discovery packet. OK, this works perfectly now. At this point I would like to understand what you wrote: I'm sorry for the question, I'm an occasional user of network things, and I don't have any deep knowledge background in the matter.
  21. shineworld

    INDY UDP broadcast to a specific Network

    I've tried to place some number (IP Broadcast for the network adapter in Binding but I gel always a socket error): // inits and starts searching phase FUDPServer.Active := False; FUDPServer.Bindings.Clear; with FUDPServer.Bindings.Add do begin IP := '192.168.0.255'; Port := 5001; end; with FUDPServer.Bindings.Add do begin IP := '192.168.120.255'; Port := 5001; end; FUDPServer.BroadcastEnabled := True; FUDPServer.Active := True; The resulting approach, at moment, was to define in what network adapter has to perform the scan:
  22. shineworld

    INDY UDP broadcast to a specific Network

    I guess to have solved! I'm very dumb in network things, so I can mistake anything. Calling: FUDPServer.Broadcast(S, QMOVE_ETHERNET_SEARCHING_PORT, '', IndyTextEncoding(enc8Bit)); The library changes the IP destination address ' ' as 255.255.255.255 and uses the default route adapter from the Windows OS list. If I change the ' ' with the Broadcast IP of the desired network adapter then the packet is routed correctly and I can get a reply from devices in that net.
  23. shineworld

    XML Parsing and Processing

    Very interesting project. I will try to move to it !!!
  24. shineworld

    XML Parsing and Processing

    Actually, I use MSXML only for 32-bit applications (never done 64bit at moment) To increase the amount of memory I use FastMM with these options: {$IFDEF USES_EMBEDDED_FASTMM_MEMORY_MANAGER} {$IFDEF USES_FASTMM_OLD} {$SetPEFlags $20} {$DEFINE USES_FASTMM} FastMM4 in 'sources\memory-managers\FastMM4-old\FastMM4.pas', FastMM4Messages in 'sources\memory-managers\FastMM4-old\FastMM4Messages.pas', {$ENDIF} {$IFDEF USES_FASTMM_NEW} {$SetPEFlags $20} {$DEFINE USES_FASTMM} FastMM4 in 'sources\memory-managers\FastMM4-new\FastMM4.pas', FastMM4Messages in 'sources\memory-managers\FastMM4-new\FastMM4Messages.pas', {$ENDIF} {$IFDEF USES_FASTMM_AVX} {$SetPEFlags $20} {$DEFINE USES_FASTMM} FastMM4 in 'sources\memory-managers\FastMM4-AVX\FastMM4.pas', FastMM4Messages in 'sources\memory-managers\FastMM4-AVX\FastMM4Messages.pas', {$ENDIF} {$ENDIF} In this FastMM.inc file I can choose three different FastMM versions. "{$SetPEFlags $20}" extends the 2GB limits of Win32. I don't know if that influence also MSXML but Delphi program memory increases a lot. I use also a lot of attributes (XMLMemento uses them to store data) but I did not reach thousand elements. I'm searching for a good native Delphi library to substitute MSXML and have all in Delphi project...
  25. shineworld

    XML Parsing and Processing

    I'use MSXML for many years and works very fine and fast. However, I've implemented a consumer class to realize a simplified version of Memento and Persistable interfaces. The memento support also XPath search. memento.7z osExceptionUtils.pas osSysUtils.pas
×