Jump to content

GUI Multi Problems (tab background design etc positioning)


Recommended Posts

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=GRAPHICS\jinx.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <Array.au3>
#include <ColorConstants.au3>
#include <Date.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

; ##################################### GUI MAIN ###################################################

Global $MainForm = GUICreate("MTGTO V10 - Settings", 960, 1370, 1600, 0) ; -1 = Centered

Global $MainPic2 = GUICtrlCreatePic("GRAPHICS\BG_CcC.jpg", 0, 0, 960, 1370)
;~ GUISetBkColor(0x191e00)

Global $ComboShopLabel = GUICtrlCreateLabel("Shop:", 10, 18, 35, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
GUICtrlSetColor(-1, $COLOR_YELLOW)
Global $ComboShop = GUICtrlCreateCombo("", 56, 16, 250, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 500, 0, "Tahoma")
Global $ButtonDelete = GUICtrlCreateButton("Delete", 320, 15, 70, 25)
GUICtrlSetState($ButtonDelete, $GUI_DISABLE)
Global $ButtonApply = GUICtrlCreateButton("Apply", 850, 15, 70, 25)
GUICtrlSetState($ButtonApply, $GUI_DISABLE)

Global $ChangeForTrade = GUICtrlCreateButton("Change Tradeable QTY", 550, 15, 150, 25)
Global $ButtonStartMTGO2T = GUICtrlCreateButton("Launch MTGO2T", 750, 15, 100, 25)
Global $Status = GUICtrlCreateLabel("Starting", 10, 1100, 940, 190, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, $COLOR_YELLOW)
Global $MainFormChecksum = $MainForm
Global $MainFormSearch = $MainForm
;~ GUISwitch($MainForm)
GUISetState(@SW_SHOW, $MainForm)

;~ $hGUI = GUICreate("Built-In Tab Example", 500, 500)

Global $hTab = GUICtrlCreateTab(0, 100, 900, 1000)
GUICtrlSetBkColor(-1, $COLOR_YELLOW)
; Create tabitems

$tab2 = GUICtrlCreateTabItem("Tab 2         ")
GUICtrlSetState(-1, $GUI_SHOW)
$tab3 = GUICtrlCreateTabItem("Tab 3       ")
$tab4 = GUICtrlCreateTabItem("Tab 4          ")

$troll = GUICtrlCreateButton("Button", 350, 180, 80, 30)
Global $kekka = GUICtrlCreateLabel("Shopping:", 350, 280, 35, 17)


$tab5 = GUICtrlCreateTabItem("Tab 5        ")
$tab6 = GUICtrlCreateTabItem("Tab 6         ")
$tab1 = GUICtrlCreateTabItem("Tab 1           ")

$troll = GUICtrlCreateButton("Button", 150, 180, 80, 30)



; ##################################### GUI 2 CREATE (SQL DEBUG) ###################################################

Global $GuiSQL = GUICreate("MTGTOT2 - SQL Debug", 1024, 40, 0, 1300, $WS_POPUP, $WS_EX_TOPMOST)
Global $GuiSQLPic = GUICtrlCreatePic("GRAPHICS\Main_DS.jpg", 0, 0, 1024, 40)
Global $GuiSQLStatus = GUICtrlCreateLabel("", 2, 2, 1020, 36, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")

GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW, $GuiSQL)


;~ Local $idTab = GUICtrlCreateTab(10, 10, 200, 100)


HotKeySet("{ESC}", "Terminate")

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate







While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    If $nMsg = $ChangeForTrade Then
        setimage()
        GUICtrlSetState($ButtonApply, $GUI_ENABLE)
        GUICtrlSetState($ButtonStartMTGO2T, $GUI_ENABLE)
    EndIf
    If $nMsg = $ButtonApply Then
        GUICtrlSetState($ButtonStartMTGO2T, $GUI_DISABLE)
        GUICtrlSetData($ButtonStartMTGO2T, "Epic")
        GUICtrlSetData($Status, "Leentje leerde lotje lopen langs de lange linden laan!")
        GUICtrlSetState($hTab, $GUI_ENABLE)
    EndIf
    Sleep(50)
WEnd


Func setimage()
;~  MsgBox(0, "", "", 0)
    $GuiSQLStatus = 0
EndFunc   ;==>setimage

Thank you for taking the time to read this, I must admit that my level of gui and general programming skills are beginner / novice, I am a slow learner and i have had problems figuring a lot of things out! 

Some code is messy and experimental stuff, but i believe it does not interfere with the real code! 

 

My problems and questions are as follow,

1. if I have a actually running background picture, the tabs are not properly visible

2. can I run on each tab a different background 

3. can each tab button contain graphics or modified buttons (not important but cute to know)

4. Maybe I am missing some big pictures here about certain stuff, but is it possible for example 

Global $MainForm = GUICreate("MTGTO V10 - Settings", 960, 1370, 1600, 0) 
$hTab = GUICtrlCreateTab(5, 100, 900, 1000) ; So it runs 5pix away from left and 100 from top of the $MainForm GUI

$tab3 = GUICtrlCreateTabItem("Tab 3       ")
$tab4 = GUICtrlCreateTabItem("Tab 4          ")

$troll = GUICtrlCreateButton("Button", 350, 180, 80, 30);SO i prefer this to show (*relative (right word?)) from where the tab starts and not where the $MainForm GUI starts!

5. any piece of advice or good reads / tutorials about this would be greatly appriciated, Also I want to ask where I can find a person who can help me out over skype / teamviewer PAID!!!(as in 10-15$ a hour) to help me get jump started

6. this is my first GUI ever and it will become kinda complicated, any good read or info is greatly appriciated!, I hope I can return one day here the favor on this forum!

7. for my buttons and checkboxes to work I just use If "$nMsg = $ChangeForTrade Then" instead of what i often see in tutorials "switch statements"  is there fundamentally wrong with I do?  

Regards, GarnetDagger

Link to comment
Share on other sites

For questions 1 - 2, this might help get you started. What you're looking for is GUICtrlCreatePic and GUICtrlSetState(Id of pic control, $GUI_DISABLE).

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=GRAPHICS\jinx.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Array.au3>
#include <ColorConstants.au3>
#include <Date.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region New Code ~InunoTaishou
#include <GUITab.au3>
#include <INetConstants.au3>

If (Not FileExists("Tab1.jpg")) Then DownloadImage("https://www.autoitscript.com/autoit3/files/graphics/autoit_matrix_wall_800x600.jpg", "Tab1.jpg")
If (Not FileExists("Tab2.jpg")) Then DownloadImage("https://www.autoitscript.com/autoit3/files/graphics/autoit_metal_wall_800x600.jpg", "Tab2.jpg")
If (Not FileExists("Tab3.jpg")) Then DownloadImage("https://www.autoitscript.com/autoit3/files/graphics/autoit9_wall_800x600.jpg", "Tab3.jpg")
If (Not FileExists("Tab4.jpg")) Then DownloadImage("https://www.autoitscript.com/autoit3/files/graphics/autoit_builder_wall_800x600.jpg", "Tab4.jpg")
#EndRegion New Code ~InunoTaishou

; ##################################### GUI MAIN ###################################################

Global $MainForm = GUICreate("MTGTO V10 - Settings", 960, 1370, 1600, 0) ; -1 = Centered

Global $MainPic2 = GUICtrlCreatePic("GRAPHICS\BG_CcC.jpg", 0, 0, 960, 1370)
;~ GUISetBkColor(0x191e00)

Global $ComboShopLabel = GUICtrlCreateLabel("Shop:", 10, 18, 35, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
GUICtrlSetColor(-1, $COLOR_YELLOW)
Global $ComboShop = GUICtrlCreateCombo("", 56, 16, 250, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 500, 0, "Tahoma")
Global $ButtonDelete = GUICtrlCreateButton("Delete", 320, 15, 70, 25)
GUICtrlSetState($ButtonDelete, $GUI_DISABLE)
Global $ButtonApply = GUICtrlCreateButton("Apply", 850, 15, 70, 25)
GUICtrlSetState($ButtonApply, $GUI_DISABLE)

Global $ChangeForTrade = GUICtrlCreateButton("Change Tradeable QTY", 550, 15, 150, 25)
Global $ButtonStartMTGO2T = GUICtrlCreateButton("Launch MTGO2T", 750, 15, 100, 25)
Global $Status = GUICtrlCreateLabel("Starting", 10, 1100, 940, 190, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, $COLOR_YELLOW)
Global $MainFormChecksum = $MainForm
Global $MainFormSearch = $MainForm
;~ GUISwitch($MainForm)
GUISetState(@SW_SHOW, $MainForm)

;~ $hGUI = GUICreate("Built-In Tab Example", 500, 500)

Global $hTab = GUICtrlCreateTab(0, 100, 900, 1000)
GUICtrlSetBkColor(-1, $COLOR_YELLOW)
; Create tabitems

#Region Modified Code ~InunoTaishou
$tab2 = GUICtrlCreateTabItem("Tab 2")
#Region New Code ~InunoTaishou
GUICtrlCreatePic("Tab2.jpg", 0, 122, 900, 878)
GUICtrlSetState(-1, $GUI_DISABLE)
#EndRegion New Code ~InunoTaishou
$tab3 = GUICtrlCreateTabItem("Tab 3")
#Region New Code ~InunoTaishou
GUICtrlCreatePic("Tab3.jpg", 0, 122, 900, 878)
GUICtrlSetState(-1, $GUI_DISABLE)
#EndRegion New Code ~InunoTaishou
$tab4 = GUICtrlCreateTabItem("Tab 4")
#Region New Code ~InunoTaishou
GUICtrlCreatePic("Tab4.jpg", 0, 122, 900, 878)
GUICtrlSetState(-1, $GUI_DISABLE)
#EndRegion New Code ~InunoTaishou

$troll = GUICtrlCreateButton("Button", 350, 180, 80, 30)
Global $kekka = GUICtrlCreateLabel("Shopping:", 350, 280, 35, 17)


$tab5 = GUICtrlCreateTabItem("Tab 5")
$tab6 = GUICtrlCreateTabItem("Tab 6")
$tab1 = GUICtrlCreateTabItem("Tab 1")
#Region New Code ~InunoTaishou
GUICtrlCreatePic("Tab1.jpg", 0, 122, 900, 878)
GUICtrlSetState(-1, $GUI_DISABLE)
#EndRegion New Code ~InunoTaishou
GUICtrlSetState(-1, $GUI_SHOW)
; Removed the spaces after the tab items and moved your SetState to the bottom
#EndRegion Modified Code ~InunoTaishou

#Region New Code ~InunoTaishou
_GUICtrlTab_SetMinTabWidth($hTab, 50)
#EndRegion New Code ~InunoTaishou

$troll = GUICtrlCreateButton("Button", 150, 180, 80, 30)



; ##################################### GUI 2 CREATE (SQL DEBUG) ###################################################

Global $GuiSQL = GUICreate("MTGTOT2 - SQL Debug", 1024, 40, 0, 1300, $WS_POPUP, $WS_EX_TOPMOST)
Global $GuiSQLPic = GUICtrlCreatePic("GRAPHICS\Main_DS.jpg", 0, 0, 1024, 40)
Global $GuiSQLStatus = GUICtrlCreateLabel("", 2, 2, 1020, 36, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")

GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW, $GuiSQL)


;~ Local $idTab = GUICtrlCreateTab(10, 10, 200, 100)

HotKeySet("{ESC}", "Terminate")

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    If $nMsg = $ChangeForTrade Then
        setimage()
        GUICtrlSetState($ButtonApply, $GUI_ENABLE)
        GUICtrlSetState($ButtonStartMTGO2T, $GUI_ENABLE)
    EndIf
    If $nMsg = $ButtonApply Then
        GUICtrlSetState($ButtonStartMTGO2T, $GUI_DISABLE)
        GUICtrlSetData($ButtonStartMTGO2T, "Epic")
        GUICtrlSetData($Status, "Leentje leerde lotje lopen langs de lange linden laan!")
        GUICtrlSetState($hTab, $GUI_ENABLE)
    EndIf
    Sleep(50)
WEnd


Func setimage()
;~  MsgBox(0, "", "", 0)
    $GuiSQLStatus = 0
EndFunc   ;==>setimage

#Region New Code ~InunoTaishou
Func DownloadImage(Const $sDownloadUrl, Const $sSaveAs)
    Local $iDownloadSize = InetGetSize($sDownloadUrl)
    Local $hDownload = InetGet($sDownloadUrl, $sSaveAs, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    While (Not InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE))
        Sleep(100)
    WEnd

    Return FileExists($sSaveAs)
EndFunc   ;==>DownloadImage
#EndRegion New Code ~InunoTaishou

#3: Yes it's possible, you want to create the button with a $BS_BITMAP style (GUICtrlCreateButton("", x, y, width, height, $BS_BITMAP)) and then use GUICtrlSetImage(Id of button, Path to image).

#4: You'll have to put in where the x and y positions of the tabs are yourself. You can store them in a global variable if you want

GUICtrlCreateButton("Button", 5 + 350, 100 + 180, 80, 30)   ; X position of tab is 5, Y position of tab is 100
; Alternative
Global Const $TAB_X = 5
Global Const $TAB_Y = 100
GUICtrlCreateButton("Button", $TAB_X + 350, $TAB_Y + 180, 80, 30)

#7: You can use Switch (GUIGetMsg()) and then the ids of your controls and the gui event messages.

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>

Example()

Func Example()
    GUICreate("GUIGetMsg() Example", 400, 280, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

    Local $idButton1 = GUICtrlCreateButton("Button 1", 10, 10, 120, 40)
    Local $idButton2 = GUICtrlCreateButton("Button 2", 140, 10, 120, 40)
    Local $idButton3 = GUICtrlCreateButton("Button 3", 270, 10, 120, 40)
    Local $idEdit = GUICtrlCreateEdit("GUIGetMsg() example using a switch", 10, 60, 380, 185)

    GUISetState(@SW_SHOW)

    While (True)
        Switch (GUIGetMsg())
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $GUI_EVENT_MINIMIZE
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "GUI was minimized")
            Case $GUI_EVENT_MAXIMIZE
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "GUI was maximized")
            Case $GUI_EVENT_RESTORE
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "GUI was restored")
            Case $GUI_EVENT_RESIZED
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "GUI was resized")
            Case $idButton1
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "Button 1 was pressed")
            Case $idButton2
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "Button 2 was pressed")
            Case $idButton3
                GUICtrlSetData($idEdit, GUICtrlRead($idEdit) & @CRLF & "Button 3 was pressed")
        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

 

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...