楼上风云
发表于 2011-7-20 13:27:53
13楼脚本还是实现不了效果。见附图。
我先检测一下我的系统和AU3环境看看。
楼上风云
发表于 2011-7-20 13:29:26
不知道倒是什么原因哦
xiezhang6263
发表于 2011-7-20 20:28:02
回复 13# 3mile
厉害呀,再加上个自动获取坐标的按钮上去就很完美了。
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]
$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
$ini_set = IniReadSection("map.ini", $ini[$i])
$temp = StringSplit($ini_set, ",", 3)
$Label[$i - 1] = GUICtrlCreateLabel("", $temp, $temp, $temp, $temp)
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
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
xiezhang6263
发表于 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]
;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
$ini_set=IniReadSection("map.ini",$ini[$i])
$temp=StringSplit($ini_set,",",3)
$Label[$i-1]=GUICtrlCreateLabel("",$temp,$temp,$temp,$temp)
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 & "Y:" & $Pos)
EndFunc
Func _SendMsg();窗体移动
_SendMessage($Form1, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
EndFunc
在从ini文件里面筛选,地图上加个查询按钮地图上根据时间显示出查询条件里面的条件,完美。。
3mile
发表于 2011-7-22 13:35:24
回复 20# xiezhang6263
你想要的功能都可以实现.
先上你的代码吧
penguinl
发表于 2011-7-22 18:12:50
好象看到过论坛上有跟FLASH交互的例子,至于数据存储的话,如果量可能选择小型数据库比较好吧!
huohukiss
发表于 2011-7-23 00:11:40
{:face (382):}
xiezhang6263
发表于 2011-7-24 00:29:44
回复 21# 3mile
查看了论坛里的资料找不到思路,3mile能否给点思路我参考下然后在把完善的贴出来。
现在的问题是外部加载图片或者flash无法实现,还有从ini文件里面按时间筛选查询也没办法实现。
希望3mile给点思路,谢谢了。
xiezhang6263
发表于 2011-7-25 20:26:02
回复 19# 3mile
查看了论坛里的资料找不到思路,3mile能否给点思路我参考下然后在把完善的贴出来。
现在的问题是外部加载图片或者flash无法实现,还有从ini文件里面按时间筛选查询也没办法实现。
希望3mile给点思路,谢谢了。
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]
Local $Label[$ini], $icon[$ini]
Global $k = 1
Global $png = ["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, 1, $iX - DllStructGetData($arr, 3))
DllStructSetData($arr, 2, $iY - DllStructGetData($arr, 4))
$blackbrush = _GDIPlus_LineBrushCreateFromRect($arr, 0xFFFFFF00, 0xFFFF0000, 1)
_GDIPlus_GraphicsDrawStringEx($backbuffer, "3mile制作", $arial, $arr, $sformat, $blackbrush)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iX, $iY);copy bitmap to GUI
For $i = 1 To $ini
$ini_set = IniReadSection("map.ini", $ini[$i])
$temp = StringSplit($ini_set, ",", 3)
$icon[$i - 1] = GUICtrlCreatepic('', $temp, $temp ,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] = $temp
$Point[$i - 1] = $temp
$Point[$i - 1] = $temp + $temp
$Point[$i - 1] = $temp + $temp
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, $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], $Point[$i], $Point[$i], $Point[$i]) 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], $Point[$i], $Point[$i], $Point[$i]) 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, 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], $Point[$i], $Point[$i], $Point[$i]) Then
ToolTip("X=" & $x & @CRLF & "Y=" & $y)
$flag=$i+1
ExitLoop
EndIf
Next
Else
If _WinAPI_PtInRectEx($x, $y, $Point[$flag-1], $Point[$flag-1], $Point[$flag-1], $Point[$flag-1])<>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, $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
qq123123
发表于 2011-7-26 02:20:29
学习了你对数组的处理方法。谢了。
xiezhang6263
发表于 2011-7-28 22:49:59
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。
xiezhang6263
发表于 2011-7-28 22:51:29
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。还有谢谢你的代码。
xiezhang6263
发表于 2011-7-28 22:54:27
回复 26# 3mile
icons.au3找不到??你那边有吗?麻烦发一个,谢谢。还有谢谢你的代码。GDIPlusEx.au3也麻烦传一个,谢谢了。