Jump to content
Sign in to follow this  
zvvyt

Parent GUI w/ backgroundimage and transparent child GUI ontop?

Recommended Posts

zvvyt

Hello there!

The idea I'm having is the following:

To have a GUI with the left half scrollable and to have a background image which is "fixed" and won't be moved with the scrolling.

To do this I've so far come up with:

Placing the backgrond image onto a parent GUI

Creating a child GUI to the parent, ontop of the left half of the parent

Using "GUIScrollbars_Ex.au3" to easy insert my scrollbars into the child gui

The problem I'm having is that the background image places itself ontop of the child GUI, making the child not visible.

I have tried placing the same background image into the child GUI to recieve the same result I want, but by doing so the image will move with my scrolling. (The right half of the parent is covered by another image, so that's why I'm able of placing the same background image into the child GUI)

If I'm somehow able of placing the background image "behind" the child GUI I could use either a transparent .GIF or .PNG to make the child window show the image aswell as my controls.

Any direct thoughts about this, or do you need me to post some of the code?

Best regards,

Share this post


Link to post
Share on other sites
Melba23

zvvyt,

do you need me to post some of the code?

Yes please - then we will see exactly what you have done so far. ;)

M23

P.S. When you post your code please use Code tags - put [autoit] before and [/autoit] after it. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
zvvyt

Alrighty then! ^__^

I took only the parts about GUIs and their controls now, which I recon are what matters.

#include <ButtonConstants.au3>
#include "GUIScrollbars_Ex.au3"





$MainWindow = GUICreate("Main Window", 800,500,-1,-1,-1)
;$ItemBackground = GUICtrlCreatePic(".\..\LoL Recommended Builder\ItemsBackground.jpg",0,0,900,600,$bs_flat) ;--------Here's the background image stated in my last post
GUICtrlSetState($ItemBackground,$gui_disable)
$Border = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Border.jpg",802-260*(500/390)-38,0,38,500,$bs_flat)
$ChampionSplash = GUICtrlCreatePic("",802-260*(500/390),"",260*(500/390),390*(500/390),$BS_FLAT)
$ButtonCC = GUICtrlCreateButton("Change Champion",700,0,95,25,$GUI_NOFOCUS)
$RecItem1 = GUICtrlCreateIcon("icons.dll","NOITEM",470,440,50,50)
$RecItem2 = GUICtrlCreateIcon("icons.dll","NOITEM",525,440,50,50)
$RecItem3 = GUICtrlCreateIcon("icons.dll","NOITEM",580,440,50,50)
$RecItem4 = GUICtrlCreateIcon("icons.dll","NOITEM",635,440,50,50)
$RecItem5 = GUICtrlCreateIcon("icons.dll","NOITEM",690,440,50,50)
$RecItem6 = GUICtrlCreateIcon("icons.dll","NOITEM",745,440,50,50)
$HighlightRecItem = GUICtrlCreateGroup("","","","","")
GUICtrlSetState(-1, $gui_hide)
$HighlightSelectedItem = GUICtrlCreateGroup("","","","","")
GUICtrlSetState(-1, $gui_hide)
$Read = FileReadLine("List.ini",2)
$ItemDropdown = GUICtrlCreateCombo("",50,50,200,45)
GUICtrlSetState(-1,$gui_hide) ;--------------------------------------------------------------------------------------------Temp. Hidden
GUICtrlSetData(-1,$Read)
$SelectedItem = GUICtrlCreateIcon("","",300,100,64,64)
$BackButton = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Back.jpg",165,370,100,30) ;Back-button
GUICtrlSetState(-1,$gui_hide)
GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\ItemTextBackgroundDark.jpg",0,400,430,100) ;Background for itemtext
$ItemText = GUICtrlCreateLabel("",10,410,420,80)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@sw_hide,$MainWindow)


;-----------------------------------------------------------------------------Child Windows----------------------
$CatWindow = GUICreate("Main Category Window",430,400,0,0,$ws_child,"",$MainWindow) ;First child-window with the main categories
;$ItemBackground = GUICtrlCreatePic(".\..\LoL Recommended Builder\ItemsBackground.jpg",0,0,900,600,$bs_flat);----And here is where I tried placing the background again.
$CatDefense = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Cat.Defense.jpg",115,45,200,40)
$CatAttack = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Cat.Attack.jpg",115,110,200,40)
$CatMagic = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Cat.Magic.jpg",115,175,200,40)
$CatMovement = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Cat.Movement.jpg",115,240,200,40)
$CatConsumables = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Cat.Consumables.jpg",115,305,200,40)
GUISetState(@sw_hide,$CatWindow)

$CatWindowDefense = GUICreate("Defense",430,400,0,0,$ws_child,"",$MainWindow) ;A child-window showing the defense subcats
$DefenseSubcatHealth = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\SubCat.Health.jpg",115,45,200,40)
$DefenseSubcatMagicResist = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Subcat.MagicResist.jpg",115,110,200,40)
$DefenseSubcatHealthRegen = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Subcat.HealthRegen.jpg",115,175,200,40)
$DefenseSubcatArmor = GUICtrlCreatePic(".\..\LoL Recommended Builder\Images\Layout\Subcat.Armor.jpg",115,240,200,40)
GUISetState(@SW_HIDE)

Best regards

Share this post


Link to post
Share on other sites
Melba23

zvvyt,

That script looks very much as if it is game-related (League of Legends) - you have read the Forum Rules I take it? ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
zvvyt

That script looks very much as if it is game-related (League of Legends) - you have read the Forum Rules I take it? :)

It is correct, that game is made "for" League of Legends!

I dunno if you're a player yourself or not, but the meaning of this program is to make a visual solution for a function created by Riot games themselves.

I'll describe this in short:

Ingame each champion has got a "Recommended build", an item build that if you follow it you'll do "good" in game with that character.

There's a way of making your own "Recommended build" for whichever champion you'd like, but to do so you have to type all the specific item numbers and such into a .ini file, all this implemended by Riot Games.

It works outside of "LoL", so it's nothing really to do with the game itself, therefor I take it this is allowed to take up for discussion? ;)

More about this function can be read here: http://na.leagueoflegends.com/board/showthread.php?t=1177803 where their "tech support" explains how to do this yourself w/ the .ini and so ^__^

Best regards,

Share this post


Link to post
Share on other sites
Melba23

zvvyt,

I am not a gamer so I have no idea what you are talking about. I am locking this thread until I can find out more. Please accept my apologies in advance if this is an unnecessary precaution. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Valik

As long as this remains a purely GUI question I'm going to allow this. There's no manipulation of the game here. There's no manipulation of the INI file, either. As long as this discussion remains strictly on the GUI it's fine.

Share this post


Link to post
Share on other sites
PhoenixXL

You can create the ScrollBar this is the basic code

#include-once
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hParent=GUICreate('',400,500)
GUICtrlCreatePic('Tc3.jpg',0,0 ,400,500)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState(@SW_SHOW,$hParent)
$h_Child=GUICreate('',100,300,10,10,$WS_POPUP,$WS_EX_MDICHILD,$hParent)
GUISwitch($h_Child)
GUICtrlCreateEdit('',10,10,90,290)
GUISetState(@SW_SHOW,$h_Child)
Local $nMsg[1]
While $nMsg[0]<>-3
$nMsg=GUIGetMsg(1)
WEnd

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
zvvyt

First of all: Thank's for unlocking the thread! =)

You can create the ScrollBar this is the basic code

#include-once
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hParent=GUICreate('',400,500)
GUICtrlCreatePic('Tc3.jpg',0,0 ,400,500)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState(@SW_SHOW,$hParent)
$h_Child=GUICreate('',100,300,10,10,$WS_POPUP,$WS_EX_MDICHILD,$hParent)
GUISwitch($h_Child)
GUICtrlCreateEdit('',10,10,90,290)
GUISetState(@SW_SHOW,$h_Child)
Local $nMsg[1]
While $nMsg[0]<>-3
$nMsg=GUIGetMsg(1)
WEnd

By adding the $WS_POPUP,$WS_EX_MDICHILD to the child made it be ontop and in position, but it "flickers" a bit when it "popups". Is that avoidable? Or do I "have to live with it?"

And then to the child gui being transparent: Ain't that possible to achieve w/ GuiCtrlCreatePic and a transparent .GIF? Or do I need to use GDI+ and a transparent .png?

Share this post


Link to post
Share on other sites
PhoenixXL

Ain't that possible to achieve w/ GuiCtrlCreatePic and a transparent .GIF?

If u r dealing with GIF's then Tracexx UDF will sound helpful

herez the link :

but it "flickers" a bit when it "popups". Is that avoidable? Or do I "have to live with it?"

I dont see any flicker with my code

Regards

Phoenix XL


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
zvvyt

If u r dealing with GIF's then Tracexx UDF will sound helpful

herez the link :

Link seem to be broken, but found it by Google.

Can I recieve same transparent result with .GIF as with .PNG? First time dealing with this matter so I have no clue >__<

I dont see any flicker with my code

Could be becuase I'm having another GUI up before the parent and child one.

EDIT: Fixed by reorganizing the GuiSetState-commands

Best regards,

Edited by zvvyt

Share this post


Link to post
Share on other sites
martin

I haven't carefully read everything in this thread but I notice you keep referring to a transparent child. Transparent child windows are not so easy but you can do it in AutoIt if you have a child with the style $WS_EX_MDICHILD.

Here is a simple example

#include <windowsconstants.au3>
#include <winapi.au3>

$G1 = GUICreate("Parent")
GUICtrlCreateButton("quite a long button across the middle of the parent gui",20,200)
GUISetState()

$C1 = GUICreate("child",200,300,0,0,-1,bitor($WS_EX_MDICHILD, $WS_EX_LAYERED),$G1)
GUISetBkColor(0xacbdef);set the child background to some colour which we can set as the transparent colour
$btn1 = GUICtrlCreateButton("a button",20,50)
GUISetState()
_WINAPI_SetLayeredWindowAttributes($C1, 0xacbdef, 255)

sleep(9000)
  • Like 1

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
zvvyt

I haven't carefully read everything in this thread but I notice you keep referring to a transparent child. Transparent child windows are not so easy but you can do it in AutoIt if you have a child with the style $WS_EX_MDICHILD.

Here is a simple example

#include <windowsconstants.au3>
#include <winapi.au3>

$G1 = GUICreate("Parent")
GUICtrlCreateButton("quite a long button across the middle of the parent gui",20,200)
GUISetState()

$C1 = GUICreate("child",200,300,0,0,-1,bitor($WS_EX_MDICHILD, $WS_EX_LAYERED),$G1)
GUISetBkColor(0xacbdef);set the child background to some colour which we can set as the transparent colour
$btn1 = GUICtrlCreateButton("a button",20,50)
GUISetState()
_WINAPI_SetLayeredWindowAttributes($C1, 0xacbdef, 255)

sleep(9000)

Your code worked like a charm on the transparancy! =D

Now it's just that when I click on a picture control in the child gui, an earlier hidden window comes back visible ... Just by adding the

bitor($WS_EX_MDICHILD, $WS_EX_LAYERED

and

GUISetBkColor(0xacbdef) _WINAPI_SetLayeredWindowAttributes($C1, 0xacbdef, 255)

Feels quite strange for me that this could happen. Will have a deeper look into it tomorrow.

EDIT: By removing the style $ws_child and replace it with $ws_popup I got away from the problem where another window would pop up. Dunno how, dunno why. Could be that something collided when I used both $ws_child and $ws_ex_mdichild.

Thanks for all your help in this matter! =D Much appreciated!

Edited by zvvyt

Share this post


Link to post
Share on other sites
meows

Melba23

Melba23

Yes, me!

  • Posted Image
  • Moderators (Mod)
  • Posted Image
  • 11,757 posts
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted Today, 03:50 AM

meows,

Regardless of whether you wrote the game or not, the Forum Rules prohibit the discussion of any script which interacts with or launches a game. Your script does exactly that and so is not permitted here - this thread is now locked. :naughty:

Please make sure your future posts are within the rules. :)

M23

This is not fair. I got locked for asking how to make a graphic buttom user clickable and I built the game. Some folks have friends in higher places than I do.

But thanks for the questions and answers. I learned a bit.

Share this post


Link to post
Share on other sites
Melba23

meows,

This script did not interact with the game in any way as Valik makes quite clear:

There's no manipulation of the game here. There's no manipulation of the INI file, either

Your script by your own admission launches the game - which is prohibited under the Forum rules

Case $Icon1
        $Icon1= ShellExecuteWait("C:0aTestlvl3.exe", "","C:0aTest", "")
        ShellExecuteWait("C:0aTestChina2a.exe", "","C:0aTest", "")
EndSelect

That is the difference and that is why your thread was locked. :naughty:

And posting in another thread like this is not the way to make me change my mind. I will consider what to do with you during my drive home. :mad:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

meows,

I have now returned home, eaten and deliberated as to what I am going to do.

I have always made it clear that if I lock a thread I am quite prepared to listen to reasoned argument as to why I should not have done so. On several occasions - and this thread is a good case in point - the thread has indeed been reopened. But I will only reopen a thread if the OP can convince me that there is good reason to do so. In the thread to which you are referring you made it quite clear that the script was to launch a game - which is quite clearly prohibited under the Forum Rules. As I pointed out in the thread, it does not matter: if you wrote the game; if it is single player; if it is for your use only - the rules are quite clear:

"Do not discuss any of the following:

Automating games or game servers. This rule is zero tolerance. Any discussion of using AutoIt to launch or interact with a game or game server violates our rules"

As I stated in my earlier post, the script in this thread does not interact with the game while your script does - hence the difference in moderation. :mellow:

But you, instead of arguing reasonably, decide on an imflammatory post suggesting that there is favouritism and corruption with in the ranks of the Moderators. While I was quite prepared to let your initial thread pass by without imposing sanctions, I am not prepared to stand by while you attack the honour and integrity of those volunteers who give up their time to keep this forum the sort of place the majority of members wish it to be. If you cannot abide by the rules as set out by the forum owner and argue against those who enforce them - in as just a manner as they can - then you obviously forfeit your right to use the forum. :mad:

You will be unable to post for a month. When and if you return, either abide by the rules and show respect for those whose task it is to apply them or you will find yourself permanently removed. You have used up any shred of flexibility that I may have been prepared to show you - any attempt to PM me about this will result in an immediate block. :naughty:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
×