- This topic has 4 replies, 2 voices, and was last updated 15 years, 6 months ago by JanK.
-
AuthorPosts
-
May 15, 2009 at 1:18 pm #32962JanKParticipant
I'm trying to create an array of TsButtons at runtime, with a TsPanel as their parent. They should have another sSkinManager then the rest of the form. I already added second sSkinManager to the form at design time. Adding a TsButton at design time works without problems.
However, when creating the controls at runtime, the buttons don't behave correctly. They look like a TLabel, with skinned background, as if the button (or panel) didn't refresh/repaint correctly.
The code is about as follows (excerpt):CODEbuttonsArray : array of TsButton;// Handling of array, etc.
// code to show buttons…..SetLength(buttonsArray, Table.RecordCount);
nNumber:=0;
while not Eof do begin
buttonsArray[nNumber] := TsButton.Create(self);
buttonsArray[nNumber].SkinData.FSkinManager:=sSkinManager2;
buttonsArray[nNumber].SkinData.SkinSection:='BUTTON';
buttonsArray[nNumber].Parent:=PanelTags; // this is a TsPanel with SkinManager1
buttonsArray[nNumber].Left:=nLeft;
buttonsArray[nNumber].Top:=nTop;
buttonsArray[nNumber].Width:=nWidth;
buttonsArray[nNumber].Caption:=cTitle;
buttonsArray[nNumber].OnClick:=BtnClick;
buttonsArray[nNumber].Visible:=True;
nLeft:=nLeft+nWidth+10;
Next;
Inc(nNumber);
endWhat am I missing here? Any ideas?
Thanks in advance,Regards
Jan
Using Delphi2009, AlphaControls 6.22 TrialMay 18, 2009 at 7:27 am #39257SupportKeymasterHello
You must be sure that second SkinManager is created and available before creating buttons.
If is possible to make a little example application for tests then it will be very helpful.May 18, 2009 at 9:45 am #39269JanKParticipantThanks, I enclosed an example with all the unnecessary code stripped from my project. In the SkinManagers, you have to set the skindirectory manually, before compiling. Skinmanager 2 is set at design time.
The generated buttons should have the skin provided by the second skinmanager, and should toggle the “Down” property when pressed.
Two questions:
1) How do I get the skinning right?
2) When the buttons are pressed, a runtime error is generated at formclose?Thanks in advance,
Regards
JanMay 18, 2009 at 1:02 pm #39278SupportKeymasterThank you
You must change this line
CODEbuttonsArray[nNumber].SkinData.FSkinManager:=sSkinManager2;to
CODEbuttonsArray[nNumber].SkinData.SkinManager:=sSkinManager2;
Skinning data will be updated in this case, and problem must be solved.Also I can suggest you to move this line :
CODEbuttonsArray[nNumber].Parent:=PanelTags;after “Visible:=True;”. And remove “Visible:=True;” because button is visible already when created.
May 19, 2009 at 5:45 pm #39301JanKParticipantThanks Serge, that helped a lot! One character, big change…
Besides, the access violation I mentioned was raised by the “TsButton.Refresh” method. But that line was also deleted now.Regards
Jan -
AuthorPosts
- You must be logged in to reply to this topic.