Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 06/21/24 in Posts

  1. Dalija Prasnikar

    Threadvar "per object"

    Word of caution, TLightweightMREW is not merely a lightweight equivalent of TMultiReadExclusiveWriteSynchronizer as it has different behavior. Most notably, write lock is not reentrant on TLightweightMREW and acquiring write lock from the same thread twice will cause deadlocks on Windows platform and will raise exception on other platforms. When it comes to TMultiReadExclusiveWriteSynchronizer it is implemented as MREW only on Windows and on other platforms it is exclusive lock.
  2. Lajos Juhász

    Make a TMemo.seltext modification cancellable by the user

    It is an easy to debug. You have to set the CanUndoSelText property to true. https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.StdCtrls.TCustomEdit.CanUndoSelText
  3. sh17

    FMX in VCL app - working natively ?

    I set up the project again and incorporated all pull requests. landrix/Delphi-Firemonkey-Container (github.com)
  4. Uwe Raabe

    Threadvar "per object"

    and for class var.
  5. shineworld

    VTK in DelphiVCL or DelphiFMX

    The code is a real crap, I'm just trying the right way to get the thing working, but Python + DelphiVCL + VTK looks like it could go. from delphivcl import * from vtkmodules.vtkRenderingCore import vtkRenderWindow from vtkmodules.vtkRenderingUI import vtkGenericRenderWindowInteractor BASE_CLASS_NAME = WinControl class vclVTKRenderWindowInteractor(BASE_CLASS_NAME): def __init__(self, owner): BASE_CLASS_NAME.__init__(self, owner) self._RenderWindow = None self._Iren = None def __getattr__(self, attr): """Makes the object behave like a vtkGenericRenderWindowInteractor""" if attr == '__vtk__': return lambda t=self._Iren: t elif hasattr(self._Iren, attr): return getattr(self._Iren, attr) else: raise AttributeError(self.__class__.__name__ + " has no attribute named " + attr) def GetRenderWindow(self): if self._RenderWindow is None: hwnd = self.Handle self._RenderWindow = vtkRenderWindow() self._RenderWindow.SetWindowInfo(str(int(hwnd))) self._Iren = vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) return self._RenderWindow def Render(self): self.update() def vclVTKRenderWindowInteractorConeExample(): """A simple example that uses the vclVTKRenderWindowInteractor class.""" from vtkmodules.vtkFiltersSources import vtkConeSource from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer import vtkmodules.vtkRenderingOpenGL2 import vtkmodules.vtkInteractionStyle class MainView(Form): def __init__(self, owner): self.vtk_panel = vclVTKRenderWindowInteractor(self) self.vtk_panel.Parent = self self.vtk_panel.Align = 'alClient' self.vtk_panel.AlignWithMargins = True self.vtk_panel.BevelInner = 'bvNone' self.vtk_panel.BevelKind = 'bkFlat' self.vtk_panel.BevelOuter = 'bvNone' self.vtk_panel.Color = clCream self.vtk_panel.ParentBackground = False self.vtk_panel.Caption = 'Hello World!' # set main form events handlers self.OnClose = self.__on_form_close def __on_form_close(self, sender, action): if sender is None: return if sender == self: action.Value = caFree # initialize application Application.Initialize() Application.Title = "" # create and show view view = MainView(Application) try: def on_timer(Sender): coneActor.RotateX(10) coneActor.RotateY(5) coneActor.RotateY(2.5) widget.GetRenderWindow().Render() timer.interval = 100 view.Show() widget = view.vtk_panel ren = vtkRenderer() widget.GetRenderWindow().AddRenderer(ren) cone = vtkConeSource() cone.SetResolution(8) coneMapper = vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) coneActor = vtkActor() coneActor.SetMapper(coneMapper) ren.AddActor(coneActor) widget._Iren.Initialize() # Initialize the interactor widget._Iren.Start() # Start the interactor timer = Timer(None) timer.Interval = 1000 timer.OnTimer = on_timer FreeConsole() Application.Run() finally: view.Destroy() if __name__ == '__main__': vclVTKRenderWindowInteractorConeExample()
  6. Uwe Raabe

    Serialize/Deserialize Enums with no RTTI

    I know, that probably won't solve your problem, but I usually get rid of these kind of enumerations in favor of proper ones supported by RTTI. The numerical values are handles by record helpers: type TReportTypeCode = (reportTypeCodeSTR, reportTypeCodeLCTR, reportTypeCodeCDR, reportTypeCodeLVCTR, reportTypeCodeEFTR); TReportTypeCodeHelper = record helper for TReportTypeCode private const cMapping: array[TReportTypeCode] of Integer = (102, 106, 113, 14, 145); function GetAsInteger: Integer; procedure SetAsInteger(const Value: Integer); public property AsInteger: Integer read GetAsInteger write SetAsInteger; end; function TReportTypeCodeHelper.GetAsInteger: Integer; begin Result := cMapping[Self]; end; procedure TReportTypeCodeHelper.SetAsInteger(const Value: Integer); begin for var idx := Low(Self) to High(Self) do begin if cMapping[idx] = Value then begin Self := idx; Exit; end; end; raise EInvalidOperation.Create('invalid Integer value for TReportTypeCode'); end; Now there is no more casting to and from Integers.
  7. Jim McKeeth

    Vote for MMX Code Explorer

    Vote for MMX Code Explorer in the Essential Delphi Addins survey https://forms.gle/xuFWpSrE5TDdordNA
  8. Lajos Juhász

    Trackbar height, fmx, android

    I don't have Android platform at the moment. On Windows you can change the scale.y to a value <1 to get a smaller trackbar.
×