[SOLVED] Here is a strange thing… how can i solve it ?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #34784
    azrael11
    Participant

    i have this procedure…

    Code:
    Procedure StartSkinEngine;
    var
    i: Integer;
    skinnames: TStringList;
    Begin
    Conf.skinM.SkinDirectory := Program_Path+'mediaconfeditorskins';
    SkinNames := TStringList.Create;
    Conf.SkinM.SkinName := Conf.SkinM.GetSkinNames(SkinNames);
    Conf.sLB_ce_themes.Items.Clear;
    for i := 0 to skinnames.Count -1 do
    Conf.sLB_ce_themes.Items.Add(SkinNames);
    i := ConfIni.ReadInteger('Themes','Theme',i);
    Conf.sLB_ce_themes.Selected := true;
    Conf.sLabelFX3.Caption := Conf.sLB_ce_themes.Items.Strings;
    Conf.img_ce_theme.Picture.LoadFromFile('mediaconfeditorskinspreview'+conf.sLB_ce_themes.items.strings+'.png');
    ThemeCreator(i+1);
    SetAllCursor(i+1);
    GroupBoxColors(i);
    conf.skinM.SkinName := Conf.sLB_ce_themes.Items.Strings;
    Conf.skinM.Active := True;
    Application.ProcessMessages;
    skinnames.Free;
    end;

    I run it to my project everything is ok BUT

    When i try to use the SelectDirectory from FileCtrl then i get a strange error that “EstringList.error List index out of bounds(0)”;

    i remove the procedure so i setup no theme the SelectDirectory WORKS PERFECT so

    HELP….

    #46718
    Support
    Keymaster

    Hello

    I think, you should debug this code more.

    The “i” variable can have incorrect value here…

    This topic will be moved in “Troubleshooting” part.

    #46722
    azrael11
    Participant
    'Support' wrote:

    Hello

    I think, you should debug this code more.

    The “i” variable can have incorrect value here…

    This topic will be moved in “Troubleshooting” part.

    I dubug the code and i found nothing other than this…

    When i make active the skinm i get the above error…

    I change the i variable to other name like xxxmmmkkk but nothing changes….

    Try difernet skins nothing changes…

    Please help… this keeps my project back….

    Thank you….

    #46729
    Support
    Keymaster
    'azrael11' wrote:
    i := ConfIni.ReadInteger('Themes','Theme',i);

    What is value of “i” here? You should check it.

    Quote:
    Conf.sLB_ce_themes.Selected := true;

    Error may be occurred here if “i” is out of range.

    Quote:
    Conf.sLabelFX3.Caption := Conf.sLB_ce_themes.Items.Strings;

    “i” should be bigger or equal 0 and smaller than Conf.sLB_ce_themes.Items.Strings.Count

    And sLB_ce_themes is ListBox? Maybe you should write Conf.sLB_ce_themes.Items?

    Quote:
    ThemeCreator(i+1);

    SetAllCursor(i+1);

    I don't know what is that, but why “i + 1”?

    You should check all this code?

    What is number of line with “Out of range” error?

    #46741
    azrael11
    Participant
    Code:
    Procedure StartSkinEngine;
    var
    skinnames: TStringList;
    rec : TSearchRec;
    themeName: string;
    Begin
    Conf.skinM.SkinDirectory := Program_Path+'mediaconfeditorskins';
    SkinNames := TStringList.Create;
    Conf.SkinM.SkinName := Conf.SkinM.GetSkinNames(SkinNames);
    Conf.sLB_ce_themes.Items.Clear;
    if FindFirst(Conf.SkinM.SkinDirectory+'*.*' , faAnyFile, Rec) = 0 then
    begin
    repeat
    if ((Rec.Attr and faDirectory) <> faDirectory) then
    begin
    themeName := Trim(Copy(rec.Name,0,Length(rec.Name)-4));
    Conf.sLB_ce_themes.Items.Add(themeName);
    end;
    until FindNext(Rec) <> 0;
    end;
    Conf.SkinM.SkinName := 'creamy_velvet';
    Conf.skinM.Active := True;
    Application.ProcessMessages;
    skinnames.Free;
    end;

    Ok here is more simple code i wrote again the same above problem…

    Now i am not using any integer variable so that envolves something…

    I update to the last version (the stable) but the problem remains…

    If i make Conf.skinM.active := False; everything works ok…

    If I make it true everything works ok exept the selectdirectory funtion that gives me the above error…

    help…

    p.s.

    The ThemeCreator(i+1) is just give the creator name and the skin name in alabel…

    The SetAllCursor(i+1) just strats the animated cursors engine…

    #46747
    azrael11
    Participant

    Please someone help i really stuck here…

    #46749
    Hamilton
    Participant

    Hi Azrael,

    You say the code raised an exception on 'selectdirectory' but that method is not called in your code. Regardless, I did try to run your code and apart from a couple of minor changes to get it working in a test environment everything seemed OK. Can you please try the following:

    1. Create a new application

    2. Add a tsbutton, align to bottom

    3. Add a tsmemo, align to client

    4. Add an OnClick event to the button and call the slightly modified StartSkinEngine procedure I've posted below. I made some slight changes to your code to get it to work in this scenario but nothing that affects the operation.

    For me, the code ran successfully and caused the memo to be modified to contain the list of all skins in my skin folder and it set the skin to the one I'd requested.

    If this doesn't work then there is something about your environment I'd guess. I didn't experiment what would happen if the skin folder had hidden files or folders but you could try something like searching for 'faAnyFile – faDirectory' insead of 'faAnyFile'. Also if you find your code works in the test app but doesn't in your project then something else to consider might be to change your file IO methods to explicitly call SysUtils, for example SysUtils.FindFirst, to avoid type mismatches with functions of the same name in other libraries (i've had this happen before, its obscure but maybe the wrong function is being called).

    Anyway good luck I hope you get it sorted soon.

    Procedure TForm1.StartSkinEngine;

    var

    skinnames: TStringList;

    rec : TSearchRec;

    themeName: string;

    Begin

    sSkinManager1.SkinDirectory := 'C:Delphi AddonsAlphaControlsSkins';

    // sSkinManager1.SkinDirectory := ExtractFilePath(Application.ExeName) + 'mediaconfeditorskins';

    SkinNames := TStringList.Create;

    sSkinManager1.SkinName := sSkinManager1.GetSkinNames(SkinNames);

    sMemo1.Lines.Clear;

    if FindFirst(sSkinManager1.SkinDirectory+'*.*' , faAnyFile, Rec) = 0 then

    begin

    repeat

    if ((Rec.Attr and faDirectory) <> faDirectory) then

    begin

    themeName := Trim(Copy(rec.Name,0,Length(rec.Name)-4));

    sMemo1.Lines.Add(themeName);

    end;

    until FindNext(Rec) <> 0;

    end;

    sSkinManager1.SkinName := 'darkglass';

    sSkinManager1.Active := True;

    Application.ProcessMessages;

    skinnames.Free;

    end;

    #46757
    azrael11
    Participant
    'Hamilton' wrote:
    Also if you find your code works in the test app but doesn't in your project then something else to consider might be to change your file IO methods to explicitly call SysUtils, for example SysUtils.FindFirst, to avoid type mismatches with functions of the same name in other libraries (i've had this happen before, its obscure but maybe the wrong function is being called).

    Thank you my friend this is it… 😉 at last…

    I change the findfirst with sysutils.findfirst as you suggest and everything works great…

    Now a small question how can i track this problem… the source code consists from 30 units and a 30.000 lines of code… any tool to track it or anything else

    #46758
    Hamilton
    Participant

    Glad I could help 🙂 I'm not sure I understand your additional question but I think you'll just want to search for occurrences of FindFirst and FindNext throughout your project and change them all to SysUtils.FindFirst and SysUtils.FindNext. Best of luck.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.