CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Dynamically adding TIWCGJQMenu items on TIWCGJQRegion

General discussion

by ScottWGast » 22 May 2014 14:59

I'm using this code to show the files that are linked / attached to an email; basically, I dynamically create TIWCGJQMenu items and assign them to a TIWCGJQRegion. This produces a list of file names within the confines of the TIWCGJQRegion. The problem is that the region's scroll bars are not displaying when I fill the region beyond it's visible capacity.

In the code I create the TIWCGJQMenu object, set a few properties, add two sub-items for Open (Download) and Delete and then assign that object to the region. I need the scroll bars to appear when I add more items to the TIWCGJQRegion than there is vertical room to display.

Code: Select all
procedure TframeEmailEdit.LoadLinkedDocuments;
var
  strFolder, strFilename, strCaption: String;
  slLinkedDocuments: TStringList;
  itemLinkedDocument: TIWCGJQMenu;
  itemDocument: TIWCGJQMenuItem;
  itemSubMenu: TIWCGJQMenuItem;
  i: Integer;
begin

  strFolder := UserSession.GetEmailLinkedDocumentsFolder(Self.FEmailID);

  Self.fileUploadLinkedDocument.JQFileUploadOptions.UploadPath := strFolder;
  Self.fileUploadLinkedDocument.JQFileUploadOptions.OnUpload.Indicator := Self.FLockIndicator;


  slLinkedDocuments := TStringList.Create;
  S2Snax.GetFileList(strFolder, False, '*.*', slLinkedDocuments);

  Self.FAttachedFileCount := slLinkedDocuments.Count;

  ForceDirectories(strFolder);

  Self.KillLinkedDocumentsList;

  for i := 0 to slLinkedDocuments.Count - 1 do
    begin
      itemLinkedDocument := TIWCGJQMenu.Create(Self);
      itemLInkedDocument.Parent := Self.regionLinkedDocuments;
      itemLinkedDocument.Name := FindUniqueName;
      itemLinkedDocument.Align := TAlign.alTop;

      strFilename := slLinkedDocuments[i];
      strCaption := '<html>' +
                        '<body>' +
                          '<div id="container" style="width:' + IntToStr(Self.regionLinkedDocuments.Width) + 'px">' +
                            '<div id="col1" style="width:'+IntToStr(Self.regionLinkedDocuments.Width div 2)+'px;float:left;">' +
                              ExtractFileName(strFilename) + '<br>' +
                            '</div>' +
                            '<div id="col2" style="width:'+IntToStr(Self.regionLinkedDocuments.Width div 4)+'px;float:left;">' +
                              FormatDateTime('MM/DD/YYYY HH:MM:SS AM/PM', S2Snax.GetFileDate(strFilename)) + '<br>' +
                            '</div>' +
                            '<div id="col3" style="width:'+IntToStr(Self.regionLinkedDocuments.Width div 4)+'px;float:left;">' +
                              S2Snax.RealToString(RoundTo(S2Snax.GetFileSize(strFilename) / 1024,-2)) + ' KB' + '<br>' +
                            '</div>' +
                          '</div>' +
                        '</body>' +
                      '</html>';


      itemDocument := itemLInkedDocument.MenuItems.Add;
      itemDocument.Caption := strCaption;
      itemSubMenu := itemDocument.SubItems.Add;
      itemSubMenu.Caption := 'Open ' + ExtractFilename(strFilename);
      itemSubMenu.InternalData := strFilename;
      itemSubMenu.OnClick.OnEvent := Self.LinkedDocumentOpenClick;
      itemSubMenu := itemDocument.SubItems.Add;
      itemSubMenu.Caption := 'Delete ' + ExtractFilename(strFilename);
      itemSubMenu.OnClick.OnEvent := Self.LinkedDocumentDeleteClick;
      itemSubMenu.InternalData := strFilename;
    end;

end;


Anybody have a suggestion?

Thanks,
Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Alexander Bulei » 23 May 2014 10:23

Hi ScottWGast,

Please make the simple testcase project.

t.i.a

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by ScottWGast » 23 May 2014 15:22

Good morning!
I finally figured out my problem; I needed to set .ClipRegion := True; on the parent region.
The Vertical scroll bar now shows up when I exceed the height of the region when adding menu items.

So many properties... so easy to forget.

Thanks!
Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Alexander Bulei » 23 May 2014 18:33

Hi ScottWGast,

good ;)

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to General - Archive

Who is online

Users browsing this forum: No registered users and 0 guests

Contact Us.