找回密码
 加入
搜索
查看: 3747|回复: 4

[GUI管理] 如何使flash大小随着窗口大小改变

  [复制链接]
发表于 2012-4-17 16:46:50 | 显示全部楼层 |阅读模式
如题
目前flash只能是创建时候的大小
问题1:最大化无法改变
问题2:如何鼠标拖动窗口时候,随之改变
请教各位高人,初学不太懂,搜索无果。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>
#include <ToolbarConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Button1 = GUICtrlCreateButton("Button1", 0, 32, 89, 65)
$Button2 = GUICtrlCreateButton("Button2", 0, 112, 89, 65)
$Button3 = GUICtrlCreateButton("Button3", 0, 200, 89, 65)
$Button4 = GUICtrlCreateButton("Button4", 0, 296, 89, 65)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
;~                         MsgBox(0,"","1")
                        creat()
                Case $Button2
                        creat()
                Case $Button3
                        MsgBox(0, "", "3")
                Case $Button4
                        MsgBox(0, "", "4")
        EndSwitch
WEnd

Func creat()
        $Form2 = GUICreate('Flash播放器', 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW)
;~         GUISetBkColor(0x000000)        ;背景黑
;~         Local $aPos = WinGetPos($Form2)
        Local $aPos = WinGetClientSize($Form2)
        Local $Obj = ObjCreate('ShockwaveFlash.ShockwaveFlash.9')
        If @error Then Exit
        $GUIActiveX = GUICtrlCreateObj($Obj,0,0,$aPos[0] ,$aPos[1])
;~         GUISetStyle($GUIActiveX,$WS_OVERLAPPEDWINDOW)
        GUICtrlSetResizing($obj,$GUI_DOCKAUTO)
;~         MsgBox(0,"","x:"&$aPos[0]&"y:"&$aPos[1])
        GUISetState()
        $Obj.Movie = @ScriptDir & '\吃豆游戏.swf'
        $Obj.ScaleMode = 0
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                GUISetState(@SW_ENABLE, $Form2)
                                GUIDelete($Form2)
                                ExitLoop
                        Case $GUI_EVENT_MAXIMIZE
                                GUICtrlSetPos($obj,0,0,1024,768)        ;最大化这里不起作用
                                MsgBox(0,"","00")
                EndSwitch
        WEnd
EndFunc   ;==>creat

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-4-17 19:31:35 | 显示全部楼层
GUICtrlSetResizing是针对控件的, 在你的代码中$Obj不属于控件吧,$GUIActiveX是一个ActiveX 控件.
换个思路吧:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>
#include <ToolbarConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIEx.au3>
Global $Form2, $GUIActiveX, $obj
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Button1 = GUICtrlCreateButton("Button1", 0, 32, 89, 65)
$Button2 = GUICtrlCreateButton("Button2", 0, 112, 89, 65)
$Button3 = GUICtrlCreateButton("Button3", 0, 200, 89, 65)
$Button4 = GUICtrlCreateButton("Button4", 0, 296, 89, 65)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
;~                         MsgBox(0,"","1")
                        creat()
                Case $Button2
                        creat()
                Case $Button3
                        MsgBox(0, "", "3")
                Case $Button4
                        MsgBox(0, "", "4")
        EndSwitch
WEnd

Func creat()
        $Form2 = GUICreate('Flash播放器', 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW)
        $obj = ObjCreate('ShockwaveFlash.ShockwaveFlash.9')
        If @error Then Exit
        $GUIActiveX = GUICtrlCreateObj($obj, 300, 200, -1, -1)
        $obj.Movie = @ScriptDir & '\shuizhu.swf'
        $obj.ScaleMode = 0
        GUISetState()
        resize()
        GUIRegisterMsg($WM_SIZE, "resize")
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                GUISetState(@SW_ENABLE, $Form2)
                                GUIDelete($Form2)
                                ExitLoop
                        Case $GUI_EVENT_MAXIMIZE
                                GUICtrlSetPos($obj, 0, 0, 1024, 768) ;最大化这里不起作用
                                MsgBox(0, "", "00")
                EndSwitch
        WEnd
EndFunc   ;==>creat

Func resize()
        Local $aPos = WinGetPos($Form2)
        GUICtrlDelete($GUIActiveX)
        $obj = ObjCreate('ShockwaveFlash.ShockwaveFlash.9')
        If @error Then Exit
        $GUIActiveX = GUICtrlCreateObj($obj, 0, 0, $aPos[2], $aPos[3])
        $obj.Movie = @ScriptDir & '\shuizhu.swf'
        $obj.ScaleMode = 0
EndFunc   ;==>resize

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2012-4-17 22:51:07 | 显示全部楼层
回复 2# haijie1223


    谢谢阿杰仔细的回答,但和我想象的还有点差距,现在是窗口改变同时又重新创建了一个obj,我想在原来运行基础上变。比如,正在运行flash中,不打断,能够变化。
发表于 2012-4-18 09:40:12 | 显示全部楼层
顶一下,表示关注
发表于 2012-4-18 10:13:20 | 显示全部楼层
不过感觉不是很理想。主要是不能完全显示
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 22:51 , Processed in 0.085805 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表