Jump to content



Photo

Multiple PNG Images on GUI


  • Please log in to reply
7 replies to this topic

#1 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 03 May 2010 - 12:13 AM

I was surfing through the forums looking for something that I had previously missed and came across JRowe's topic on creating a gui out of multiple png images. I saw the complexity of using several guis so I thought I would post what I have used for quite a while to make this process much easier.

This is a fairly simple udf for newcomers (or anyone new to GDI+) that allows you to add images and strings to an array and they will be automatically be drawn on top of the background when SetBitmapEx is called. There is only one gui so you won't have to juggle several windows just to get a good looking gui.

This example was meant to be edited based on personal preference. I refrained from adding too much complexity to the code without sacrificing a whole lot of functionality. Everyone is free to change this udf to suite your project.

The files can be downloaded here.

Updated 3/11/10: Fixed a few bugs; added gui centering; added examples
Updated 3/3/10: Added ability to draw strings

Edited by dantay9, 12 May 2010 - 02:34 AM.

"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com







#2 picea892

picea892

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 690 posts

Posted 12 May 2010 - 01:39 AM

Any chance you could give an example with more than one image? I've tried a couple times to tweak. Also is $Style defined in a udf, maybe I'm using an old autoit build.
Is this how you would do it?

Dim $Images[1][9] = [["Dice.png", 0, 100, 50, 50, 0, 0, 100, 50]] _GDIPlus_Startup() $GUI = GUICreate("", 300, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED) AddImage($Images, "Dice.png", 50, 100, 50, 50, 0, 100) AddImage($Images, "Picture1.png", 150, 100, 150, 50, 200, 100) ;AddString($Images, "STRING", 25, 25, "Arial", 20, 1, 0xFFFF0000) SetBitmapEx($GUI, "Dice.png", 255, $Images, -1, -1) SetBitmapEx($GUI, "Picture1.png", 255, $Images, -1, -1) GUISetState()


#3 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 12 May 2010 - 02:15 AM

Oops. $Style was the old name of my variable but I changed it to $Attribute. Fixed it now.

SetBitmap should only be called once. There is going to be a single background and then the images in the array will be painted on top of the background.

Maybe the small example that I gave was a bit too small. I will work on adding more examples. Anyways, here is another example that shows a bit of a different look to the code. This is also in the new download.

#Region Create Images Array Dim $Images[1][9] ;doesn't have to be initialized, but can be AddImage($Images, "Image 1.png", 50, 50, 50, 50, 0, 50) AddImage($Images, "Image 2.png", 50, 50, 50, 50, 50, 150) AddString($Images, "STRING", 15, 115, "Arial", 20, 1, 0xFFFF0000) #EndRegion Create Images Array _GDIPlus_Startup() $GUI = GUICreate("", 300, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED) ;don't forget, the window must be layered SetBitmapEx($GUI, "Dice.png", 255, $Images, -1, -1) ;set the background that will be drawn on top of GUISetState() ;Loop until ESC is pressed Do     Sleep(100) Until _IsPressed("1B") _GDIPlus_Shutdown()


Edit: Added a few more examples. The examples are a little more diverse now.

Edited by dantay9, 12 May 2010 - 02:35 AM.

"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#4 picea892

picea892

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 690 posts

Posted 12 May 2010 - 02:57 AM

Okay, it makes complete sense now.
You're right, it is very easy to use, I think you'll get a bit more interest with your new examples.

#5 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 12 May 2010 - 07:07 PM

Thanks. At least someone found this interesting.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#6 qwert

qwert

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 503 posts

Posted 16 November 2011 - 02:51 PM

This ID doesn't exist!

Any chance of getting this link restored? ... or maybe post the script inline?

#7 nino11

nino11

    Seeker

  • New Members
  • 1 posts

Posted 13 April 2012 - 02:05 PM

Same as qwert ?

I would like get your UDF

#8 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 7,037 posts

Posted 13 April 2012 - 02:27 PM

Unfortunately it appears that the OP hasn't been on the site since June of last year, unless another user has the code I wouldn't hold my breath too long waiting.

How to ask questions the smart way!

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.

Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.

_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users