|
Post by Mark Dunham on Aug 29, 2020 21:33:13 GMT -5
Okay, I have been working on this for a few hours now and I need some assistance please. I can get the Animation Control window to open but I cannot get my buttons to show on the animation control window. I bought Alyce's book API's for Liberty Basic and I am working through some of the example's to get a better understanding of API and DLL calls. Any assistance anyone can provide is greatly appreciated.
'Animation Control'
nomainwin
WindowWidth = 800 WindowHeight = 600 UpperLeftX = ((DisplayWidth - WindowWidth)/2) UpperLeftY = ((DisplayHeight - WindowHeight)/2)
button #1.btn1, "Button", AnimationControl, UL 10,10,75,20
open "Animation Control" for window_nf as #1 #1, "trapclose [1.quit]"
wait
[1.quit] close #1 end
[2.quit] close #2 wait
sub AnimationControl handle$
calldll #comctl32, "InitCommonControls",_ re as void
class$ = "SysAnimate32" ACS.TRANSPARENT = 2 ACS.AUTOPLAY = 4 ACS.OPEN = 1124 ACS.PLAY = 1125 ACS.STOP = 1126
WindowWidth = 520 WindowHeight = 80 UpperLeftX = 10 UpperLeftY = 10
button #2.btnPlay, "Play", AnimationControlEventHandler, UL 15,50,50,20
open "Animation Contol Test" for dialog as #2 #2, "trapclose [2.quit]"
hwndParent = hwnd(#2) calldll #user32, "GetWindowLongA",_ hwndParent as ulong,_ _GWL_HINSTANCE as long,_ hInstance as ulong
style = _WS_CHILD or _WS_VISIBLE or ACS.AUTOPLAY or ACS.TRANSPARENT calldll #user32, "CreateWindowExA",_ 0 as long,_ class$ as ptr,_ "" as ptr,_ style as long,_ 0 as long,_ 0 as long,_ 0 as long,_ 0 as long,_ hwndParent as ulong,_ 0 as ulong,_ hInstance as ulong,_ "" as ptr,_ hwndAC as ulong
file$ = "Filecopy.avi" calldll #user32, "SendMessageA",_ hwndAC as ulong,_ ACM.OPEN as long,_ 0 as long,_ file$ as ptr,_ re as long
end sub
sub AnimationControlEventHandler handle$
buttHandle$ = word$(handle$,2,".")
select case buttHandle$ case "btnPlay" calldll #user32, "SendMessageA",_ hwndAC as ulong, ACM.PLAY as long,_ -1 as long,_ '-1=start at first frame -1 as long,_ '-1=play entire clip re as long case "btnStop" calldll #user32, "SendMessageA",_ hwndAC as ulong,_ ACM.STOP as long,_ 0 as long,_ 0 as long,_ re as long case "btnQuit" calldll #user32, "DestroyWindow",_ hwndAC as ulong,_ re as long end select end sub
|
|
|
Post by Chris Iverson on Aug 29, 2020 23:15:21 GMT -5
My guess is it's being covered up by the animation control. If you make the window bigger, and move the button further down or out, it becomes visible.
The animation control is created after the button control, so it gets drawn on top of it.
|
|
|
Post by Mark Dunham on Aug 30, 2020 7:30:21 GMT -5
My guess is it's being covered up by the animation control. If you make the window bigger, and move the button further down or out, it becomes visible. The animation control is created after the button control, so it gets drawn on top of it. I made the window 520x250 and set the button at x:150 y:400 and still cannot see the button. Thanks.
|
|
|
Post by Mark Dunham on Aug 31, 2020 21:04:56 GMT -5
My guess is it's being covered up by the animation control. If you make the window bigger, and move the button further down or out, it becomes visible. The animation control is created after the button control, so it gets drawn on top of it. Do you know if a lot of the controls have changed windows 10? It does not seem like the AVI is even loading or playing. I am sure it is something I am doing.
|
|
|
Post by Rod on Sept 1, 2020 2:21:29 GMT -5
Most if not all controls work fine in wi10. I am not sure you understood Chris’s point. It is not the size of the host window but where you place the controls. If the amimstion is at 15,15,520,80 then your button must be out with that area say 15, 100,50,20 The larger y value will drop the button below the animation.
|
|
|
Post by Brandon Parker on Sept 1, 2020 14:02:14 GMT -5
If you have the button in the area of the animation control and hover over it, you might see it flicker into the foreground. The animation control is drawing the animation over-and-over again, so you will not get the button to show up over it reliable. Maybe if you do something with the Z-Order, but that is too much of a hassle. Just take a look at avi_4.bas in Alyce's examples. This plays the AVI through the mciSendStringA function. The background is pink, but maybe Rod, our mciSendString aficionado, can figure out what to do from there ... Or maybe the AVI File has to be updated? {:0) Brandon Parker
|
|
|
Post by Mark Dunham on Sept 2, 2020 20:09:46 GMT -5
Good evening guys or good morning depending on where you are at.I have really worked hard to figure this out and I am stumped now the play button shows up like I want but the .avi does not play. If I load the same file in Alyce's example the .avi plays but in the code that I have created it does not. Can anyone explain why by all count's from what I can see it should work. My .avi file Dropbox Filecopy.aviMy Code 'Animation Control'
nomainwin
global file$ file$ = "Filecopy.avi"
calldll #comctl32, "InitCommonControls",_ re as void
class$ = "SysAnimate32" ACS.TRANSPARENT = 2 ACS.AUTOPLAY = 4 ACS.OPEN = 1124 ACS.PLAY = 1125 ACS.STOP = 1126
WindowWidth = 800 WindowHeight = 600 UpperLeftX = ((DisplayWidth - WindowWidth)/2) UpperLeftY = ((DisplayHeight - WindowHeight)/2)
button #1.btn1, "Button", AnimationControl, UL 10,10,75,20
open "Animation Control" for window_nf as #1 #1, "trapclose [1.quit]"
wait
[1.quit] close #1 end
[2.quit] close #2 wait
sub AnimationControl handle$
WindowWidth = 520 WindowHeight = 100 UpperLeftX = 10 UpperLeftY = 10
button #2.btnPlay, "Play", AnimationControlEventHandler, UL 300,25,50,20
open "Animation Contol Test" for window as #2 #2, "trapclose [2.quit]"
hwndParent = hwnd(#2)
calldll #user32, "GetWindowLongA",_ hwndParent as ulong,_ _GWL_HINSTANCE as long,_ hInstance as ulong
style = _WS_CHILD or _WS_VISIBLE or ACS.AUTOPLAY or ACS.TRANSPARENT calldll #user32, "CreateWindowExA",_ 0 as long,_ class$ as ptr,_ "" as ptr,_ style as long,_ 10 as long,_ 10 as long,_ 0 as long,_ 0 as long,_ hwndParent as ulong,_ 0 as ulong,_ hInstance as ulong,_ "" as ptr,_ hwndAC as ulong
calldll #user32, "SendMessageA",_ hwndAC as ulong,_ ACM.OPEN as long,_ 0 as long,_ file$ as ptr,_ re as long
end sub
sub AnimationControlEventHandler handle$
buttHandle$ = word$(handle$,2,".")
select case buttHandle$ case "btnPlay" calldll #user32, "SendMessageA",_ hwndAC as ulong, ACM.PLAY as long,_ -1 as long,_ '-1=start at first frame -1 as long,_ '-1=play entire clip re as long case "btnStop" calldll #user32, "SendMessageA",_ hwndAC as ulong,_ ACM.STOP as long,_ 0 as long,_ 0 as long,_ re as long case "btnQuit" calldll #user32, "DestroyWindow",_ hwndAC as ulong,_ re as long end select end sub
Ayce's Code 'Alyce Watson
'put your filename here: anifile$ = "Filecopy.avi" 'avi file name
'constants class$ = "SysAnimate32" 'class for control ACS.TRANSPARENT = 2 'transparent background - style ACS.AUTOPLAY = 4 'play as soon as opened - style ACM.OPEN = 1124 'open file - message
'initialize common controls: calldll #comctl32, "InitCommonControls",_ re as void
[WindowSetup] NoMainWin WindowWidth = 300 : WindowHeight = 100 UpperLeftX = Int((DisplayWidth-WindowWidth)/2) UpperLeftY = Int((DisplayHeight-WindowHeight)/2)
[ControlSetup] button #main.default, "Exit",[quit],UL,220,10,70,24 statictext #main.tip, "Isn't this cool?",80,20,100,130 open "Animation Control" for window as #main print #main, "trapclose [quit]"
hwndParent = hwnd(#main)
' Get window instance handle CallDLL #user32, "GetWindowLongA",_ hwndParent As ulong,_GWL_HINSTANCE As long,_ hInstance As ulong 'instance handle
' Create animation control, use autoplay flag, transparent background ' Must be a child window, and must be visible style = _WS_CHILD or _WS_VISIBLE or ACS.AUTOPLAY or ACS.TRANSPARENT
calldll #user32, "CreateWindowExA",_ 0 As long,_ ' extended style class$ as ptr,_ ' class name "" as ptr,_ ' caption = none style as long,_ ' style 10 as long,_ ' left x 10 as long,_ ' top y 0 as long,_ ' width = 0 0 as long,_ ' height = 0 hwndParent as ulong,_ ' parent hWnd 0 as ulong,_ ' handle to menu = 0 hInstance as ulong,_ ' hInstance "" as ptr,_ ' pointer to window creation data = none hwndAC as ulong ' animation control handle
'send message to open file, which will play automatically calldll #user32, "SendMessageA",_ hwndAC as ulong,_ ACM.OPEN as long,_ 0 as long,_ anifile$ as ptr,_ re as long
wait
[quit] close #main : end
|
|
|
Post by Chris Iverson on Sept 2, 2020 23:08:03 GMT -5
Multiple issues.
One - you've misnamed some of the constants, and are therefore using different names in the copy-pasted subroutines.
ACS.TRANSPARENT and ACS.AUTOPLAY are fine. They're styles for the animation control, therefore they get the prefix ACS.
ACS.OPEN, ACS.PLAY, and ACS.STOP are wrong. They're not styles; they're MESSAGES for the animation control. They get the prefix ACM. Rename these to ACM.OPEN, ACM.PLAY, and ACM.STOP.
Two - tons of scoping issues. In multiple places, you use variables in a different subroutine than they're declared. Unless you make those variables GLOBAL, or redefine that data in those subs, this will not work.
In particular, you've used all the constants(ACS.TRANSPARENT, ACS.AUTOPLAY, ACM.OPEN, ACM.PLAY, ACM.STOP), the handle to the animation control(hwndAC), and the class name of the animation class(class$) in different subroutines than they're declared. This will cause them to have 0(if numeric) or ""(if string) instead of what they should contain to work. Either make these global, or declare them in the subroutines they're used in.
Three - You've left the control with the style ACS.AUTOPLAY, meaning it will immediately start to play when the window is opened. If you want fine control of the playback time, you'll likely have to remove that style.
I should note that, when I fixed all these issues, I got the clip playing successfully in your second window.
|
|
|
Post by Mark Dunham on Sept 3, 2020 9:16:21 GMT -5
Multiple issues. One - you've misnamed some of the constants, and are therefore using different names in the copy-pasted subroutines. ACS.TRANSPARENT and ACS.AUTOPLAY are fine. They're styles for the animation control, therefore they get the prefix ACS. ACS.OPEN, ACS.PLAY, and ACS.STOP are wrong. They're not styles; they're MESSAGES for the animation control. They get the prefix ACM. Rename these to ACM.OPEN, ACM.PLAY, and ACM.STOP. Two - tons of scoping issues. In multiple places, you use variables in a different subroutine than they're declared. Unless you make those variables GLOBAL, or redefine that data in those subs, this will not work. In particular, you've used all the constants(ACS.TRANSPARENT, ACS.AUTOPLAY, ACM.OPEN, ACM.PLAY, ACM.STOP), the handle to the animation control(hwndAC), and the class name of the animation class(class$) in different subroutines than they're declared. This will cause them to have 0(if numeric) or ""(if string) instead of what they should contain to work. Either make these global, or declare them in the subroutines they're used in. Three - You've left the control with the style ACS.AUTOPLAY, meaning it will immediately start to play when the window is opened. If you want fine control of the playback time, you'll likely have to remove that style. I should note that, when I fixed all these issues, I got the clip playing successfully in your second window. Chris, first and foremost thank you for taking the time to look at this. Maybe I was too tired when I was reading I don't know but as you can see the issues are mine which I figured they were. I will spend more time reading on API's and DLL's. Once again thank you for your time.
|
|