Forum > LCL

Using same procedure to generate menu on Form1 and Combobox on Frame2

<< < (2/3) > >>

wasp41p:
Yes, Sure, It's me.

wp:

--- Quote from: wasp41p on August 15, 2023, 05:29:59 pm ---So far so good except for the procedure which assigns the active synedit, it refers to the pagecontrol1 of form1, if I move it to the common unit in this way it gives me an access violation during compilation.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function CurrentSynEdit(APageControl1: TPageControl): TSynEdit;begin  if APageControl1.ActivePage <> nil then    Result := TSynEdit(APageControl1.ActivePage.Tag)  else    Result := nil;end;                                  
--- End quote ---
Something is wrong here: Your code shows the opposite of what you are saying. It does not assign the synedit to the ActivePage - it's the other way: it retrieves the synedit from the ActivePage.

wasp41p:
Yes. You are right, I misspelled

wp:
And then? Is the code shown causing the issue? If yes: Are you sure that APageControl1 is not nil? Or: Is the code calling CurrentSynEdit able to handle the case that CurrentSynEdit may return a nil result?

wasp41p:
I was checking and that´s not the problem.
The problem is this and I don´t understand how to solve it, I should assign him the owner but I don´t know how, since he´s in another unit.
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure PrepareHighlighters(AList: TFPList; AMenu: TMenuItem; ACombobox: TComboBox; AClickHandler: TNotifyEvent);var  i: Integer;  HL: TSynCustomHighlighter;  item: TMenuitem;beginAList := TFPList.Create;AList.Add(TSynADSP21xxSyn.Create(self));AList.Add(TSynFortranSyn.Create(self));AList.Add(TSynGalaxySyn.Create(self));AList.Add(TSynBaanSyn.Create(self));AList.Add(TSynAWKSyn.Create(self));AList.Add(TSynHaskellSyn.Create(self));AList.Add(TSynCacheSyn.Create(self));AList.Add(TSynModelicaSyn.Create(self));AList.Add(TSynCobolSyn.Create(self));AList.Add(TSynCSSyn.Create(self));AList.Add(TSynDmlSyn.Create(self));AList.Add(TSynProgressSyn.Create(self));AList.Add(TSynEiffelSyn.Create(self));AList.Add(TSynGWScriptSyn.Create(self));AList.Add(TSynHP48Syn.Create(self));AList.Add(TSynVBScriptSyn.Create(self));AList.Add(TSynUnrealSyn.Create(self));AList.Add(TSynVrml97Syn.Create(self));AList.Add(TSynTclTkSyn.Create(self));AList.Add(TSynLDRSyn.Create(self));AList.Add(TSynRubySyn.Create(self));AList.Add(TSynInnoSyn.Create(self));AList.Add(TSynAsmSyn.Create(self));AList.Add(TSynDOTSyn.Create(self));AList.Add(TSynIdlSyn.Create(self));AList.Add(TSynKixSyn.Create(self));AList.Add(TSynSDDSyn.Create(self));AList.Add(TSynSMLSyn.Create(self));AList.Add(TSynFreePascalSyn.Create(self));AList.Add(TSynM3Syn.Create(self));AList.Add(TSynRCSyn.Create(self));AList.Add(TSynPrologSyn.Create(self));AList.Add(TSynLuaSyn.Create(self));AList.Add(TSyn8051Syn.Create(self));AList.Add(TSynCACSyn.Create(self));AList.Add(TSynJavaSyn.Create(self));AList.Add(TSynSQLSyn.Create(self));AList.Add(TSynVHDLSyn.Create(self));AList.Add(TSynVerilogSyn.Create(self));AList.Add(TSynJSONSyn.Create(self));AList.Add(TSynPasSyn.Create(self));AList.Add(TSynXMLSyn.Create(self));AList.Sort(@CompareHighlighters); if (AMenu <> nil) then  for i:=0 to AList.Count-1 do begin    HL := TSynCustomHighlighter(AList[i]);    if Assigned(HL) then    begin      item := TMenuItem.Create(nil);      AMenu.Add(item);      item.Caption := Format('%d - %s', [i, GetHighlighterCaption(HL)]);      item.Tag := i+1;      item.OnClick := AClickHandler;      if AComboBox <> nil then AComboBox.Items.Add(item.Caption);    end;  end;end;                                            

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version