找回密码
 加入
搜索
查看: 5142|回复: 8

[AU3基础] 求-从dll直接引用BMP文件以实现水波纹特效

[复制链接]
发表于 2014-9-23 14:13:01 | 显示全部楼层 |阅读模式
用以下方法已经可以实现从DLL引用BMP文件实现图片控件了,那么大虾们如何一步到位实现,从DLL直接到水波纹效果呢?





从DLL引用位图资源的方法:http://www.autoitx.com/forum.php ... hlight=dll%2B%CD%BC

Afan 的水波纹 https://autoitx.com/thread-17705-1-1.html
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>;Get $Pos
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <waterctrl.dll.au3>


$Form1 = GUICreate("DEMO", 397, 260, -1, -1)

;_WaterCtrl_Startup(@TempDir & "\BG.bmp", $Form1, '70,27') ;这里想实现直接从DLL里引用图片,请问如何实现呢?
$bgconfirm = GUICtrlCreatePic("", 0, 0, 397,90)
_SetBitmap('sys.dll', "BG", $bgconfirm)

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd


;~ By Crossdoor
;~ 从DLL文件中加载图片到图片控件
;~ _SetBitmap(DLL名称, 图片编号, 控件句柄)
;~ 成功返回1
;~ 示例:
;~ $pic = GUICtrlCreatePic("", 0, 0, 640, 480, 0x04000000)
;~ _SetBitmap('Res.dll', '#143', $pic)
Func _SetBitmap($sDll, $sBitmap, $hwnd)
        $LoadLibraryA = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $sDll)
        If @error Then Return SetError(@error, 0, 0)
        $LoadBitmap = DllCall("User32.dll", "hwnd", "LoadBitmap", "hwnd", $LoadLibraryA[0], "str", $sBitmap)
        If @error Then Return SetError(@error, 0, -1)
        DllCall("user32.dll", "lparam", "SendMessage", "hwnd", GUICtrlGetHandle($hwnd), "int", 0x0172, "wparam", 0, "lparam", $LoadBitmap[0])
        If @error Then Return SetError(@error, @extended, "")
        DllCall("Kernel32.dll", "hwnd", "FreeLibrary", "hwnd", $LoadLibraryA[0])
        Return 1
EndFunc   ;==>_SetBitmap

本帖子中包含更多资源

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

×
 楼主| 发表于 2014-9-23 14:13:39 | 显示全部楼层
本帖最后由 touch_xu 于 2014-9-23 14:46 编辑

不好意思,是求完全组合,谢谢!
 楼主| 发表于 2014-9-23 22:42:41 | 显示全部楼层
本帖最后由 touch_xu 于 2014-9-24 18:29 编辑

这个要顶起来.这个居然没有人看,真是奇怪了.
 楼主| 发表于 2014-9-29 16:19:48 | 显示全部楼层
完美结合,谢谢楼主提供
zxxpt9 发表于 2014-9-28 07:33



   不好意思,我是求助,当然谢谢帮顶,谢谢!
发表于 2021-10-23 03:12:06 | 显示全部楼层
说实话,非常好的帖子,但是毕竟本人小白一点,还是没搞清楚,是否能详细一下
发表于 2021-10-23 04:24:50 | 显示全部楼层
合并后,一直提示,怎么回事
error: _SetBitmap() already defined
发表于 2021-10-23 09:34:30 | 显示全部楼层
楼主问题解决了么,我的回复是不是来的晚点了。。。
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseX64=n
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <waterctrl.dll.au3>
$Form1 = GUICreate("DEMO", 397, 260, -1, -1)
$bgconfirm = GUICtrlCreatePic("", 0, 0, 397, 90)
_WaterCtrl_StartupFromRes('sys.dll', "BG", $Form1, '70,27');'这里想实现直接从DLL里引用图片,请问如何实现呢?
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
Func _WaterCtrl_StartupFromRes($DllName, $BitMapName, $hWnd, $start = '', $WaterRadius = 3, $WaterHeight = 50, $Left = 0, $Top = 0)
        If Not IsHWnd($hWnd) Then Return SetError(2, 0, '')
        Local $code, $sDll_Filename, $hFileDllOut, $bmp_pic, $pos, $_pos[5]
        $code = CtrlCode()
        Do
                $sDll_Filename = ''
                While StringLen($sDll_Filename) < 7
                        $sDll_Filename = $sDll_Filename & Chr(Random(97, 122, 1))
                WEnd
                $sDll_Filename = @TempDir & '\~' & $sDll_Filename & '.tmp'
        Until Not FileExists($sDll_Filename)
        $hFileDllOut = FileOpen($sDll_Filename, 2)
        FileWrite($hFileDllOut, $code)
        FileClose($hFileDllOut)
        FileSetTime($sDll_Filename, '20100725164800', 0)
        $___sDll___Filename[0] = DllOpen($sDll_Filename)
        If $___sDll___Filename[0] = -1 Then Return SetError(3, 0, '')
        $___sDll___Filename[1] = $sDll_Filename
        Local $LoadLibraryA = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $DllName)
        If @error Then Return SetError(@error, 0, 0)
        Local $LoadBitmap = DllCall("User32.dll", "hwnd", "LoadBitmap", "hwnd", $LoadLibraryA[0], "str", $BitMapName)
        If @error Then Return SetError(@error, 0, -1)
        $___sDll___Filename[2] = $LoadBitmap[0]
        
        DllCall($___sDll___Filename[0], 'bool', 'enablewater', 'HWND', $hWnd, 'int', $Left, 'int', $Top, 'HWND', $___sDll___Filename[2], 'int', $WaterRadius, 'int', $WaterHeight)
        $pos = StringSplit($start, ',;|')
        If Not @error And $pos[0] >= 2 Then
                $_pos[1] = $pos[1]
                $_pos[2] = $pos[2]
                If $pos[0] = 2 Then
                        $_pos[3] = 10
                        $_pos[4] = 500
                ElseIf $pos[0] = 3 Then
                        $_pos[3] = $pos[3]
                        $_pos[4] = 500
                ElseIf $pos[0] = 4 Then
                        $_pos[3] = $pos[3]
                        $_pos[4] = $pos[4]
                EndIf
                DllCall($___sDll___Filename[0], 'bool', 'waterblob', 'int', $_pos[1], 'int', $_pos[2], 'int', $_pos[3], 'int', $_pos[4])
        EndIf
        Local $csize = ControlGetPos($hWnd, '', '#327701')
        Local $wsize = WinGetPos($hWnd)
        $___sDll___Filename[3] = $csize[2]
        If $wsize[2] < $csize[2] Then $___sDll___Filename[3] = $wsize[2]
        $___sDll___Filename[4] = $csize[3]
        If $wsize[3] < $csize[3] Then $___sDll___Filename[4] = $wsize[3]
        Return $___sDll___Filename
EndFunc   ;==>_WaterCtrl_StartupFromRes
发表于 2021-10-23 11:03:47 | 显示全部楼层
haijie1223 发表于 2021-10-23 09:34
楼主问题解决了么,我的回复是不是来的晚点了。。。

有用,从xp到win11都有水纹效果
PS:编译之后再试效果

附带一个waterctrl.dll.au3 传送门
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-23 23:37 , Processed in 0.114153 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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