找回密码
 加入
搜索
查看: 6287|回复: 7

[AU3基础] 给输入框(Input)设上背景图片的问题,各位老师进来看

  [复制链接]
发表于 2011-10-17 12:00:31 | 显示全部楼层 |阅读模式
请问各位老师,是否可以给GUICtrlCreateInput设上背景图片啊,
我用了GUICtrlSetImage(),不行啊
又用了GUICtrlCreatePic(),一开始是可以了,但是当Input处于焦点时,背景图片又没在了
请各位老师给予指导……
发表于 2011-10-17 13:35:18 | 显示全部楼层
发表于 2011-10-17 13:40:06 | 显示全部楼层
楼上正解,效果非常好
 楼主| 发表于 2011-10-17 14:55:36 | 显示全部楼层
面具人老师的代码有问题,脚本运行起来时倒是可以在框中输入,
如果输入框失去焦点后再次获得焦点时,输入框已经不能用了……
发表于 2011-10-17 22:41:55 | 显示全部楼层
回复 4# kood481748
Vista或WIN7下,开启AERO试用.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPIex.au3>
#include <sendmessage.au3>
#include <GuiEdit.au3>
#Include <Date.au3>
#include <GDIPlus.au3>

HotKeySet("ESC", "_Exit")
If Not _WinAPI_DwmIsCompositionEnabled() Then
        MsgBox(16, 'Error', '桌面窗口管理(DWM)不可用'&@CRLF&'退出示例!')
        Exit
EndIf
$alpha=_WinAPI_DwmGetColorizationColor( )
$CtrlBkColor="0X"&Hex(BitAND($alpha,0xFFFFFF),6)
$alpha="0X"&Hex($alpha)
Global $Jpg = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Examples\GUI\msoobe.jpg'

_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile($Jpg)
$hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
$hHBITMAP = _WinAPI_CreateBitmap(430, 252, 1, 32)
$hCDC = _WinAPI_CreateCompatibleDC(0)
_WinAPI_SelectObject($hCDC, $hHBITMAP)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, 430, 252)
$hFontFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFontFamily, 24)
$hBrush = _GDIPlus_BrushCreateSolid(0xffFFc0c0)
 $tLayout = _GDIPlus_RectFCreate(30, 200)
 _GDIPlus_GraphicsDrawStringEx($hGraphic, "This is a Font", $hFont, $tLayout, 0, $hBrush)
_WinAPI_DeleteObject($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteDC($hCDC)

$form1 = GUICreate("abc", 430, 252, -1, -1, -1, $WS_EX_LAYERED);_GDIPlus_ImageGetWidth($hImage1), _GDIPlus_ImageGetHeight($hImage1), -1, -1, $WS_POPUP, $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($form1, $hHBITMAP, 200,1)
_GDIPlus_ImageDispose($hImage1)
_WinAPI_DeleteObject($hBitmap1)
_GDIPlus_Shutdown()

GUISetState()

$pos1=WinGetPos($form1,"")
$hGUI = GUICreate("Test", 430, 180, $pos1[0]+5, $pos1[1]+30, 0x80000000, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, 0x02000000),$form1)
local $lable = GUICtrlCreateLabel("", 2, 2, 250, 25)
GUICtrlSetFont(-1, 12, 800, 1, '微软雅黑',3)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1,-2)
$Edit1 = GUICtrlCreateEdit("这里输入", 2, 25, 400, 148, $ES_AUTOVSCROLL + $ES_MULTILINE + $ES_WANTRETURN)
GUICtrlSetBkColor(-1, $CtrlBkColor)
GUICtrlSetFont(-1, 24, 800, 1, '微软雅黑',3)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState()
GUISetBkColor($CtrlBkColor)
_WinAPI_SetLayeredWindowAttributes($hGUI, $alpha, 255,True)

GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUIRegisterMsg($WM_SIZE, "WM_MOVE")

While 1
        $nt = _NowCalc()
        If $nt <> GUICtrlRead($lable) Then GUICtrlSetData($lable, $nt)
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func _Exit()
        Exit
EndFunc   ;==>_Exit

Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)        
        $XY2 = WinGetPos($Form1)
        WinMove($hGUI, "", $XY2[0]+5, $XY2[1]+30)
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
        Switch $hWnd
                Case $form1
                        Switch $iMsg
                                Case $WM_NCHITTEST
                                                Return $HTCAPTION
                                
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST
 楼主| 发表于 2011-10-19 01:32:41 | 显示全部楼层
回复 5# 3mile


我没用win7系统,我一直用的都是XP,请问我说的这个问题能不能解决啊?
发表于 2011-10-19 08:43:57 | 显示全部楼层
XP下的,修改了下3笑的代码,把多余的去掉了
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPIex.au3>
#include <sendmessage.au3>
#include <GuiEdit.au3>
#Include <Date.au3>
#include <GDIPlus.au3>
 
HotKeySet("ESC", "_Exit")
Global $alpha=0x010101
Global $CtrlBkColor=$alpha
Global $Jpg = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Examples\GUI\msoobe.jpg'
 
_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile($Jpg)
;$hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
;$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
$hHBITMAP = _WinAPI_CreateBitmap(430, 252, 1, 32)
$hCDC = _WinAPI_CreateCompatibleDC(0)
_WinAPI_SelectObject($hCDC, $hHBITMAP)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage1, 0, 0, 430, 252)
$hFontFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFontFamily, 24)
$hBrush = _GDIPlus_BrushCreateSolid(0xffFFc0c0)
 $tLayout = _GDIPlus_RectFCreate(30, 200)
 _GDIPlus_GraphicsDrawStringEx($hGraphic, "This is a Font", $hFont, $tLayout, 0, $hBrush)
;_WinAPI_DeleteObject($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteDC($hCDC)
 
$form1 = GUICreate("abc", 430, 252, -1, -1, -1, $WS_EX_LAYERED);_GDIPlus_ImageGetWidth($hImage1), _GDIPlus_ImageGetHeight($hImage1), -1, -1, $WS_POPUP, $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($form1, $hHBITMAP, 200,1)
_GDIPlus_ImageDispose($hImage1)
;_WinAPI_DeleteObject($hBitmap1)
_GDIPlus_Shutdown()
 
GUISetState()
 
$pos1=WinGetPos($form1,"")
;$hGUI = GUICreate("Test", 430, 180, $pos1[0]+5, $pos1[1]+30, 0x80000000, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, 0x02000000),$form1)
$hGUI = GUICreate("Test", 430, 180, $pos1[0]+5, $pos1[1]+30, 0x80000000, BitOR($WS_EX_LAYERED, 0x02000000),$form1)
local $lable = GUICtrlCreateLabel("", 2, 2, 250, 25)
GUICtrlSetFont(-1, 12, 800, 1, '微软雅黑',3)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1,-2)
$Edit1 = GUICtrlCreateEdit("这里输入", 2, 25, 400, 148, $ES_AUTOVSCROLL + $ES_MULTILINE + $ES_WANTRETURN)
GUICtrlSetBkColor(-1, $CtrlBkColor)
GUICtrlSetFont(-1, 24, 800, 1, '微软雅黑',3)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState()
GUISetBkColor($CtrlBkColor)
_WinAPI_SetLayeredWindowAttributes($hGUI, $alpha, 255,True)
 
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUIRegisterMsg($WM_SIZE, "WM_MOVE")
 
While 1
        $nt = _NowCalc()
        If $nt <> GUICtrlRead($lable) Then GUICtrlSetData($lable, $nt)
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
 
Func _Exit()
        Exit
EndFunc   ;==>_Exit
 
Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)        
        $XY2 = WinGetPos($Form1)
        WinMove($hGUI, "", $XY2[0]+5, $XY2[1]+30)
EndFunc
 
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
        Switch $hWnd
                Case $form1
                        Switch $iMsg
                                Case $WM_NCHITTEST
                                                Return $HTCAPTION
                                
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST
发表于 2011-10-19 09:30:09 | 显示全部楼层
收藏,备用。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-22 05:15 , Processed in 0.080410 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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