Author |
Topic: Problems using AnimateWindow (Read 372 times) |
|
Chris Iverson
Moderator
member is offline

20% Cooler

Gender: 
Posts: 1720
|
 |
Re: Problems using AnimateWindow
« Reply #15 on: Apr 21st, 2012, 12:07pm » |
|
Microsoft doesn't choose to break things. They put a lot of work into trying to make applications work, even when said applications have been written improperly and don't follow the standards MS has laid out.
It's an annoying state for them, to be sure. They lay out guidelines, the guidelines get ignored, and then on the next version of Windows, the app stops working and people blame Microsoft for breaking it. So MS goes back and adds compatibility shims to attempt to get it working again.
(You can get a lot of information on The Old New Thing, a blog by Raymond Chen, a developer for Microsoft. Search for anything related to compatibility. http://blogs.msdn.com/b/oldnewthing/)
So, yes. Programs written in LB 4.03 should work just fine in Windows 8. Programs that worked in Windows 7, save for those that require OS-specific code, should work on Windows 8. I'm using it right now, and every single one of the programs I run works just fine on Windows 8, with the current exception of one of my antivirus programs and Sandboxie, both of which require burying themselves deep into the OS. They don't work because they need to be recoded to work with Windows 8. If the work they do is done improperly, it could break your system.
|
"It needs to be about 20% cooler." - Rainbow Dash giving the advice every designer hates to hear.
|
|
|
Precise Timing
Full Member
member is offline

Trying to sync Windows time with nanosecond accuracy...

Gender: 
Posts: 129
|
 |
Re: Problems using AnimateWindow
« Reply #16 on: Apr 21st, 2012, 4:08pm » |
|
Ok, it might not be a good idea to post this because i am not sure if the problem has to do with the explanation i provide, but i'm a little confused.
I completed the testing of the complete program (not only the splash window code i posted previously). It works perfect on my desktop and on my netbook (Windows XP 32 bit) but failed with an "Out of memory" runtime error when i tried it on a laptop with Windows Vista 32 bit, right after i clicked the "Run Setup" menu selection.
The error indicates something to do with the "unloadbmp" command at the program's exit. Because i do not have the computer, i cannot tell why this happened (and that's why i hesitate to ask for help).
I did a search on the forums to find out that these errors do come up from unloading bmp's or filling arrays. So, i suspect that the 'unloadbmp "game" ' at the program exit has to do with that. I also suspect the way i made the menus change color (from white to yellow). A test with the task manager (observing the RAM usage) with the program running from the IDE indicates that the RAM usage starts with a value at about 5.700 KB and ends at about 6.500 KB - after that it resets back to the starting value.
I DO have infinite loops (two to be accurate - one checks for mouse cursor position to change the menu color and the second to capture the mouse clicks).
The weird thing is that the first "unloadbmp" command works without problems (not showing any runtime error) and no problems at all are reported on my computers.
Code follows. You can replace the images with anything you have (not size specific but must be .bmp) with the names "splash" and "game". If it matters, current "splash" image size is 439 KB (500 x 300 px) and "game" image is 325 KB (370 x 300 px).
Code:
'=============================================================================================================
' autorun.bas
' Created: 04/16/2012
' Last Modified: 04/21/2012
'=============================================================================================================
' Define variables (global & local, arrays).
nomainwin
WindowWidth = 500
WindowHeight = 300
UpperLeftX = int((DisplayWidth - WindowWidth) / 2)
UpperLeftY = int((DisplayHeight - WindowHeight) / 2)
splashImage$ = "Resource\splash.bmp"
gameImage$ = "Resource\game.bmp"
AW.BLEND = hexdec("&H80000")
AW.HIDE = hexdec("&H10000")
quit = 0
'-------------------------------------------------------------------------------------------------------------
' Load the game images (splash screen image, main window image).
loadbmp "splash", splashImage$
loadbmp "game", gameImage$
hSplashImage = hbmp("splash")
hGameImage = hbmp("game")
'-------------------------------------------------------------------------------------------------------------
' Create the splash screen window.
stylebits #splash, _DS_CENTER, _WS_VISIBLE, _WS_EX_TOOLWINDOW or _WS_EX_TOPMOST, 0
stylebits #splash.img, _SS_BITMAP, 0, 0, 0
statictext #splash.img, "", 0, 0, WindowWidth, WindowHeight
open "splash" for dialog_popup as #splash
null = SendMessage(hwnd(#splash.img), _STM_SETIMAGE, _IMAGE_BITMAP, hSplashImage)
null = AnimateWindow(hwnd(#splash), 1000, AW.BLEND)
retSleep = pause(4000)
null = AnimateWindow(hwnd(#splash), 1000, AW.BLEND or AW.HIDE)
'-------------------------------------------------------------------------------------------------------------
' Close the splash screen window and create the main window.
stylebits #auto, 0, _WS_BORDER, _WS_EX_TOOLWINDOW or _WS_EX_TOPMOST, 0
stylebits #auto.img, _SS_BITMAP, 0, 0, 0
statictext #auto.img, "", 0, 0, 350, 300
graphicbox #auto.menu, 370, 0, 130, 300
unloadbmp "splash"
close #splash
open "autorun" for window_popup as #auto
#auto, "trapclose quit"
null = SendMessage(hwnd(#auto.img), _STM_SETIMAGE, _IMAGE_BITMAP, hGameImage)
'-------------------------------------------------------------------------------------------------------------
' Set the menu selections.
#auto.menu, "home"
#auto.menu, "down"
#auto.menu, "fill black"
#auto.menu, "color white ; backcolor black"
#auto.menu, "when mouseMove menuSelection"
#auto.menu, "when leftButtonUp menuAction"
#auto.menu, "place 20 40 ; font courier_new ;\Run Setup"
#auto.menu, "place 40 280 ; font courier_new ;\Exit"
#auto.menu, "flush menuInstaller"
'-------------------------------------------------------------------------------------------------------------
' Check for user input.
do
scan
null = pause(15)
loop until quit = 1
'=============================================================================================================
'=================================================SUBROUTINES=================================================
'=============================================================================================================
' Close the main window.
sub quit quitHandle$
unloadbmp "game"
close #auto
end
end sub
'-------------------------------------------------------------------------------------------------------------
' Run the game installer program.
sub runSetup
run "setup.exe"
call quit quitHandle$
end sub
'-------------------------------------------------------------------------------------------------------------
' Check for mouse cursor position.
sub menuSelection menuSelectionHandle$, xPos, yPos
if xPos > 50 and xPos < 85 and yPos > 270 and yPos < 280 then
#auto.menu, "delsegment menuInstaller"
#auto.menu, "color yellow ; backcolor black"
#auto.menu, "place 40 280 ; font courier_new ;\Exit"
#auto.menu, "flush menuInstaller"
else
#auto.menu, "delsegment menuInstaller"
#auto.menu, "color white ; backcolor black"
#auto.menu, "place 40 280 ; font courier_new ;\Exit"
#auto.menu, "flush menuInstaller"
end if
if xPos > 15 and xPos < 115 and yPos > 30 and yPos < 40 then
#auto.menu, "delsegment menuInstaller"
#auto.menu, "color yellow ; backcolor black"
#auto.menu, "place 20 40 ; font courier_new ;\Run Setup"
#auto.menu, "flush menuInstaller"
else
#auto.menu, "delsegment menuInstaller"
#auto.menu, "color white ; backcolor black"
#auto.menu, "place 20 40 ; font courier_new ;\Run Setup"
#auto.menu, "flush menuInstaller"
end if
end sub
'-------------------------------------------------------------------------------------------------------------
' Check for left mouse button action.
sub menuAction menuActionHandle$, xPos, yPos
if xPos > 15 and xPos < 115 and yPos > 30 and yPos < 40 then
call runSetup
end if
if xPos > 50 and xPos < 85 and yPos > 270 and yPos < 280 then
call quit quitHandle$
end if
end sub
'=============================================================================================================
'==================================================FUNCTIONS==================================================
'=============================================================================================================
function AnimateWindow(handle, dwTime, dwFlags)
calldll #user32, "AnimateWindow", _
handle as ulong, _
dwTime as long, _
dwFlags as long, _
result as long
AnimateWindow = result
end function
'=============================================================================================================
function pause(millisec)
calldll #kernel32, "Sleep", _
millisec as long, _
retSleep as void
pause = retSleep
end function
'=============================================================================================================
function SendMessage(handle, message, wParam, lParam)
calldll #user32, "SendMessageA", _
handle as ulong, _
message as long, _
wParam as long, _
lParam as ulong, _
result as long
SendMessage = result
end function
I'm 100% sure that i have missed something here...
EDIT: I have put the ' unloadbmp "game" ' commmand before the close #auto command. Is this a possible problem (the demo at LBPE about images on statictext has the unloadbmp after the window closing)?
|
|
|
|
Stefan Pendl
Global Moderator
member is offline

Computers are like babies, you must teach them what you like them to do ...

Gender: 
Posts: 4987
|
 |
Re: Problems using AnimateWindow
« Reply #17 on: Apr 21st, 2012, 5:02pm » |
|
on Apr 21st, 2012, 4:08pm, Precise Timing wrote:| EDIT: I have put the ' unloadbmp "game" ' commmand before the close #auto command. Is this a possible problem (the demo at LBPE about images on statictext has the unloadbmp after the window closing)? |
|
If you remove the image before the window is closed, you could as well remove the chair while you are seated on it.
Always close the controls/windows using the resources before you get rid of the resources.
As a quick test comment out UNLOADBMP and you will be certain.
|
|
Logged
|
Stefan - Homepage
Please give credit if you use code I post, no need to ask for permission.
Liberty BASIC Pro 4.04, Windows 7 Home Premium x64 SP1, AMD Turion X2 RM-70 2GHz, 4GB RAM
|
|
|
Brandon Parker
Moderator
member is offline


Gender: 
Posts: 824
|
 |
Re: Problems using AnimateWindow
« Reply #18 on: Apr 21st, 2012, 9:08pm » |
|
Can you post the error log?
It could be related to something else......
{:0)
Brandon
|
|
Logged
|
Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
|
|
|
Precise Timing
Full Member
member is offline

Trying to sync Windows time with nanosecond accuracy...

Gender: 
Posts: 129
|
 |
Re: Problems using AnimateWindow
« Reply #19 on: Apr 22nd, 2012, 5:02pm » |
|
Yes, i will be able to retrieve the error log tomorrow (it is not up to me if i can manage to get the laptop where it is located). But i will certainly post it when i get it.
EDIT: Ok, a quick update. Stefan was right about the "unloadbmp" command. I changed it and placed it after the "close" command and now works perfect. Now, i need to do some corrections with the images and the menus (for different screen resolutions).
|
|
|
|
|