Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 22:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



.png als GUI

Discussion on .png als GUI within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
Σternαl.'s Avatar
 
elite*gold: 20
Join Date: Dec 2009
Posts: 1,850
Received Thanks: 484
.png als GUI

Hi ich hab mal wieder ein Problem.
Und zwar möchte ich ein Bild mit Transparenz in meine GUI machen, also dass
die GUI nur aus diesem Bild besteht. Ich weiß eigentlich wie man sowas macht,
aber scheinbar nimmt AutoIt das Format .png nicht an, weil meine GUI nur grau ist.

Hier mal das Script

Also mein einziges Problem ist, dass die GUI grau ist und nicht mein Bild drauf ist.

Hoffe ihr kriegt es hin.

Mfg
Σternαl. is offline  
Old 07/21/2010, 03:13   #2
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Hier mal ein Script von mir, wo ich ein Bild als GUI verwende, ist halt auf autoit.de released worden.



Kurzes HowTo:

- Mit GDI+ Image laden
- WinAPISetLayeredWindowAttributes auf 255 setzen
- mit der SetBitmap Funktion das Bild auf die GUI laden.
PenGuin :O is offline  
Thanks
1 User
Old 07/21/2010, 12:28   #3
 
Σternαl.'s Avatar
 
elite*gold: 20
Join Date: Dec 2009
Posts: 1,850
Received Thanks: 484
Quote:
Originally Posted by pinguin94 View Post
Hier mal ein Script von mir, wo ich ein Bild als GUI verwende, ist halt auf autoit.de released worden.



Kurzes HowTo:

- Mit GDI+ Image laden
- WinAPISetLayeredWindowAttributes auf 255 setzen
- mit der SetBitmap Funktion das Bild auf die GUI laden.
Vielen Dank erstmal, ich hab ein Problem mit SetBitmap, da sagt der Compiler mir "Unknown Function".
Und warum muss man das über GDIplus machen?
Warum geht das eigentlich nicht einfach mit GUICreatePic?^^

€dit:
Sooo, sry für die dumme Frage zu SetBitmap xD
Hab ewig nixmehr programmiert, deswegen^^

Also ich denk ich hab das Prinzip so in etwa verstanden^^

Man lädt sich das Bild, dann haut man 2 GUI's drüber und macht die beiden transparent, oder?
Sry wenn ich falsch liege, hab wie gesagt schon ewig nixmehr programmiert
Σternαl. is offline  
Old 07/21/2010, 17:39   #4
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Praktisch ja, also
du lädst das Bild per GDI+.
Dann lädst du das auf eine GUI die vorherstellt wurde, aber nicht deine HauptGUI ist und die eigentliche machst du als Child von der BildGUI.
Die ChildGUI machst du transparent mit der Hintergrundfarbe deiner GUI.
Ich editiere gleich mal ein Beispiel.

Code:
#include <GDIPlus.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $AC_SRC_ALPHA = 1
$pngSrcGUIBK = "Bild.bmp"

#Region
$GUI = GUICreate("Test", 400, 450, -1, -1, $WS_POPUP, BitOR($WS_EX_CONTROLPARENT, $WS_EX_LAYERED))
_GDIPlus_Startup()
Global $hImageGUIBK = _GDIPlus_ImageLoadFromFile($pngSrcGUIBK)
SetBitmap($GUI, $hImageGUIBK, 255)
#EndRegion

#Region
$GUI_Main = GUICreate("", 400, 450, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)
GUISetBkColor(0x585858)
_WinAPI_SetLayeredWindowAttributes($GUI_Main, 0x585858)
#EndRegion

GUISetState(@SW_SHOW, $GUI)
GUISetState(@SW_SHOW, $GUI_Main)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
	EndSwitch
WEnd


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
PenGuin :O is offline  
Thanks
1 User
Old 07/23/2010, 00:31   #5
 
Σternαl.'s Avatar
 
elite*gold: 20
Join Date: Dec 2009
Posts: 1,850
Received Thanks: 484
Ah ok, das Prinzip versteh ich zwar nich so ganz, aber auf jeden Fall weiß ich, wie ichs machen muss und wie es klappt, Labels und Buttons hab ich auch schon hingekriegt ;D Danke nochmal^^

Morgen werd ich noch ein Bild reinmachen, iPod ftl ;O

€dit: So, das Bild ist jetzt da^^
Ist jetzt erstmal ohne Labels, weil ich mir noch nich sicher bin, was ich aus der GUI mache^^
Der Rote Knopf ist ein Closebutton.

Attached Images
File Type: jpg newGUI.jpg (15.9 KB, 20 views)
Σternαl. is offline  
Reply




All times are GMT +1. The time now is 22:02.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.