Jump to content

Is there a way to make a custom gui?


bleh
 Share

Recommended Posts

Hello

I know how to make a GUI with GUIcreate, GUIctrlcreatelist, etc.

But is there a way to skin them?

I could remove borders, menus and so on from the GUIcreate form but then i won't be able to drag the window anymore and the buttons, editboxes etc would still have the windows look.

So, is there an easy way to make a custom gui?

Link to comment
Share on other sites

Okay. I rephrase my question. Is there a way to make a custom UI without having to use a 3d party DLL/script and without having to pay hundreds of dollars for skincrafter? If so.. how? Are there any tutorials or examples?

Link to comment
Share on other sites

Okay. I rephrase my question. Is there a way to make a custom UI without having to use a 3d party DLL/script and without having to pay hundreds of dollars for skincrafter? If so.. how? Are there any tutorials or examples?

I'm not sure what you mean by 3rd party script, but without some type of external elements such as png/jpg/bmp files, you're in for a lot of effort for little gain.

I'd use something like XSkin or USkin for easy skinning.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try this :

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>

Local $aFile[3] = ["5qa.png", "15u.jpg", "ag5.jpg"], $hGet = 0
For $i = 0 To UBound($aFile) -1
    $hGet = InetGet("http://img.myzupics.com/ab/" & $aFile[$i], @TempDir & "\" & $aFile[$i])
    InetClose($hGet)
Next

Local $hBmp = 0, $hHBmp = 0, $tSize = 0, $iWidth = 0, $iHeight = 0
Local $hGUI = 0, $hGUILayered = 0, $iLabelBtnCustom = 0, $iBtnOK = 0

_GDIPlus_Startup()

$hBmp = _GDIPlus_BitmapCreateFromFile(@TempDir & "\" & $aFile[0])

$hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
_GDIPlus_ImageDispose($hBmp)

$tSize = _WinAPI_GetBitmapDimension($hHBmp)

$iWidth = DllStructGetData($tSize, 1)
$iHeight = DllStructGetData($tSize, 2)

#region GUI
$hGUI = GUICreate("MyGUI", $iWidth, $iHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))

$hGUILayered = GUICreate("", $iWidth, $iHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)
GUISetBkColor(0x2B5280, $hGUILayered)

$iPicBtnCustom = GUICtrlCreatePic(@TempDir & "\" & $aFile[1], 20, 20, 101, 24)
GUICtrlSetState($iPicBtnCustom, $GUI_DISABLE)

$iLabelBtnCustom = GUICtrlCreateLabel("Click me", 20, 20, 101, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor($iLabelBtnCustom, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor($iLabelBtnCustom, 0)

$iBtnOK = GUICtrlCreateButton("OK", ($iWidth - 70) / 2, $iHeight - 45, 70, 22)
GUICtrlSetState($iBtnOK, $GUI_FOCUS)

_WinAPI_SetLayeredWindowAttributes($hGUILayered, 0x2B5280, 0, $LWA_COLORKEY)
_WinAPI_UpdateLayeredWindowEx($hGUI, -1, -1, $hHBmp)
GUISetState(@SW_SHOW, $hGUILayered)

GUISetState(@SW_SHOW, $hGUI)
#endregion

Local $aCi = 0, $blBtnCustomHovered = False

While 1
    Sleep(10)

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iBtnOK
            ExitLoop
        Case $iLabelBtnCustom
            MsgBox($MB_SYSTEMMODAL, Default, "It works !", 0, $hGUILayered)
    EndSwitch

    $aCi = GUIGetCursorInfo($hGUILayered)
    If IsArray($aCi) = 0 Then ContinueLoop

    If $aCi[4] = $iLabelBtnCustom _
            And Not $blBtnCustomHovered Then
        GUICtrlSetImage($iPicBtnCustom, @TempDir & "\" & $aFile[2])
        $blBtnCustomHovered = True
    ElseIf $aCi[4] <> $iLabelBtnCustom _
            And $blBtnCustomHovered Then
        GUICtrlSetImage($iPicBtnCustom, @TempDir & "\" & $aFile[1])
        $blBtnCustomHovered = False
    EndIf
WEnd

GUIDelete($hGUI)

_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()

For $i = 0 To UBound($aFile) -1
    FileDelete(@TempDir & "\" & $aFile[$i])
Next
Edit: Added indents.

Note: The WinAPIEx library is only needed for the _WinAPI_GetBitmapDimension function, you can use instead _GDIPlus_ImageGetWidth/Height.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Thanks guys.

 

I'm not sure what you mean by 3rd party script, but without some type of external elements such as png/jpg/bmp files, you're in for a lot of effort for little gain.

 

I'd use something like XSkin or USkin for easy skinning.


What i meant by that is that i was looking for a way to skin without having to use a DLL file or a second .au3. Of course i would have to save the images somewhere.

So that i end up in the end with something like this:


appdirapp.exe

appdirfilesskinfile1.png

appdirfilesskinfile2.png

 

Anyways, i don't have time to test around right now, but a quick look at USkin, XSkin and what FireFox posted, seemed good. I'll test around with that later.

Thanks

Link to comment
Share on other sites

One of the ways that I like to handle this is to create a GUI with no boarder. Then you are free to create the boarder for yourself. If you are looking for somthing more custom than that, you arnt likely to find it.

This is not only a solution for autoit, but any programming language that deals with interfaces.

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Skin without DLL? Why do this? You could use a DLL and run it from memory.

But if you don't want to do this, then this is the hard way to go for you:

It's by far not complete, just a start. A lot of work, only to see that AutoIt is a bit to slow for things like this.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

It's really simple and not that useful in the grand scheme of things but it works for the tiny little prog i'm doing. I'm new to AutoIt and i'm not sure yet what is 'elegant' coding and what the do's and do not's are, so i'm kind of shy posting my scripts.

But i will quickly make an example of how i did it and post it in a few mins.

Edit:

Here it is, if anyone cares (don't laugh ;)):

simple.rar

Credit goes to the script from this post by melba23: 

Edited by bleh
Link to comment
Share on other sites

I once made a GUI for a project of mine, in AutoIt, that looked like a CD, complete with the hole in the middle, and it was round. I accomplished this by using an image of a CD as the background of my GUI.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

:)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...