Jump to content

Recommended Posts

Posted

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

 

  • Moderators
Posted

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

 

Posted

$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

Posted
#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

Posted

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.

  • Moderators
Posted

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

 

Posted

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?

 

  • Moderators
Posted

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

 

Posted

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.

Posted (edited)

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
  • Moderators
Posted

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

 

  • 4 weeks later...
Posted

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

 

  • Moderators
Posted

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

 

Posted

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.

Posted

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?

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
×
×
  • Create New...