找回密码
 加入
搜索
楼主: xiezhang6263

[系统综合] 按钮添加从ini文件读取坐标以及数据的问题

 火.. [复制链接]
发表于 2011-7-20 13:27:53 | 显示全部楼层
13楼脚本还是实现不了效果。见附图。
我先检测一下我的系统和AU3环境看看。

本帖子中包含更多资源

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

×
发表于 2011-7-20 13:29:26 | 显示全部楼层
不知道倒是什么原因哦
 楼主| 发表于 2011-7-20 20:28:02 | 显示全部楼层
回复 13# 3mile

厉害呀,再加上个自动获取坐标的按钮上去就很完美了。
发表于 2011-7-20 23:53:10 | 显示全部楼层
回复 18# xiezhang6263
你说的是这个意思?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)

$pic = @ScriptDir & "\map.jpg"
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($pic)
$iY = _GDIPlus_ImageGetHeight($hImage)
$iX = _GDIPlus_ImageGetWidth($hImage)
_GDIPlus_Shutdown()

$ini = IniReadSectionNames("map.ini")
Local $Label[$ini[0]]

$gui = GUICreate("My GUI picture", $iX, $iY, -1, -1, $WS_POPUP + $WS_SYSMENU)
GUISetOnEvent(-3, "_exit")

$n = GUICtrlCreatePic("2.jpg", 0, 0, $iX, $iY)
GUICtrlSetState(-1, $gui_disable)
For $i = 1 To $ini[0]
        $ini_set = IniReadSection("map.ini", $ini[$i])
        $temp = StringSplit($ini_set[1][1], ",", 3)
        $Label[$i - 1] = GUICtrlCreateLabel("", $temp[0], $temp[1], $temp[2], $temp[3])
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetTip(-1, $ini[$i])
        GUICtrlSetOnEvent(-1, "_Click")
Next

Global Const $idPic = GUICtrlCreatePic("", 0, 0, 120, 200)
_GDIPlus_Startup()
Global $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", 120, "int", 200, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
$hBitmap = $hBitmap[6]
Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hContext, "int", 4)
_GDIPlus_GraphicsClear($hContext, "0xFF" & 0xFFFFFF)


GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUISetState()

; Run the GUI until the dialog is closed
While 1
        Sleep(100)
WEnd

Func _exit()
        _GDIPlus_BitmapDispose($hBitmap)
        _GDIPlus_GraphicsDispose($hContext)
        _GDIPlus_Shutdown()
        Exit
EndFunc   ;==>_exit

Func _Click()
        MsgBox(0, $ini[@GUI_CtrlId - 3], IniRead("map.ini", $ini[@GUI_CtrlId - 3], "str", "ok"))
EndFunc   ;==>_Click

Func WM_MOUSEMOVE($hWndGUI, $MsgID, $wParam, $lParam)
        Local $x = BitAND($lParam, 0xFFFF)
        Local $y = BitShift($lParam, 16)
        _GDIPlus_GraphicsDrawString($hContext, "X="&$x & @CRLF &"Y="& $y, 0, 0, "Arial", 12)
        Local $hHBITAMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $hHBITAMP))
        _WinAPI_DeleteObject($hHBITAMP)
        _GDIPlus_GraphicsClear($hContext, "0xFFFFFFFF")
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE
 楼主| 发表于 2011-7-21 00:41:30 | 显示全部楼层
本帖最后由 xiezhang6263 于 2011-7-21 00:43 编辑

回复 19# 3mile
坐标我已经可以解决了,现在的问题是我要是在地图上面加多个flash效果或者是多张图片,然后点击上面的图片或者flash就可以显示这个ini里面对应的内容就更加棒了。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GuiMenu.au3>;窗体移动
 
Opt("GUIOnEventMode",1)
 
$pic = @ScriptDir & "\2.jpg"
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($pic)
$iY = _GDIPlus_ImageGetHeight($hImage)
$iX = _GDIPlus_ImageGetWidth($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
 
$ini=IniReadSectionNames("map.ini")
Local $Label[$ini[0]]

;GUICreate("My GUI picture", $iX, $iY , -1, -1, $WS_POPUP + $WS_SYSMENU) 
$Form1 = GUICreate("分布图", $iX, $iY , -1, -1) 
GUISetOnEvent(-3,"_exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SendMsg") ;窗体移动
$n = GUICtrlCreatePic("2.jpg", 0, 0, $iX , $iY )
GUICtrlSetState(-1,$gui_disable)
For $i=1 to $ini[0]
        $ini_set=IniReadSection("map.ini",$ini[$i])
        $temp=StringSplit($ini_set[1][1],",",3)
        $Label[$i-1]=GUICtrlCreateLabel("",$temp[0],$temp[1],$temp[2],$temp[3])
        GUICtrlSetBkColor(-1,-2)
        GUICtrlSetTip(-1,$ini[$i])
        GUICtrlSetOnEvent(-1,"_Click")
Next

$Label3 = GUICtrlCreateLabel("", 650, 10, 250, 20)
$Button = GUICtrlCreateButton("查询", 50, 625, 100, 30, 0)
GUISetState()
AdlibRegister("Pos")

 
; Run the GUI until the dialog is closed
While 1
        Sleep(100)
WEnd
 
Func _exit()
        Exit
EndFunc
 
Func _Click()
                msgbox(0,$ini[@GUI_CtrlId-3],IniRead("map.ini",$ini[@GUI_CtrlId-3],"str","ok"))
EndFunc
                        
Func Pos()
        Opt("MouseCoordMode", 2)
    $Pos = MouseGetPos()
    GUICtrlSetData($Label3, "坐标点  X:" & $Pos[0] & "  Y:" & $Pos[1])
EndFunc

Func _SendMsg();窗体移动
        _SendMessage($Form1, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
EndFunc
        
在从ini文件里面筛选,地图上加个查询按钮地图上根据时间显示出查询条件里面的条件,完美。。
发表于 2011-7-22 13:35:24 | 显示全部楼层
回复 20# xiezhang6263
你想要的功能都可以实现.
先上你的代码吧
发表于 2011-7-22 18:12:50 | 显示全部楼层
好象看到过论坛上有跟FLASH交互的例子,至于数据存储的话,如果量可能选择小型数据库比较好吧!
发表于 2011-7-23 00:11:40 | 显示全部楼层
 楼主| 发表于 2011-7-24 00:29:44 | 显示全部楼层
回复 21# 3mile


    查看了论坛里的资料找不到思路,3mile能否给点思路我参考下然后在把完善的贴出来。
现在的问题是外部加载图片或者flash无法实现,还有从ini文件里面按时间筛选查询也没办法实现。
希望3mile给点思路,谢谢了。
 楼主| 发表于 2011-7-25 20:26:02 | 显示全部楼层
回复 19# 3mile


    查看了论坛里的资料找不到思路,3mile能否给点思路我参考下然后在把完善的贴出来。
现在的问题是外部加载图片或者flash无法实现,还有从ini文件里面按时间筛选查询也没办法实现。
希望3mile给点思路,谢谢了。
发表于 2011-7-25 22:05:00 | 显示全部楼层
回复 25# xiezhang6263
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlusEx.au3>
#include <Array.au3>
#include <icons.au3>

Opt("GUIOnEventMode", 1)
Global Const $SC_DRAGMOVE = 0xF012
Global $hImage, $hGraphics, $backbuffer, $ffamily, $arial, $sformat, $rectf, $arr, $blackbrush, $iX, $iY
Global $ini, $start = 0, $flag = 0
$pic = @ScriptDir & "\map.jpg"
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($pic)
$iY = _GDIPlus_ImageGetHeight($hImage)
$iX = _GDIPlus_ImageGetWidth($hImage)


$ini = IniReadSectionNames("map.ini")
Global $Point[$ini[0]][4]
Local $Label[$ini[0]], $icon[$ini[0]]
Global $k = 1
Global $png[3] = ["a.png", "b.png", "c.png"]

$gui = GUICreate("My GUI picture", $iX, $iY, -1, -1, $WS_POPUP + $WS_SYSMENU)
GUISetOnEvent(-3, "_exit")
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($gui)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($hImage)
$ffamily = _GDIPlus_FontFamilyCreate("微软雅黑")
$arial = _GDIPlus_FontCreate($ffamily, 25, 1)
$sformat = _GDIPlus_StringFormatCreate();创建字符串格式对象,0x1000禁止该文本换行到下一行

$rectf = _GDIPlus_RectFCreate(0);创建 $tagGDIPRECTF 结构,左上宽高
$arr = _GDIPlus_GraphicsMeasureString($backbuffer, "3mile制作", $arial, $rectf, $sformat);测量字符串尺寸

DllStructSetData($arr[0], 1, $iX - DllStructGetData($arr[0], 3))
DllStructSetData($arr[0], 2, $iY - DllStructGetData($arr[0], 4))
$blackbrush = _GDIPlus_LineBrushCreateFromRect($arr[0], 0xFFFFFF00, 0xFFFF0000, 1)
_GDIPlus_GraphicsDrawStringEx($backbuffer, "3mile制作", $arial, $arr[0], $sformat, $blackbrush)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iX, $iY);copy bitmap to GUI

For $i = 1 To $ini[0]
        $ini_set = IniReadSection("map.ini", $ini[$i])
        $temp = StringSplit($ini_set[1][1], ",", 3)
        $icon[$i - 1] = GUICtrlCreatepic('', $temp[0], $temp[1] ,32, 32)
;~         SetBitmap(GUICtrlGetHandle($icon[$i-1]),"a.png",1)
        GUICtrlSetState($icon[$i-1],$gui_disable)
        
        $hBitmap = _Icons_Bitmap_Load("a.png")
        $hArea = _Icons_Bitmap_Resize($hBitmap, 32,32)
            _SetHImage($icon[$i-1], $hArea)
            _WinAPI_DeleteObject($hBitmap)
            _WinAPI_DeleteObject($hArea)
                        
;~         _SetImage($icon[$i-1],"a.png")
        $Point[$i - 1][0] = $temp[0]
        $Point[$i - 1][1] = $temp[1]
        $Point[$i - 1][2] = $temp[0] + $temp[2]
        $Point[$i - 1][3] = $temp[1] + $temp[3]
Next

;~ AdlibRegister("Set_Icon",1000)

Global Const $idPic = GUICtrlCreatePic("", $iX - 85, 10, 85, 60)
Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(85, 60,$GDIP_PXF32ARGB);DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", 120, "int", 200, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
Global Const $hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00)
Global Const $hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("DS-Digital")
Global Const $hFont = _GDIPlus_FontCreate($hFamily, 16, 0)
Global Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)

_GDIPlus_GraphicsSetTextRenderingHint($hContext, 4)
_GDIPlus_GraphicsClear($hContext, "0xFFFFFFFF")



GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUIRegisterMsg($WM_LBUTTONUP, "_WM_LBUTTONUP")
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUIRegisterMsg(0x0014, "WM_ERASEBKGND")
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState()

; Run the GUI until the dialog is closed
While 1
        Sleep(100)
WEnd

Func _exit()
        _GDIPlus_BrushDispose($blackbrush)
        _GDIPlus_StringFormatDispose($sformat)
        _GDIPlus_FontDispose($arial)
        _GDIPlus_FontFamilyDispose($ffamily)
        _GDIPlus_GraphicsDispose($backbuffer)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_BitmapDispose($hBitmap)
        _GDIPlus_GraphicsDispose($hContext)
        _GDIPlus_Shutdown()
        Exit
EndFunc   ;==>_exit

;~ Func _Click()
;~         MsgBox(0, $ini[@GUI_CtrlId - 3], IniRead("map.ini", $ini[@GUI_CtrlId - 3], "str", "ok"))
;~ EndFunc   ;==>_Click

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
        _GDIPlus_GraphicsDrawStringEx($backbuffer, "3mile制作", $arial, $arr[0], $sformat, $blackbrush)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iX, $iY);copy bitmap to GUI
        Return True
EndFunc   ;==>WM_ERASEBKGND

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
        Local $x = BitAND($lParam, 0xFFFF)
        Local $y = BitShift($lParam, 16)
        For $i = 0 To UBound($Point) - 1
                If _WinAPI_PtInRectEx($x, $y, $Point[$i][0], $Point[$i][1], $Point[$i][2], $Point[$i][3]) And $start = 0 Then
;~                         msgbox(0,0,IniRead("map.ini",$ini[$i+1],"str","error"))
                        $start = 1
                        Return
                EndIf
        Next
        _SendMessage($gui, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Func _WM_LBUTTONUP($hWnd, $Msg, $wParam, $lParam)
        Local $x = BitAND($lParam, 0xFFFF)
        Local $y = BitShift($lParam, 16)
        For $i = 0 To UBound($Point) - 1
                If _WinAPI_PtInRectEx($x, $y, $Point[$i][0], $Point[$i][1], $Point[$i][2], $Point[$i][3]) And $start = 1 Then
                        MsgBox(0, 0, IniRead("map.ini", $ini[$i + 1], "str", "error"))
                        $start = 0
                        Return
                EndIf
        Next
EndFunc   ;==>_WM_LBUTTONUP

Func WM_MOUSEMOVE($hWndGUI, $MsgID, $wParam, $lParam)
        Local $XX, $YY
        Local $x = BitAND($lParam, 0xFFFF)
        Local $y = BitShift($lParam, 16)
        Local $mes = _GDIPlus_GraphicsMeasureString($backbuffer, "3mile制作", $arial, $rectf, $sformat)
        $hBrush_bk = _GDIPlus_LineBrushCreateFromRect($mes[0], 0xFFFF00FF, 0xFFFFFF00)
        _GDIPlus_GraphicsDrawStringEx($hContext, "X=" & $x & @CRLF & "Y=" & $y, $hFont, $tLayout, $hFormat, $hBrush_bk)        
        Local $hHBITAMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BrushDispose($hBrush_bk)
        _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $hHBITAMP))
        _WinAPI_DeleteObject($hHBITAMP)
        _GDIPlus_GraphicsClear($hContext, "0xFFFFFFFF")
        
        If $flag = 0 Then
                For $i = 0 To UBound($Point) - 1
                        If _WinAPI_PtInRectEx($x, $y, $Point[$i][0], $Point[$i][1], $Point[$i][2], $Point[$i][3]) Then
                                ToolTip("X=" & $x & @CRLF & "Y=" & $y)
                                $flag=$i+1
                                ExitLoop
                        EndIf
                Next
        Else
                        If _WinAPI_PtInRectEx($x, $y, $Point[$flag-1][0], $Point[$flag-1][1], $Point[$flag-1][2], $Point[$flag-1][3])<>1 Then
                                ToolTip("")
                                $flag=0
                        EndIf
        EndIf
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func Set_Icon()
        If $k > 2 Then $k = 0
        For $i = 0 To UBound($icon) - 1
                _SetImage($icon[$i], $png[$k])
                GUICtrlSetState(-1, $GUI_SHOW)
        Next
        $k += 1
EndFunc   ;==>Set_Icon

Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
        _WinAPI_RedrawWindow($gui, 0, 0, $RDW_UPDATENOW)
        _GDIPlus_GraphicsDrawStringEx($backbuffer, "3mile制作", $arial, $arr[0], $sformat, $blackbrush)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iX, $iY);copy bitmap to GUI
        _WinAPI_RedrawWindow($gui, 0, 0, $RDW_VALIDATE)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_PAINT

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
发表于 2011-7-26 02:20:29 | 显示全部楼层
学习了你对数组的处理方法。谢了。
 楼主| 发表于 2011-7-28 22:49:59 | 显示全部楼层
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。
 楼主| 发表于 2011-7-28 22:51:29 | 显示全部楼层
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。还有谢谢你的代码。
 楼主| 发表于 2011-7-28 22:54:27 | 显示全部楼层
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。还有谢谢你的代码。GDIPlusEx.au3也麻烦传一个,谢谢了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 06:18 , Processed in 0.074610 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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