Jump to content

nglthach

Members
  • Content Count

    11
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by nglthach


  1. The problem is VCL TCustomForm.WndProc call SaveDC before the owner drawing method, then restore the drawing context by calling RestoreDC

    Solving the problem by overriding WndProc as:

     

    interface
    
    TForm12 = class(TForm)
      public
        procedure WndProc(var Message: TMessage); override;
      end;
      
    implementation
    
    procedure TForm12.WndProc(var Message: TMessage);
    var
      MenuItem: TMenuItem;
      Canvas: TCanvas;
      SaveIndex: Integer;
    begin
      if Message.Msg = WM_DRAWITEM then
      begin
        with PDrawItemStruct(Message.LParam)^ do
          if (CtlType = ODT_MENU) and Assigned(Menu) and not IsVclControl(HWndItem) then
          begin
            MenuItem := Menu.FindItem(itemID, fkCommand);
            if (MenuItem <> nil) and not (MenuItem.GetParentComponent is TMainMenu) then
            begin
              Canvas := TControlCanvas.Create;
              with Canvas do
              try
                //SaveIndex := SaveDC(hDC); <==== here is the problem
                try
                  Handle := hDC;
                  Font := Screen.MenuFont;
                  Vcl.Menus.DrawMenuItem(MenuItem, Canvas, rcItem,
                    TOwnerDrawState(LoWord(itemState)));
                finally
                  Handle := 0;
                  //RestoreDC(hDC, SaveIndex) <==== here is the problem
                end;
              finally
                Free;
              end;
              Exit;
            end;
          end;
      end;
    
      inherited WndProc(Message);
    
    end;

     

    • Like 1

  2. Hi folks,

     

    I am trying to skin menu item. I have successfully customize the menu item appearance. But if the menu has sub menu, I could not owner drawing the arrow. Here is my code:

    procedure TForm12.cmniOpenRecentAdvancedDrawItem(Sender: TObject;
      ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
    begin
      // Prevent the OS drawing the arrow
      ExcludeClipRect(ACanvas.Handle, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
    end;
    
    procedure TForm12.cmniOpenRecentDrawItem(Sender: TObject; ACanvas: TCanvas;
      ARect: TRect; Selected: Boolean);
    begin
      ACanvas.Brush.Style := bsSolid;
      ACanvas.Brush.Color := clRed;
      ACanvas.Rectangle(ARect);
      // Prevent the OS drawing the arrow
      ExcludeClipRect(ACanvas.Handle, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
    end;

    Here is the result:

    image.thumb.png.13cad7595500205d4f4a6f9e42c86802.png

     

    As you see, the arrow still there although I already draw a rectangle to the whole menu item's rect.

    Do you know how to prevent the OS drawing the arrow? Thanks!

     

     


  3. On 11/19/2022 at 4:07 PM, David Schwartz said:

    Here's some pseudo-code that needs to be executed when you visit a particular URL:

     

    
    case TodaysName of
      'mon': ShowPage(1);
      'tue': ShowPage(2);
      . . .
      'fri': ShowPage(5);
    end;

    ShowPage loads a list of either HTML files or URLs, then sends that page out to the browser. I want to implement this in TMS WebCore, and the app sits at the URL in question.

     

    I'm looking at a situation where the pages use a different template for each day. Someone will edit the template for each day eg, on Sunday) and save it; when the URL is viewed in the browser it will display that day's template as edited previously. 

     

    The users might create the pages using an HTML page / web editor, or maybe create them in, say, Wordpres, or any number of similar options.

     

    Is it sufficient to load up the entire HTML file and send it out to the browser? Or will the header need to be doctored in some way?

    I suppose I could also write an app that would let the user edit the pages and save their most relevant details somewhere.

     

    I know this isn't specific to WebCore, but may be a fairly common problem with many kinds of services.

    Hi @David Schwartz

     

    You would like to do this on client site (at the browser) or server side? Both are easy to implement (not TMS WebCore). If you would like to see a working demo, like my comment and back in tomorrow, I will show you 🙂

    • Like 1

  4. Hi @David Schwartz

     

    As a web developer in 12 years, I’m sure no Javascript developer willing to learn Delphi. From their point of view, Delphi is dying programming language and the concept of two languages are different. Js eco (include NodeJs) has a lot of framework for both back-end and front-end, there is no reason for a Js dev using Delphi for the back-end! You could take a look at AdonisJs for an example!

     

    And the Delphi dev also dont want to learn Js, it is a dynamic language and annoyed when using (it is why TypeScript was born).

     

    If you would like to hire a Delphi dev who experienced with Js, please contact me! I’m willing to work 🙂


  5. Artem's Classes/Components/Controls library (ACL)

     

    Library contains number of classes, components and visual controls for Delphi that used in AIMP. I have published the library because it was used in plugins that no longer supported by me.

    If anyone will be interested the library I will add more details and create index of all features and abilities of the library. My working Delphi is 11.0 Alexandria. The library may work on earlier versions of Delphi, but I haven't tested it.

     

    Link: https://github.com/ArtemIzmaylov/ACL

    • Thanks 2

  6. You should take a look on AddExitProc: http://docwiki.embarcadero.com/Libraries/Sydney/en/System.SysUtils.AddExitProc

    procedure DoOnExit;
    var
      s: string;
    begin
      s := ''; // Set a breakpoint here
    end;
    
    begin
      AddExitProc(DoOnExit); // Put this line before Application.Run
      Application.Initialize;
      Application.DefaultFont.Assign(Screen.MenuFont);
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
    end;
×