delphi - Load many pictures in a form -


i asked develop game called "flag quiz" in player have guess correct name of flag appears in middle of screen.

enter image description here

of course have lot of pictures (221 flags) , have put them inside program because, when button play pressed, program has pick randomly 10 of these flags.

problem thinking use imagelist flags 480x311 , delphi asks me separate picutre in 30 different bitmaps. can this?

my idea, avoid problem, following (although think it's not good): create 221 tpicture components (invisible user of course) , load in each of them picture of flag.

i'd prefer not using last idea had. know improvement?

this sort of problem not suited form designer. want store 221 images, , managing in ide horrible. once you've got them in won't able see them readily because base 16 encoded in .dfm file. under revision control mess because won't able change individual images in manageable , traceable manner.

the accepted way use resources. if me, i'd arrange images have predicatable names. instance, flag1, flag2, etc. i'd generate resource script (.rc) listed flags. i'd compile resource script compiled resource (.res) linked executable. i'd have resource script , image files committed revision control.

then @ runtime have single timage control display flag. every time need new image load tresourcestream, , push timage control.


Comments