Jump to content
Sign in to follow this  
AndreyS

The problem with using styles GUICtrlCreatePic

Recommended Posts

Tell me, please, why in the application of different styles($SS_BLACKFRAME, $SS_BLACKRECT, etc.) of frames stops working function Msg().

And why in the application of certain frame styles($SS_BLACKFRAME) do not even picture displayed?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1)

Example()

Func Example()
    GUICreate("My GUI picture", 350, 300, -1, -1) ; will create a dialog box that when displayed is centered
    GUISetOnEvent($GUI_EVENT_CLOSE,"Quit")

    $idPic = GUICtrlCreatePic("D:\Program Files\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 200, 50, $SS_SUNKEN)
    GUICtrlSetOnEvent(-1,"Msg")

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1

    WEnd


EndFunc   ;==>Example

Func Msg()
    MsgBox(0,0,0)
EndFunc

Func Quit()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites

AndreyS,

When you specify styles when creating a control you overwrite the default styles set by AutoIt. For a picture control, the default style is $SS_NOTIFY, so by only specifying another style you remove that style and so will not get notification of a click. By re-adding the style, the script works as you require:

$idPic = GUICtrlCreatePic("M:\Program\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 200, 50, BitOr($SS_SUNKEN, $SS_NOTIFY))

The Setting Styles tutorial in the Wiki explains in more detail.

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

Ah, that's it! Thank you, Melba23!

And why in the application of certain frame styles($SS_BLACKFRAME) do not even picture displayed?

 

Share this post


Link to post
Share on other sites

$SS_BLACKFRAME is just a frame around the picture control, you can't specify a picture or text inside it. You have to create 2 different controls in the same area if you want to use a frame or RECT style.


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

Share this post


Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Example()

Func Example()
    GUICreate("My GUI picture", 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered

    GUISetBkColor(0xE0FFFF)
    Local $idPic = GUICtrlCreatePic("E:\Release\AutoIt3\Examples\GUI\Advanced\Images\green.bmp", 50, 50, 200, 50) ; change this path according to where you have autoit installed
    GUICtrlCreateLabel("", 50, 50, 200, 50, $ss_blackframe)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    GUIDelete()
EndFunc   ;==>Example

This should do it.


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

Share this post


Link to post
Share on other sites

Thank you, BrewManNH, for your example!
It turns out that this style is no point to use with the Picture? It applies only to Label?

Tell me then, please, how can I when you click on the picture highlight it in some way? The frame, brightness, or opacity change it. To make it visible that the user clicks on it.

Share this post


Link to post
Share on other sites

AndreyS,

I always use an underlaid label like this:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cHiLite_1 = GUICtrlCreateLabel("", 5, 5, 110, 110)
GUICtrlSetState($cHiLite_1, $GUI_DISABLE)
$cButton_1 = GUICtrlCreateLabel("Press me 1", 10, 10, 100, 100)
GUICtrlSetBkColor($cButton_1, 0xCCFFCC)
$cHiLite_2 = GUICtrlCreateLabel("", 155, 5, 110, 110)
GUICtrlSetState($cHiLite_2, $GUI_DISABLE)
$cButton_2 = GUICtrlCreateLabel("Press me 2", 160, 10, 100, 100)
GUICtrlSetBkColor($cButton_2, 0xCCFFCC)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            GUICtrlSetBkColor($cHiLite_1, 0xFF0000)
            GUICtrlSetBkColor($cHiLite_2, 0xFEFEFE)
        Case $cButton_2
            GUICtrlSetBkColor($cHiLite_2, 0xFF0000)
            GUICtrlSetBkColor($cHiLite_1, 0xFEFEFE)
    EndSwitch

WEnd

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, thank you for the example of a good and clear!
But I really need to organize the allocation without additional controls. Only by using the properties and styles control Picture.

There is a possibility?

 

Share this post


Link to post
Share on other sites

AndreyS,

Not as far as I know - which is why I suggested the underlaid labels.

Why do you not want the added controls? With a couple of helper functions it is really easy to code:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cButton_1 = _CreateButton("Press me 1", 10, 10, 100, 100)
$cButton_2 = _CreateButton("Press me 2", 150, 10, 100, 100)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            _ColourBorder($cButton_1, 0xFF0000)
            _ColourBorder($cButton_2, 0xFEFEFE)
        Case $cButton_2
            _ColourBorder($cButton_2, 0xFF0000)
            _ColourBorder($cButton_1, 0xFEFEFE)
    EndSwitch

WEnd

Func _CreateButton($sText, $iX, $iY, $iW, $iH, $iB = 5)

    Local $cHilite = GUICtrlCreateLabel("", $iX - $iB, $iY - $iB, $iW + ($iB * 2), $iH + ($iB * 2))
    GUICtrlSetState($cHilite, $GUI_DISABLE)
    Local $cButton = GUICtrlCreateLabel($sText, $iX, $iY, $iW, $iH)
    GUICtrlSetBkColor($cButton, 0xCCFFCC)
    Return $cButton

EndFunc

Func _ColourBorder($cCID, $iColour)

    GUICtrlSetBkColor($cCID - 1, $iColour)

EndFunc

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

Yes, I see it clearly and simply.
I did not want to add additional controls, as I have, and so the program contains a lot of controls (they probably already a few hundred). In order to once again not to load it, and not take up resources.

Share this post


Link to post
Share on other sites

Melba23,i realized that really the best use label for my task. Thus the frame can be made of any thickness and color. And in order not to create Label under each picture, I just move this Labelle when clicked by function GUICtrlSetPos().


Thank you all for your active support!

Edited by AndreyS

Share this post


Link to post
Share on other sites

AndreyS,

Quote

 I just move this Labelle when clicked by function GUICtrlSetPos().

An interesting solution. Glad you got it sorted.

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

An additional problem I have with this control.
Can you please tell how to make the picture does not change the size of $ idPic?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ScreenCapture.au3>


Opt("GUIOnEventMode", 1)

Example()

Func Example()
    Global $form=GUICreate("My GUI picture", 350, 300, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"Quit")

    Global $idPic = GUICtrlCreatePic("", 50, 50, 250, 200)
    GUICtrlSetOnEvent(-1,"Msg")

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1

    WEnd

EndFunc   ;==>Example

Func Msg()
    GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, _ScreenCapture_Capture(""))
EndFunc

Func Quit()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites

AndreyS,

I think you will need GDI to set the picture to the correct size before loading it - I am sure UEZ has shown how to do this somewhere.

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

I decide it this way, but not to understand why control $idPic is so weird ?!

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ScreenCapture.au3>


Opt("GUIOnEventMode", 1)

Example()

Func Example()
    Global $form=GUICreate("My GUI picture", 350, 300, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"Quit")

    Global $idPic = GUICtrlCreatePic("", 50, 50, 250, 200)
    GUICtrlSetOnEvent(-1,"Msg")

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1

    WEnd

EndFunc   ;==>Example

Func Msg()
    Local $arPosPicPres = ControlGetPos($form,"", $idPic)
    GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, _ScreenCapture_Capture(""))
    GUICtrlSetPos($idPic,$arPosPicPres[0],$arPosPicPres[1],$arPosPicPres[2]-1, $arPosPicPres[3])
    GUICtrlSetPos($idPic,$arPosPicPres[0],$arPosPicPres[1],$arPosPicPres[2]+1, $arPosPicPres[3])
EndFunc

Func Quit()
    Exit
EndFunc


As it is easier and do the right thing? This method also does not work. When many times installed image, the control $idPic somehow reduces its size.

Share this post


Link to post
Share on other sites

If no one knows how to solve it. So tell me why it is at least strange behavior GUICtrlSetPos() applied to the $idPic? Why suddenly change the size of $idPic?

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By cdeb
      How can you select the specific style of a font with multiple * .otf files?
      The font in question has several files:
       
      Thin Thin Italic Extra-Light Extra-Light Italic Light Light Italic Regular Regular Italic Medium Medium Italic Semi-Bold Semi-Bold Italic Bold Bold Italic Extra-Bold Extra-Bold Italic Black Black Italic But after doing several tests I can recall the font like this, without being able to specify the precise style:
      Local $hFamily = _GDIPlus_FontFamilyCreate("Poppins") ; Local $hFont = _GDIPlus_FontCreate($hFamily, 95, 1+2, 3) ; Example I cannot therefore select "Poppins Black Italic"
      but only "Poppins" 
      Thank you

    • By therks
      So normally you can use the arrow keys in a GUI to walk through all the controls, not unlike the tab key. But I recently realized that if you put a Pic control in the midst of your normal controls it interrupts the ability to move through the controls (the tab key still works). I really liked the arrow key functionality, and I'm wondering if there's a way to restore that capability without capturing and processing the arrow keys manually, or just moving the Pic creation to a different part of the code.
      I've whipped up a bit of code with some examples:
      #include <GUIConstants.au3> $sPic = StringLeft(@AutoItExe, StringInStr(@AutoItExe, '\', 0, -1)) & '\Examples\GUI\logo4.gif' ; This is the normal behaviour I'd like to keep. GUICreate('Good Example', 250, 150, @DesktopWidth/2 - 250) GUICtrlCreateButton('Button', 50, 0, 200, 30) GUICtrlCreateButton('Button', 50, 30, 200, 30) GUICtrlCreateButton('Button', 50, 60, 200, 30) GUICtrlCreateButton('Button', 50, 90, 200, 30) GUICtrlCreateButton('Button', 50, 120, 200, 30) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() ; This is the bad behaviour I'd like to avoid. GUICreate('Example 2', 250, 150, @DesktopWidth/2 - 250) GUICtrlCreatePic($sPic, 0, 0, 50, 30) GUICtrlCreateButton('Button', 50, 0, 200, 30) GUICtrlCreatePic($sPic, 0, 30, 50, 30) GUICtrlCreateButton('Button', 50, 30, 200, 30) GUICtrlCreatePic($sPic, 0, 60, 50, 30) GUICtrlCreateButton('Button', 50, 60, 200, 30) GUICtrlCreatePic($sPic, 0, 90, 50, 30) GUICtrlCreateButton('Button', 50, 90, 200, 30) GUICtrlCreatePic($sPic, 0, 120, 50, 30) GUICtrlCreateButton('Button', 50, 120, 200, 30) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() ; This is almost what I want, but notice it doesn't "loop" around like the first example. ; And also having to create the pictures out of sequence with the buttons is not ideal. GUICreate('Example 3', 250, 150, @DesktopWidth/2 - 250) GUICtrlCreateButton('Button', 50, 0, 200, 30) GUICtrlCreateButton('Button', 50, 30, 200, 30) GUICtrlCreateButton('Button', 50, 60, 200, 30) GUICtrlCreateButton('Button', 50, 90, 200, 30) GUICtrlCreateButton('Button', 50, 120, 200, 30) GUICtrlCreatePic($sPic, 0, 0, 50, 30) GUICtrlCreatePic($sPic, 0, 30, 50, 30) GUICtrlCreatePic($sPic, 0, 60, 50, 30) GUICtrlCreatePic($sPic, 0, 90, 50, 30) GUICtrlCreatePic($sPic, 0, 120, 50, 30) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() The first GUI that opens demonstrates the behaviour I like. The second GUI demonstrates the problem. The third GUI is almost a solution, but the focus won't wrap around (eg: You can't just hold the down arrow and have the focus loop through the buttons, it sticks at the end). Also creating the pic controls out of sequence with the buttons makes my code harder to read.
    • By Reher
      Hi
      so i ran into a Problem i didn't expect to get stuck on.
      It sounds simple (and probably is) but i can't seem to get it to work
      So i created a Combobox and filled it with some things from an array which worked fine.
      $combobox = GUICtrlCreateCombo($list[0], 160, 200, 265, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GuiCtrlSetData($list, "|" & _ArrayToString($list,Default,1),$list[2]) GUICtrlSetFont(-1, 9, 400, 0, "Arial") Now i want to change the style of the combobox from $CBS_DROPDOWN to $CBS_DROPDOWNLIST via a checkbox.
      $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 160, 96, 105, 25) Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Call ("Read_only") Else Call ("Edit") Endif Func Read_only() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOWNLIST) EndFunc Func Edit() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOW) EndFunc I tried using $CBS_DROPDOWN and $CBS_DROPDOWNLIST but it simply does nothing.
      I also tried $ES_READONLY which kinda worked, it changed the combobox so i couldn't change the input via dropdown anymore but i could still type in it via keyboard (which i dont want).
      It's essential that its Editable but once the checkbox is checked the combobox becomes readonly so you can't type in it anymore but you can still choose between the items in the list. (It does not have to save your current input if you write something in it and then check the Checkbox it would be best if it would simpy jump back to the first item in the list)
      Im sure this is a simple thing but after long google search im tired of my stupidity can someone give me a push in the right direction?
    • By Mannyfresh31
      Hello everybody I need help with Opt("GUIOnEventMode",1) 
      I Normally use GUIGetMsg() but I want to learn how GUIOnEventMode works so I created a little test GUI the start button works fine and everything but the problem is that the stop button won't work down below is the code  I made and I'm wondering if someone with experience can explain me and the rest o newbies how it works and also if can post the code already fixed
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Stop = False $X=1 $i = 0 Opt("GUIOnEventMode",1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 579, 212, 192, 124) Global $Button1 = GUICtrlCreateButton("Stop", 432, 136, 75, 25) Global $Button2 = GUICtrlCreateButton("Start", 96, 136, 75, 25) Global $Progress1 = GUICtrlCreateProgress(24, 40, 526, 49) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetOnEvent ($GUI_EVENT_CLOSE, "_exit",$Form1 ) GUICtrlSetOnEvent($Button1,"_Stop") GUICtrlSetOnEvent($Button2,"DecreaseAndIncrement") While 1 sleep(500) WEnd Func _Stop () $Stop = True EndFunc Func _exit () Exit EndFunc Func DecreaseAndIncrement () $Stop = False While $Stop = False $i+=$X ;ConsoleWrite($i & @CRLF) GUICtrlSetData($Progress1,$i) Sleep(80) if $i = 105 Then $X = -1 if $i = 0 Then $X = 1 WEnd EndFunc  
       
      here is the version that works with GUIGetMsg()
       
       
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Stop = False $X=1 $i = 0 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 579, 212, 192, 124) Global $Button1 = GUICtrlCreateButton("Stop", 432, 136, 75, 25) Global $Button2 = GUICtrlCreateButton("Start", 96, 136, 75, 25) Global $Progress1 = GUICtrlCreateProgress(24, 40, 526, 49) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 DecreaseAndIncrement () case $Button1 $Stop = True EndSwitch WEnd Func DecreaseAndIncrement () $Stop = False While $Stop = False $i+=$X ;ConsoleWrite($i & @CRLF) GUICtrlSetData($Progress1,$i) Sleep(80) if $i = 105 Then $X = -1 if $i = 0 Then $X = 1 $nMsg2 = GUIGetMsg() Switch $nMsg2 Case $GUI_EVENT_CLOSE Exit case $Button1 $Stop = True EndSwitch WEnd EndFunc  
       
       
       
       
       
       
    • By nacerbaaziz
      Hello
      Dear Sirs, I have a question please
      About UPDown ctrl
      Where I want to adjust its format
      For example, I want to create a window to set the clock like the window in the system
      Can this be done?
      here's the example
      ______

      #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <UpDownConstants.au3> goto() func Goto() local $wGoto = GUICreate("go to spissific position", 250, 180, @DesktopWidth / 2 - 192, @DesktopHeight / 2 - 235, -1) GUICtrlCreateLabel("please write a corect position to go to it", 50, 10, 220, 20) GUICtrlCreateLabel("hours", 0, 80, 100, 30) local $Inp1 = GUICtrlCreateInput("00", 0, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp1, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 23, 0) GUICtrlCreateLabel("minuts", 110, 80, 100, 30) local $Inp2 = GUICtrlCreateInput("00", 110, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp2, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) GUICtrlCreateLabel("seconds", 220, 80, 100, 30) local $Inp3 = GUICtrlCreateInput("00", 220, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp3, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) local $Ok = GUICtrlCreateButton("&ok", 0, 150, 50, 30, 0x01) local $cancel = GUICtrlCreateButton("&cancel", 200, 150, 50, 30) GUISetState(@sw_show, $WgoTo) while 1 switch GUIGetMSG() case $GUI_Event_Close, $cancel exit case $OK local $read1 = GUICtrlRead($inp1) if $read1 >= 1 then $Read1 = ($Read1*60)*60 local $read2 = GUICtrlRead($inp2) if $read2 >= 1 then $Read2 = $Read2*60 local $read3 = GUICtrlRead($inp3) GUIDelete($WgoTo) Return $read1+$read2+$read3 exit endSwitch Wend EndFunc
      ________
      What I need is to be the contents of the inputs as follows when i change the value of the UPDown CTRL
      00
      01
      02
      03
      ...
       
×
×
  • Create New...