Friday 15 March 2013

c# - Picture Box doesn't show image -



c# - Picture Box doesn't show image -

i have form project in vs2010. scenario: created form want utilize splash screen, without borders. within have image box big form. set image importing , in designer can see it. when phone call splashscreen form form , show it, can see image box borders, doesn't load image.

update

i load splashscreen in bmform_load (other form):

splashscreen ss = new splashscreen(); ss.topmost = true; ss.show(); //prepare bmform.... ss.close();

and designer code snippet image box in splash screen form:

this.picturebox1.borderstyle = system.windows.forms.borderstyle.fixedsingle; this.picturebox1.dock = system.windows.forms.dockstyle.fill; this.picturebox1.image = ((system.drawing.image)(resources.getobject("picturebox1.image"))); this.picturebox1.imagelocation = ""; this.picturebox1.initialimage = null; this.picturebox1.location = new system.drawing.point(0, 0); this.picturebox1.name = "picturebox1"; this.picturebox1.size = new system.drawing.size(256, 256); this.picturebox1.sizemode = system.windows.forms.pictureboxsizemode.stretchimage; this.picturebox1.tabindex = 0; this.picturebox1.tabstop = false; this.picturebox1.waitonload = true;

update 2

if doesn't close splashscreen form before other form load end, image shown after this!

question

somebody knows why isn't image showed?

what problem seems preparation of bmform locking downwards main ui thread trying load splash image process commands prepare bmform. counter this, load splash form in own thread , close thread/form when done loading.

example of code:

inside bmform_load

thread splashthread = new thread(showsplash); splashthread.start(); // initialize bmform splashthread.abort(); // ensure form gets focus back, can left out. bmform.focus();

the method show splash screen

private void showsplash() { splashscreen splashscreen = null; seek { splashscreen = new splashscreen(); splashscreen.topmost = true; // utilize showdialog() here because form doesn't show when using show() splashscreen.showdialog(); } grab (threadabortexception) { if (splashscreen != null) { splashscreen.close(); } } }

you might need add together using system.threading; class , add together error handling bmform_load event in case errors occur, can clean splashthread.

you can read more threading here

c# image forms picturebox splash-screen

No comments:

Post a Comment