- NSIS Discussion
- wansis and LoadImage problems
Archive: wansis and LoadImage problems
sorinoss
29th April 2006 03:42 UTC
wansis and LoadImage problems
i use this command to load images i need to display on my installer
ReadINIStr $ctrlhandle "$PLUGINSDIR\select_skin.ini" "Field 2" "HWND"
System::Call "user32::LoadImage(i 0, t '$R0', i 0, i 310, i 180, i ${LR_LOADFROMFILE}) i.s"
Pop $bmphandle
SendMessage $ctrlhandle 0x0172 "" "$bmphandle"
the images are changed by a droplist event
with wansis:
if i change the images too fast with the mouse wheel .. then the installer simply quits
it's enough to scroll up or down several items in the list by moving the mouse wheel relatively fast
without wansis:
if i scroll like crazy for about 30 seconds then the image dissapears and same thing happens to all the other images in the installer [i.e. on the welcome/finish screen]
kichik
29th April 2006 10:04 UTC
It probably runs out of handles. You should close the image handle after you're done with it.
sorinoss
29th April 2006 15:43 UTC
now i have this code for reading the size of the bitmap image
System::Alloc 24
Pop $R3
System::Call `user32::LoadImage(i 0, t "$R0", i 0, i 0, i 0, i ${LR_LOADFROMFILE}) i.R1`
System::Call `gdi32::GetObject(i R1, i 24, i R3)`
System::Call `*$R3(i, i .R1, i .R2, i, i, i, i)`
System::Call `gdi32::DeleteObject(i R1)`
System::Free $R3
and this code to put the image on screen
ReadINIStr $ctrlhandle "$PLUGINSDIR\select_skin.ini" "Field 2" "HWND"
System::Call "user32::LoadImage(i 0, t '$R0', i 0, i '$0', i '$1', i ${LR_LOADFROMFILE}) i.s"
Pop $bmphandle
SendMessage $ctrlhandle 0x0172 "" "$bmphandle"
System::Call `gdi32::DeleteObject(i bmphandle)`
System::Call `gdi32::DeleteObject(i ctrlhandle)`
; last plugin call must not have /NOUNLOAD so NSIS will be able to delete
; the temporary DLL
SetPluginUnload manual
; do nothing (but let the installer unload the System dll)
System::Free $bmphandle
System::Free $ctrlhandle
i have put the lines for $bmphandle and $ctrlhandle in an attempt to free the resource
still exactly the same problems
but after i have added the code to read the image pixel size the problems appear sooner [on scroll wheel select]
Afrow UK
29th April 2006 15:57 UTC
Not sure why you need the code to get the image size. You can just use 0 for the width and height when you want to use the original dimensions when using LoadImage (just like I have done in the code that you requested).
-Stu
sorinoss
29th April 2006 16:17 UTC
i need it because i need to resize the image to fit the window
the image is from outside of the installer
and it may have a different size than the size i can put in the installer 310x180
so i need to display a scaled image in the installer, i don;t want a distorted one
Joel
29th April 2006 18:31 UTC
I have on mu vault a script to get bitmap sizes...
Converted to nsis...
sorinoss
29th April 2006 20:25 UTC
:) thanx for the script
but the problem is not the image size
i have the image size and also have made the code to scale down the image to fit in 320x180 pixels because i will use images of any size
but the problem is that the installer seems to have some problems when i change the image using a droplist event
with or without wansis
with wansis it's more dificult because the installer exits for no reason
without wansis if i change the droplist [eachs change causes the image to change also]after a while all the images from the installer are gone [incl. those from welcome/finish pages]
so i susspect there is a problem with my code
maybe i have smth wrong with image handles ...
i have posted the code because i am not sure i have the correct commands for closing the handle ..
thanx in advance :)
kichik
29th April 2006 20:36 UTC
Your delete object calls are missing a dollar sign for the bmphandle vriable. ctrlhandle shouldn't be closed.
sorinoss
29th April 2006 20:59 UTC
ok i have this code now ...
ReadINIStr $ctrlhandle "$PLUGINSDIR\select_skin.ini" "Field 2" "HWND"
System::Call "user32::LoadImage(i 0, t '$R0', i 0, i '$0', i '$1', i ${LR_LOADFROMFILE}) i.s"
Pop $bmphandle
SendMessage $ctrlhandle 0x0172 "" "$bmphandle"
System::Call `gdi32::DeleteObject(i $bmphandle)`
now it's a little strange
the images r dissapearing like before
exept a few of them from the droplist [2 maybe 3]
also .. no image appears at the first run [on page show]
i have 40-60 items in the drolist so i have to read 40-60 different bitmap images
images are read each time i change the droplist
maybe i chenge too fast with the mouse wheel so the system diesn;t have time to do all the commands
do you think it would be usefull to add a delay timer of about 100 miliseconds?
like Sleep 100
[to give time to the system to do the comands and close the handle aswell]
kichik
29th April 2006 21:01 UTC
You should close the handle only after you change the picture. If you close the handle of an image being displayed, it'll disappear.
sorinoss
29th April 2006 21:12 UTC
ah yes ... true
but the image remains on the screen untill a another window gets over and then the image dissapears
but i have observed that it seems my used memory increases during this operation [changing the droplist]
but it gets nowhere near 50% ...
on task manager i have the setup using abou 3-4 megs maximum
but the page file usage increases a lot .. 100-200 megs maybe more
sorinoss
29th April 2006 21:30 UTC
oh, i have observed smth interesting
at the first display of each of the bmp images, all is ok
no increase in memory usage or page file usage [not even by a bit]
but then on the second display it starts to increase pf usage
third disply of the same picture same increase ... and so on
so at some point the hard disk starts to roll and the images dissapear
after 5-6 displays of all 60 pictures
why is this happening
sorinoss
30th April 2006 11:55 UTC
now i have added the code
System::Call `gdi32::DeleteObject(i $bmphandle)`
just before changing the bitmap
now i can change the images twice before the pagefile starts to load data
is this a bug of LoadImage .. or is it me?
kichik
1st May 2006 19:30 UTC
It's you. You are probably not handling the handles correctly. If you can't find the problem, attach the entire script for a review.
sorinoss
2nd May 2006 01:10 UTC
i have posted reply by mistake to the other post, sorry
i have simplified the code
i have deleted some functions that were reading from some files [fileopen, file read, fileclose and a few loops], and read from registry
now the pictures don't disappear, but after a few scrolls
i get the size of the pictures x=0 y=o :-s
please put some bmp's in the "pict" directory to test
prefferably more than 20 with 500*300 pixels or bigger
kichik
2nd May 2006 12:08 UTC
In your code to get the bitmap size, you change $R1 which contains the bitmap handle. When you later call DeleteObject, it's deleting the wrong object.
sorinoss
2nd May 2006 12:20 UTC
i have tried that also
same error :cry:
sorinoss
2nd May 2006 21:36 UTC
it woked :D
soory, it was my fault
well, i have adapted the code from Afrow UK
it seems he made the same error in his code
this is the code i have used to make it work
System::Alloc 24
Pop $R3
System::Call `user32::LoadImage(i 0, t "$R0", i 0, i 0, i 0, i ${LR_LOADFROMFILE}) i.R7`
System::Call `gdi32::GetObject(i R7, i 24, i R3)`
System::Call `*$R3(i, i .R1, i .R2, i, i, i, i)`
System::Call `gdi32::DeleteObject(i $R7)`
System::Free $R3
but the problem with wansis still remains
setup exits if i rapidly change the droplist
wansis is not skining the droplist
is this a wansis problem?
sorinoss
2nd May 2006 22:02 UTC
here is the script i have used for testing
quick scroll the droplist with ouse wheel and installer exits :-s
do you recommend using skincrafter instead?
personally i have chosen wansis because of the simplicity of the bmp files
sorinoss
2nd May 2006 22:03 UTC
sorry i forgot to attach the script
kichik
3rd May 2006 10:31 UTC
I don't know why it crashes with wansis, but the rest works fine. The GDI handle count stays foot and so does the memory usage. You should contact the author of wansis.
dandaman32
3rd May 2006 20:28 UTC
I'va had a similar problem with wansis and droplist events in the ExperienceUI 1.1 beta 3 installer (i think). When I did the mouse wheel thing under Win2k it showed a "setup.exe has generated errors and will be closed by Windows" message. It didn't change a bitmap, just a couple of labels. There were only 4 options in the drop down list.
-dandaman32
sorinoss
7th May 2006 23:59 UTC
have you solved the problem?
or the only solution is to remove wansis...
onad
8th May 2006 15:55 UTC
you could opt for a sleep of a few millisecs in the script.
( and forced message que refresh maybe)