-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguiCtrlCreatePic.au3
132 lines (91 loc) · 2.6 KB
/
guiCtrlCreatePic.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt ('MustDeclareVars', 1)
Global $gui, $guiPos, $pic, $picPos, $WS_EX_MIDCHILD
Example1()
Example2()
; ---Example 1-----
Func Example1()
Local $n, $msg
GUICreate("My GUI Picture", 1024, 720, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is created
GUISetBkColor(0xE0FFFF)
$n = GUICtrlCreatePic(@DesktopDir & "\gai.jpg", 25, 25, 512, 342)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
; GUISetState
; resize the control
$n = GUICtrlSetPos($n, 25, 25, 720, 360)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc
; Example 2
Func Example2()
Local $msg
$gui = GUICreate("test transparentpic",1024,720, -1)
$pic = GUICreate("",512, 341, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MIDCHILD), $gui)
GUICtrlCreatePic(@DesktopDir & "\gai1.jpg",0, 0, 0, 0, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_SHOW, $pic)
HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
EndFunc ; => Example 2
Func main()
$guiPos = WinGetPos($gui)
WinMove($gui, "", $guiPos[0] + 10, $guiPos[1] + 10)
EndFunc
Func left()
$picPos = WinGetPos($pic)
WinMove($pic, "",$picPos[0] - 10, $picPos[1])
EndFunc
Func right()
$picPos = WinGetPos($pic)
WinMove($pic, "", $picPos[0] + 10, $picPos[1])
EndFunc
Func down()
$picPos = WinGetPos($pic)
WinMove($pic, "", $picPos[0], $picPos[1] + 10)
EndFunc
Func up()
$picPos = WinGetPos($pic)
WinMove($pic, "", $picPos[0], $picPos[1] - 10)
EndFunc
;Example 3 PNG work araund by Zedna
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
Global $hGUI, $hImage, $hGraphics, $hImage1
; Create GUI
$hGUI = GUICreate("Show PNG", 350, 301)
; Load PNG Image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("Desktop\gai3.jpg")
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
GUIRegisterMsg($WS_PAINT, "MY_WM_PAINT")
GUISetState()
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resource
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
; Draw PNG Image
Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam)
_WinAPI_RedrawWindow($hGUI, 0, 0 , $RDW_UPDAte