6 posts in this topic
Hello. I'm trying to make a form with two pictures and one button. But pictures must overlap one another. First picture I'm getting from screenshot of another window, but second picture must be with alfa channel and positioning on that first image.
Something like that:
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> Global Const $AC_SRC_ALPHA = 1 $Form1_1 = GUICreate("Document", 701, 671, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("", 8, 8, 409, 657) $Button1 = GUICtrlCreateButton("Take Picture", 424, 8, 161, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Generate() EndSwitch WEnd Func Generate() Local $hBMP, $hBitmap, $hGraphic, $WindowToCapture WinActivate("Notepad") $WindowToCapture = ControlGetHandle("Notepad", "", "[CLASS:Edit; INSTANCE:1]") $hBMP = _ScreenCapture_CaptureWnd ( '', $WindowToCapture,4,4,400,470,False) ; Initialize GDI+ library _GDIPlus_Startup() $PicHandle = GUICtrlGetHandle($Pic1) $myGuiHandle = ControlGetHandle("Document", "", $PicHandle) $TransparentButtonTest = GUICreate("", 0, 0, 390, 130, $WS_EX_MDICHILD, $WS_EX_LAYERED, $myGuiHandle) $hImageButton = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\2-f.png") SetBitMap($TransparentButtonTest, $hImageButton, 255) GUISetState() WinActivate("Document") ; Draw bitmap to GUI $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($Pic1)) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 100) ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hBMP) ; Shut down GDI+ library _GDIPlus_Shutdown() EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) 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 But the most interesting, that I need to move second picture(png FromFile) by draging it with mouse ontop of first image.
Can you tell me what I have done wrong and maybe there is some easier ways to do this?
I'm trying to use '?do=embed' frameborder='0' data-embedContent>> but none of the examples work. Mostly, I'm just not seeing any pictures, just nothing, a window with some text but no picture. What am I doing wrong? Do these examples work for anybody else?
New release. 19 June 2013 (126.96.36.199)
There is a relation with this topic SQLite ListView and BLOB demo but I decided to start a completely new Topic because the approach is considerably different from the two previous examples which were only kick-offs to this demo.
This example shows how binary objects can be recognized natively in a database BLOB field without having to link to other fields that may contain information of the data object.
In the demo I used 2 approaches for native recognition
1. For multi-type binary objects, the file name is added in the header of the BLOB
Multi-type object can be images or any other kind of file. Because of the object header data, there is no need to identify the object in the binary code
2. Objects without header data, this works only for images, an algorithm will identify the type of image.
The demo shows what happens whit objects which are not identifiable, see example 5.
1. trancexx: GIFAnimation.au3
'?do=embed' frameborder='0' data-embedContent>>
2. smashly: _ImageResize()
Resizes and converts different graphicformats
3. rover: Customize Draw of Listview rows
Optimizations of WS_NOTIFY
I also thank rover for giving a second method to resolve the image space issue.
I implemented the one proposed by KaFu, because very simple to implement
4. KaFu: Solved the Listview issue with image space in Columns one.
5. jchd: For some hints and background info on SQLite
6. Yashied: WinAPIEx.au3
'?do=embed' frameborder='0' data-embedContent>>
new release. Version 188.8.131.52
- added fully generic Add, Edit, Add/Copy, Delete and Find buttons. With fully generic I mean, you don't have to bother about the table content, GUI field inputs will populate accoring to the table definition.
- Added Field validation, also according to how the columns were defined in the table. (see GUI dynamic input validation for more information)
tested a thousand times... on W7 and WXP 32/64
For a working example you have to download 2 files (see links in between the horizontal lines:
SQLite GreenCan_demo BLOB in Listview 184.108.40.206.zip GreenCan_demo2.zip (if you already did, don't mind downloading it again) Note:
For the Edit GUI, you will notice that sometimes one field is not editable, marked as (*PK) in the description. The field is a 'Primary Key autoincrement'. When appending the row, the PK will automatically increment, therefore it is not allowed to edit the field.
Other fields mared (*) cannot be empty, you can only save the row if these fields contain data.
In the case (*PK) is editable, you have to put unique data for the Primary key. If you do a copy/add without changing the field content, you will get a not unique Error.
Special case: I don't allow empty primary key (NULL), while SQLite does, but it's pretty useless anyhow because you can only have 1 NULL in a Primary key.
I have also included a very small non BLOB database, for example 0, to show that the generic edit/add works also here.
SQLite GreenCan_demo BLOB in Listview 220.127.116.11.zip
and don't forget to download this zip file to complete the required files for the demo
I let you explore the demo and please give me feedback.
Hi Everyone! Been away from scripting for a bit and am a bit rusty.
I was trying to get downloaded image filenames to increment by one. I was hoping to be able to check the last filename and continue from there if the program was closed and reopened again.
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $biolister = GUICreate("Form1", 125, 97, 192, 124) GUISetBkColor(0x99B4D1) $start = GUICtrlCreateButton("Start", 8, 40, 41, 33) GUICtrlSetBkColor(-1, 0x00FFFF) $stop = GUICtrlCreateButton("Stop", 72, 40, 41, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Bio = GUICtrlCreateLabel("Bio Lister", 24, 8, 80, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $filename = 0 $sImgDir = "C:\filepathname\"&$filename&".jpg" $sImgUrl = "http://lorempixel.com/400/200" $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $stop Exit case $start InetGet($sImgUrl, $simgdir, 1, 0) if fileexists( $simgdir & $filename) then $filename + 1 EndSwitch WEnd