delphi - How check all TImage in Form -


what run if statement checks if timage object in form has .top property equal tedit1.text. want change .image property of timage matched variable /images/buttonstand/jpeg

you can loop through form.components locate it. (you didn't specify you'd variable .top, i've retrieved tedit. didn't specify new image come from, i've presumed it's loaded tbitmap somewhere.)

procedure tform1.changeimagebuttonclick(sender: tobject); var   i: integer;   topvalue: integer;   newbmp: tbitmap; begin   // top value locate edit1   topvalue := strtointdef(edit1.text, -1);     if topvalue = -1  // user entered invalid value. nothing do; bail out.     exit;    := 0 componentcount - 1   begin     if components[i] timage     begin       if timage(components[i]).top = topvalue       begin         newbmp := tbitmap.create;         newbmp.loadfromfile('images' + inttostr(i) + '.bmp');         try           timage(components[i]).picture.graphic.assign(newbmp);                   newbmp.free;         end;       end;     end;   end; end; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -