求-从dll直接引用BMP文件以实现水波纹特效
用以下方法已经可以实现从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, "str", $sBitmap)
If @error Then Return SetError(@error, 0, -1)
DllCall("user32.dll", "lparam", "SendMessage", "hwnd", GUICtrlGetHandle($hwnd), "int", 0x0172, "wparam", 0, "lparam", $LoadBitmap)
If @error Then Return SetError(@error, @extended, "")
DllCall("Kernel32.dll", "hwnd", "FreeLibrary", "hwnd", $LoadLibraryA)
Return 1
EndFunc ;==>_SetBitmap
本帖最后由 touch_xu 于 2014-9-23 14:46 编辑
不好意思,是求完全组合,谢谢! 本帖最后由 touch_xu 于 2014-9-24 18:29 编辑
这个要顶起来.这个居然没有人看,真是奇怪了. 完美结合,谢谢楼主提供
zxxpt9 发表于 2014-9-28 07:33 http://61.153.183.105/images/common/back.gif
不好意思,我是求助,当然谢谢帮顶,谢谢! 说实话,非常好的帖子,但是毕竟本人小白一点,还是没搞清楚,是否能详细一下 合并后,一直提示,怎么回事
error: _SetBitmap() already defined 楼主问题解决了么,我的回复是不是来的晚点了。。。
#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
$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 = DllOpen($sDll_Filename)
If $___sDll___Filename = -1 Then Return SetError(3, 0, '')
$___sDll___Filename = $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, "str", $BitMapName)
If @error Then Return SetError(@error, 0, -1)
$___sDll___Filename = $LoadBitmap
DllCall($___sDll___Filename, 'bool', 'enablewater', 'HWND', $hWnd, 'int', $Left, 'int', $Top, 'HWND', $___sDll___Filename, 'int', $WaterRadius, 'int', $WaterHeight)
$pos = StringSplit($start, ',;|')
If Not @error And $pos >= 2 Then
$_pos = $pos
$_pos = $pos
If $pos = 2 Then
$_pos = 10
$_pos = 500
ElseIf $pos = 3 Then
$_pos = $pos
$_pos = 500
ElseIf $pos = 4 Then
$_pos = $pos
$_pos = $pos
EndIf
DllCall($___sDll___Filename, 'bool', 'waterblob', 'int', $_pos, 'int', $_pos, 'int', $_pos, 'int', $_pos)
EndIf
Local $csize = ControlGetPos($hWnd, '', '#327701')
Local $wsize = WinGetPos($hWnd)
$___sDll___Filename = $csize
If $wsize < $csize Then $___sDll___Filename = $wsize
$___sDll___Filename = $csize
If $wsize < $csize Then $___sDll___Filename = $wsize
Return $___sDll___Filename
EndFunc ;==>_WaterCtrl_StartupFromRes
haijie1223 发表于 2021-10-23 09:34
楼主问题解决了么,我的回复是不是来的晚点了。。。
有用,从xp到win11都有水纹效果
PS:编译之后再试效果
附带一个waterctrl.dll.au3 传送门
页:
[1]