找回密码
 加入
搜索
查看: 2933|回复: 2

[图形处理] stretchblt扩大调用不成功,求助

[复制链接]
发表于 2011-11-9 22:55:50 | 显示全部楼层 |阅读模式
本帖最后由 浪迹红客 于 2011-11-9 23:01 编辑

最近用Autoit V3写了一个窗口扩大程序,起初在笔记本上Win7系统下编写,很成功,扩大伸缩没有问题
殊不知,将它在Win XP下运行却是白屏一个,汗,控制放大区域坐标移动,有时会变成黑屏
赫赫,心都凉了 ,用api getlasterror
$er=DllCall("kernel32.dll", "int", "GetLastError")
FileWrite("t.txt",$er[0]&@CRLF)
获取错误数值,有时显示无效句柄(又或无效DC句柄),所以偶认为是否参数格式不对,或者在传递过程中发生了什么。。。或者用了stretchblt后没使用SetBrushOrgEx函数
来设置刷子的起始点,不过,Win XP下用对准吗?
总之,原因自己找不到,实在木办法,作为一名AU3并且热爱AU3的新手。。。在此恳求论坛的各位大大能够帮偶找出问题。代码:
#include <WinAPI.au3>
#include <WinAPIEx.au3>
Global $leave = 0, $2, $3, $4, $5, $orihwnd, $MyhWnd, $02, $03, $04, $05, $state = 0, $Omode
HotKeySet("{Esc}", "leave")
HotKeySet("{space}", "op")
HotKeySet("{up}", "up")
HotKeySet("{down}", "down")
HotKeySet("{right}", "right")
HotKeySet("{left}", "left")
HotKeySet("^{up}", "_up")
HotKeySet("^{down}", "_down")
HotKeySet("^{right}", "_right")
HotKeySet("^{left}", "_left")

FileInstall("info.ini", @ProgramsDir & "", 1)
If Not FileExists("info.ini") Then
        $rt = MsgBox(20, "错误", "缺少info.ini" & @CRLF & "是否重新创建?")
        If $rt = 6 Then
                FileMove(@ProgramsDir & "" & "info.ini", @ScriptDir & "", 1)
        Else
                Exit
        EndIf
EndIf
$1 = IniRead("info.ini", "Windows Text", "Default", "Working")
$2 = IniRead("info.ini", "Control Xcoord", "Default", "200")
$3 = IniRead("info.ini", "Control Ycoord", "Default", "10")
$4 = IniRead("info.ini", "Control Width", "Default", "500")
$5 = IniRead("info.ini", "Control Height", "Default", "500")
$bitmode = IniRead("info.ini", "Bit Mode", "Default", "4")
$runmode = IniRead("info.ini", "Run Mode", "Default", "1")
$Omode = IniRead("info.ini", "0 Mode", "Default", "true")
If Not WinExists($1) Then
        MsgBox(16, "错误", "设置程序未运行!")
        Exit
EndIf
If $runmode = 1 Then
        SplashTextOn("MAGNIFY TOOL", "", @DesktopWidth, @DesktopHeight, 0, 0, 1)
        $MyhWnd = WinGetHandle("MAGNIFY TOOL")
        
EndIf
$orihwnd = WinGetHandle($1)
While Not $leave
        Sleep(25)
        If $runmode = 1 Then MAG()
        If $runmode = 0 Then win()
WEnd

Func MAG()
        
        $MyHDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $MyhWnd)
        If @error Then Return
        $DeskHDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $orihwnd)
        DllCall("gdi32.dll", "int", "SetStretchBltMode", "int", $MyHDC[0], "int", $bitmode)
        ;MsgBox(0,"",@error)
        If Not @error Then
                DllCall("gdi32.dll", "int", "StretchBlt", "int", $MyHDC[0], "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, "int", $DeskHDC[0], "int", $2, "int", $3, "int", $4, "int", $5, "long", $SRCCOPY)
        EndIf
        DllCall("user32.dll", "int", "ReleaseDC", "int", $DeskHDC[0], "hwnd", 0)
        DllCall("user32.dll", "int", "ReleaseDC", "int", $MyHDC[0], "hwnd", $MyhWnd)
EndFunc   ;==>MAG

Func win()
        If $Omode = "TRUE" Then $Omode = True
        _WinAPI_MoveWindow($orihwnd, $04, $05, @DesktopWidth + $02, @DesktopHeight + $03, $Omode)
        
EndFunc   ;==>win
Func leave()
        FileDelete(@ProgramsDir & "" & "info.ini")
        
        $leave = 1
EndFunc   ;==>leave

Func up()
        $5 += 10
        
        $05 -= 10
EndFunc   ;==>up

Func down()
        $5 -= 10

        $05 += 10
EndFunc   ;==>down

Func left()
        $4 += 10

        $04 -= 10
EndFunc   ;==>left

Func right()
        $4 -= 10

        $04 += 10
EndFunc   ;==>right

Func _up()
        $3 += 10

        $03 -= 10
EndFunc   ;==>_up

Func _down()
        $3 -= 10
        
        $03 += 10
EndFunc   ;==>_down

Func _left()
        $2 += 10

        $02 -= 10
EndFunc   ;==>_left

Func _right()
        $2 -= 10
        
        $02 += 10
EndFunc   ;==>_right

Func op()
        If WinExists($MyhWnd) Then
                minormax($MyhWnd)
        Else
                minormax($orihwnd)
        EndIf
EndFunc   ;==>op

Func minormax($hnd)
        If $state = 0 Then
                _WinAPI_CloseWindow($hnd)
                $state = 1
        Else
                _WinAPI_OpenIcon($hnd)
                $state = 0
        EndIf
EndFunc   ;==>minormax
ini文件:
[Windows Text]      //将扩大窗口标题,若标题栏没有标题,可用SPY++或其他获取
Default=Working     
[Control Xcoord]    //将扩大窗口区域的X坐标,其相对于主窗口左上角,可用SPY++或其他获取
Default=143         
[Control Ycoord]    //将扩大窗口区域的Y坐标,其相对于主窗口左上角,可用SPY++或其他获取
Default=48          
[Control Width]     //将扩大窗口区域的宽度,可用SPY++或其他获取,其单位为像素
Default=650         
[Control Height]    //将扩大窗口区域的高度,可用SPY++或其他获取,其单位为像素
Default=478         
[Bit Mode]          //ENGLISH MAGNIFY窗口中位图拉伸模式,默认为4(可增大扩大时的清晰度)
Default=4           
[Run Mode]          //ENGLISH MAGNIFY有两种运行模式,0:直接接窗口(或客户区)扩大,但效果不理想;1:取区域后间接扩大
Default=1           
[0 Mde]             //O模式下确定窗口是否被刷新,TRUE:窗口接收一个WM_PAINT消息;FALSE:不发生任何刷新动作
Default=TRUE 
 楼主| 发表于 2011-11-9 22:56:50 | 显示全部楼层
自己先顶一下
 楼主| 发表于 2011-11-10 19:59:00 | 显示全部楼层
帮顶啊。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-5 08:19 , Processed in 0.083991 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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