Jump to content

How to insert cursors images in combobox


Recommended Posts

I even understand that the Handle generated by _WinAPI_LoadCursor is not an Icon but how to display the image in the Combobox

Here is the listing and please tell me how to make the current user current cursor image uncertainty

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;dados de mouse
#include <WinAPIRes.au3>
;COMBO
#include <GuiComboBoxEx.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo
    Local $idListview, $hImage
    Local $sWow64 = ""
    Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur"

    $hGUI = GUICreate("ImageList Mouse Icons", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $idListview = GUICtrlCreateListView("", 2, 104, 394, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16)
    ;teste
    _GUIImageList_AddIcon($hImage, $Pasta)
    ;<<<<<<<<<<<<<<<<<<<<<this
    $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0,$IDC_HAND));32649 ; Hand cursor

        _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<<<<<<<< erro
    for $i=1 to 15
        $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $i));<<<<<<<<<<<<<<<<<
        _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<<
    Next
    _GUIImageList_AddIcon($hImage, $Pasta)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    $a=StringSplit("testeIcone|HAND|APPSTARTING|ARROW|CROSS|HELP|IBEAM|ICON|NO|SIZE|SIZEALL|SIZENESW|SIZENS|SIZENWSE|SIZEWE|UPARROW|WAIT|testefim","|")
    For $i=1 to $a[0]
    _GUICtrlListView_AddItem($idListview, $a[$i], $i-1)
    _GUICtrlComboBoxEx_AddString($hCombo,  $a[$i], $i-1)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Note that only the initial image is uncertain because it comes from a file
And the one that would be the last enters as the second
And the background is black how to transform into transparent

imagem de cursor.bmp

Link to post
Share on other sites

Something like this here?

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;dados de mouse
#include <WinAPIRes.au3>
;COMBO
#include <GuiComboBoxEx.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo
    Local $idListview, $hImage
    Local $sWow64 = ""
    Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur"

    $hGUI = GUICreate("ImageList Mouse Icons", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $idListview = GUICtrlCreateListView("", 2, 104, 394, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5)
    ;teste
    ;<<<<<<<<<<<<<<<<<<<<<this
    Local $aCursors[] = [ 32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514 ]
    for $i=0 to UBound($aCursors) - 1
        $hIcon = _WinAPI_LoadCursor(0, $aCursors[$i])
        If $hIcon Then
            _GUIImageList_ReplaceIcon($hImage, -1, $hIcon)
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    Next
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    $a=StringSplit("Standard arrow and small hourglass|Standard arrow|Crosshair|Hand|Arrow and question mark|I-beam|Slashed circle|Four-pointed arrow|Double-pointed arrow|Double-pointed arrow pointing|Double-pointed arrow|Double-pointed arrow|Vertical arrow|Hourglass","|")
    For $i=1 to $a[0]
    _GUICtrlListView_AddItem($idListview, $a[$i], $i-1)
    _GUICtrlComboBoxEx_AddString($hCombo,  $a[$i], $i-1)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
Share on other sites

Many thanks for the prompt reply ...
What would be the nubs if it was not the masters.

It worked in part.
Images of icons are added ... ok
But in the Combobox after choosing item the mouse image does not appear

; Load images
    $hImage = _GUIImageList_Create(32, 32, 6);16,16,5) ;aumentei o icone e mudei o Image color depth


Note that I increased the size of the icon and changed (Image color depth) to display the icon when the item is selected, since it was disappearing when selected.
I tried changing the background color but it did not work

mouse em combo.JPG

Link to post
Share on other sites

This code

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;dados de mouse
#include <WinAPIRes.au3>
;COMBO
#include <GuiComboBoxEx.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo
    Local $idListview, $hImage
    Local $sWow64 = ""
    Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur"

    $hGUI = GUICreate("ImageList Mouse Icons", 400, 310)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 200)
    $idListview = GUICtrlCreateListView("", 2, 50, 394, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 32, 5, 5);16,16,5) ;aumentei o icone e mudei o Image color depth
    ;teste
    ;<<<<<<<<<<<<<<<<<<<<<this
    Local $aCursors[] = [ 32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514 ]
    for $i=0 to UBound($aCursors) - 1
        $hIcon = _WinAPI_LoadCursor(0, $aCursors[$i])
        If $hIcon Then
            _GUIImageList_ReplaceIcon($hImage, -1, $hIcon)
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    Next
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    $a=StringSplit("Standard arrow and small hourglass|Standard arrow|Crosshair|Hand|Arrow and question mark|I-beam|Slashed circle|Four-pointed arrow|Double-pointed arrow|Double-pointed arrow pointing|Double-pointed arrow|Double-pointed arrow|Vertical arrow|Hourglass","|")
    For $i=1 to $a[0]
    _GUICtrlListView_AddItem($idListview, $a[$i], $i-1)
    _GUICtrlComboBoxEx_AddString($hCombo,  $a[$i], $i-1, $i-1)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

looks like this in my Win7 VM

Combo_Icon.png
 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
Share on other sites

I did not imagine that a simple problem could cause so many changes.

I noticed the subtle changes from the previous code and again this is a genius thing.

But notice the icons of Cross and Iben, they are invisible because they are white and without any contour.

I again changed the _GUIImageList_Create (32, 32, 6, 2) function where the black background did display the invisible lines with white background.

Could it be that with your experience it would be possible to change the black color to a blue background at least for a better look ....

 

Another issue:

For a better visualization I adopted as a pad the 32x32 size that seems to be the normal one of the cursor and with that I thought by well increase the font for size 14.

GUISetFont (14,400,0, "Arial")

Behold, the combobox did not accept it.

Not even using GUICtrlSetFont ($ hCombo, 14, 400, 0, "Arial")

So I snoozed the _GUICtrlComboBoxEx_Create function and noticed that it uses:

_WinAPI_SetFont ($ hCombo, _WinAPI_GetStockObject ($ __ COMBOBOXCONSTANT_DEFAULT_GUI_FONT))

In your code and thanks to the link:

How to change font of ComboBoxEx

I solved the mystery by unscrambling a font of size 30 in pixels to have the desired look

Here are the latest changes:

 

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;dados de mouse
#include <WinAPIRes.au3>
;COMBO
#include <GuiComboBoxEx.au3>
;Fonts
#include <FontConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo, $hFont
    Local $idListview, $hImage
    Local $sWow64 = ""
    Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur"

    $hGUI = GUICreate("ImageList Mouse Icons", 500, 310)

    GUISetFont(14, 400, 0, "Arial");<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create

    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200)
    ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work
    ;
    ;Create a handle to a font object
    $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
    ;Pass the handle to _WinAPI_SetFont
    _WinAPI_SetFont($hCombo, $hFont)

    $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 32, 6, 2) ;32,32,5,5) ;  ;<<<<<<<<<<<<<<<<<<<<<this
    Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514]
    For $i = 0 To UBound($aCursors) - 1
        $hIcon = _WinAPI_LoadCursor(0, $aCursors[$i])
        If $hIcon Then
            _GUIImageList_ReplaceIcon($hImage, -1, $hIcon)
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    Next

    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350)


    ; Add items
    $a = StringSplit("Standard arrow and small hourglass|Standard arrow|Crosshair|Hand|Arrow and question mark|I-beam|Slashed circle|Four-pointed arrow|Double-pointed arrow|Double-pointed arrow pointing|Double-pointed arrow|Double-pointed arrow|Vertical arrow|Hourglass", "|")
    For $i = 1 To $a[0]
        _GUICtrlListView_AddItem($idListview, $a[$i], $i - 1)
        _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $i - 1, $i - 1);<<<<<<<<<<<<<<<<<<<<this is just for geniuses
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

I suggest that this source detail can be corrected or exemplified within the autoit help

 

I look forward to the new genius idea to partially solve the background color problem.

Preferably using GetSysColor

 

Link to post
Share on other sites

Here the version to change the background color

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;dados de mouse
#include <WinAPIRes.au3>
;COMBO
#include <GuiComboBoxEx.au3>
;Fonts
#include <FontConstants.au3>
;background color
#include <GDIPlus.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo, $hFont
    Local $idListview, $hImage
    Local $sWow64 = ""
    Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur"

    $hGUI = GUICreate("ImageList Mouse Icons", 500, 310)

    GUISetFont(14, 400, 0, "Arial");<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create

    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200)
    ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work
    ;
    ;Create a handle to a font object
    $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
    ;Pass the handle to _WinAPI_SetFont
    _WinAPI_SetFont($hCombo, $hFont)

    $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    ; Load images
    Local $iW = 32, $iH = 32, $iBgColor1 = 0xFFE0E0, $iBgColor2 = BitShift(BitAND(0xFF, $iBgColor1), -16) + BitAND(0xFF00, $iBgColor1) + BitShift(BitAND(0xFF0000, $iBgColor1), 16)
    $hImage = _GUIImageList_Create($iW, $iH, 5) ;32,32,5,5) ;  ;<<<<<<<<<<<<<<<<<<<<<this
    Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514]
    $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GUIImageList_SetBkColor ( $hImage, $iBgColor1) ;BGR
    For $i = 0 To UBound($aCursors) - 1
        $hIcon = _WinAPI_LoadCursor(0, $aCursors[$i])
        If $hIcon Then
            Switch $aCursors[$i]
                Case 32513, 32515
                    _GUIImageList_ReplaceIcon($hImage, -1, $hIcon)
                Case Else
                    $hImg = _GDIPlus_BitmapCreateFromHICON32($hIcon) ;convert the cursor to a bmp
                    _GDIPlus_GraphicsClear($hGfx, 0xFF000000 + $iBgColor2) ;ARGB
                    _GDIPlus_GraphicsDrawImageRect($hGfx, $hImg, 0, 0, $iW, $iH)
                    $hIconNew = _GDIPlus_HICONCreateFromBitmap($hBmp)
                    _GUIImageList_ReplaceIcon($hImage, -1, $hIconNew)
                    _WinAPI_DestroyIcon($hIconNew)
                    _GDIPlus_ImageDispose($hImg)
            EndSwitch
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    Next
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_ImageDispose($hBmp)

    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350)


    ; Add items
    $a = StringSplit("Standard arrow and small hourglass|Standard arrow|Crosshair|Hand|Arrow and question mark|I-beam|Slashed circle|Four-pointed arrow|Double-pointed arrow|Double-pointed arrow pointing|Double-pointed arrow|Double-pointed arrow|Vertical arrow|Hourglass", "|")
    For $i = 1 To $a[0]
        _GUICtrlListView_AddItem($idListview, $a[$i], $i - 1)
        _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $i - 1, $i - 1);<<<<<<<<<<<<<<<<<<<<this is just for geniuses
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Also for those two cursors (standard arrow and I-beam).

Edited by UEZ
Update

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AFrenchCroissant
      Hello,
      i would like to know why isnt anything displayed on the combo box. i used this example and added it to my code
      Autoit Example :
      #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Dim $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" GUICreate("Test", 400, 100) $cCombo_Font = GUICtrlCreateCombo("", 10, 10, 170, 20, 2097474);HELPHERE GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey)) $cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cCombo_Font GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font)) EndSwitch WEnd Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal And my code:
      #NoTrayIcon #include <Misc.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <String.au3> #include <GuiRichEdit.au3> #include <GuiToolbar.au3> #include <GuiImageList.au3> $WIDTH = 500 $HEIGHT = 380 $EXT1 = "|Rich Text File (*.rtf)" $EXT2 = "|ODF Text (*.odt)" $EXT3 = "|All Files(*.*)" $EXT = $EXT1 & $EXT2 $SETTINGS = "Settings.ini" Dim $FONTKEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" Global $FILESAVE, $FILEOPEN = "", $SAVES, $SAVE, $FILEOPENED = 0 Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp $MAINGUI = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE) $TOOLBAR = _GUICtrlToolbar_Create($MAINGUI) _GUIImageList_AddIcon($TOOLBAR, @SystemDir & "\shell.dll", -1) $IMAGES = _GUIImageList_Create(24,24) _GUICtrlToolbar_SetImageList($TOOLBAR, $IMAGES) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -1);AndHereIfYouCouldTHX _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -2) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 3) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 4) _GUICtrlToolbar_AddButtonSep($TOOLBAR) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 5) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 6) $EDITBOX = _GUICtrlRichEdit_Create($MAINGUI, "This is a test.", 10, 35, $WIDTH - 20, $HEIGHT - 70, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $FONTCOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, 2097474);HELPMEHERE GUICtrlSetData($FONTCOMBOBOX, _RegEnumVal($FONTKEY));ALSOHERE $FONTSIZECOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, 2097474);FuncForPreviousLineAtTheEnd $FILE = GUICtrlCreateMenu("File") $NEW = GUICtrlCreateMenuItem("New", $FILE) $OPEN = GUICtrlCreateMenuItem("Open...", $FILE) $SAVE = GUICtrlCreateMenuItem("Save", $FILE) $SAVEAS = GUICtrlCreateMenuItem("Save As...", $FILE) $PRINT = GUICtrlCreateMenuItem("Print...", $FILE) GUICtrlCreateMenuItem("", $FILE) $EXIT = GUICtrlCreateMenuItem("Exit", $FILE) $EDIT = GUICtrlCreateMenu("Edit") $UNDO = GUICtrlCreateMenuItem("Undo", $EDIT) $REDO = GUICtrlCreateMenuItem("Redo", $EDIT) $SEPARATOR = GUICtrlCreateMenuItem("", $EDIT) $FONT = GUICtrlCreateMenuItem("Font test", $EDIT) $SEPARATOR1 = GUICtrlCreateMenuItem("", $EDIT) $CUT = GUICtrlCreateMenuItem("Cut", $EDIT) $COPY = GUICtrlCreateMenuItem("Copy", $EDIT) $PASTE = GUICtrlCreateMenuItem("Paste", $EDIT) GUISetState(@SW_SHOW & $GUI_ACCEPTFILES) While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop Exit EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $OPEN $FILEOPEN = FileOpenDialog("Open", $FILEOPEN, $EXT) $TEXT = _GUICtrlRichEdit_StreamFromFile($EDITBOX, $FILEOPEN) _GUICtrlRichEdit_ReplaceText($EDITBOX, $TEXT) $FILEOPENED = 1 Case $Msg = $NEW If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) EndIf If $SAVECHANGES = 7 Then GUICtrlSetData($EDITBOX, "") If $SAVECHANGES = 2 Then Sleep(1) EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then GUICtrlSetData($EDITBOX, "") $FILEOPENED = 0 Case $Msg = $EXIT If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop If $SAVECHANGES = 2 Then Sleep(1) EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $SAVEAS GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 1 FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) _GUICtrlEdit_EmptyUndoBuffer($EDITBOX) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $PRINT $PRINTMSGBOX = MsgBox(35, "Text Editor", "Are you sure you want to print this page?") Select Case $PRINTMSGBOX = 6 If FileExists("Print.txt") Then FileDelete("Print.txt") EndIf FileWrite("Print.txt", GUICtrlRead($EDITBOX)) $PRINTFILE = "Print.txt" _FilePrint($PRINTFILE) FileDelete($PRINTFILE) EndSelect Case $Msg = $UNDO _GUICtrlRichEdit_Undo($EDITBOX) Case $Msg = $REDO _GUICtrlRichEdit_Redo($EDITBOX) Case _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 1 GUICtrlSetState($SAVE, $GUI_ENABLE) Case $Msg = $CUT _GUICtrlRichEdit_Cut ($EDITBOX) Case $Msg = $COPY _GUICtrlRichEdit_Copy ($EDITBOX) Case $Msg = $PASTE _GUICtrlRichEdit_Paste ($EDITBOX) Case Not _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 0 GUICtrlSetState($SAVE, $GUI_DISABLE) $SAVES = 1 Case $Msg = $FONT _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, "Times New Roman") Case $FONTCOMBOBOX _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, GUICtrlRead($FONTCOMBOBOX)) EndSelect WEnd Exit Func SaveAs() $FILESAVEAS = FileSaveDialog("Save As", "", "Text Document (*.txt)|All Files (*.*)") If Not @error Then $STRING = StringSplit($FILESAVEAS, ".") If $STRING[0] = 1 Then FileDelete($FILESAVEAS) _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") Else _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") EndIf EndIf EndFunc Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal So the problem is that
      The second combo box is blank Icons in taskbar are not appearing (don't really care for now, .dll file for icon in attachement) problem with $FONTCOMBOBOX = GUICtrlCreateCombo("", 10, 10, 200, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL) (BitOR gave me a weird error)
      Thanks !
      Autoit newbie
      ico.dll
    • By ute_man
      Hi Forum,
      I am struggling to select an IP address from "Server Interface" dropdown (ComboBox2) of tftpd32 client.
      tftpd32 is a TFTP server - TFTPD32 : an opensource IPv6 ready TFTP server/service for windows : TFTP server (pagesperso-orange.fr)
      The IP addresses (and the associated interfaces) are dynamic in ComboBox2.
      What I want to do is to select an item from ComboBox2 which contains a given IP address (eg. 192.168.2.1) - (which is hidden in the picture as it is at the bottom of the list) and fill the edit field with the selection. (Note : the ComboBox items contain the IP address and the Interface name, therefore IP address is just a part of the item)
      I am not sure whether functions such as _GUICtrlComboBox_SelectString() are only to be used with Autoit generated ComboBoxes.
      Please help !!!!
      My code below, it does not select the ComboBox2 item with my IP address 192.168.2.1.
      Local $hWnd=ControlGetHandle("Tftpd32 by Ph. Jounin", "", 4008) Sleep(100) ControlFocus("Tftpd32 by Ph. Jounin", "", $hWnd) Sleep(100) Local $IP = "192.168.2.1" _GUICtrlComboBox_SelectString($HWnd, $IP) ComboBox2 ID = 4008


    • By Colduction
      Hi, i have a source code of "Danny35d" and i have 2 main question that are:
       How to extract this function's results (Datas are as Array) to combo-box without set number of datas?  When i type 1, 2 in _SystemUsers($AccountType = 0) to get only Local or Domain users, it just give me both of them, it's old problem of this function, please share us debugged code :)❤ #include <Array.au3> $Users = _ArrayToString(_SystemUsers(), "|", 1) ConsoleWrite($Users & @CRLF) #cs =============================================================================== Function: _SystemUsers($AccountType = 0) Description: Return an array with the local or domain username Parameter(s): $AccountType: Local, domain or both username 0 = Local and Domain usernames 1 = Local usernames only 2 = Domain usernames only Returns: An array with the list of usernames - Succeeded @error 1 - Didn't query any username @error 2 - Failed to create Win32_SystemUsers object @error 3 - Invalid $AccountType Author(s): Danny35d #ce =============================================================================== Func _SystemUsers($AccountType = 0) Local $aSystemUsers Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems = "", $strComputer = "localhost" If Not StringRegExp($AccountType, '[012]') Then Return SetError(3, 3, '') $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemUsers", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = StringSplit($objItem.PartComponent, ',') If IsArray($Output) Then $Temp = StringReplace(StringTrimLeft($Output[2], StringInStr($Output[2], '=', 0, -1)), '"', '') If $AccountType = 0 Or ($AccountType = 1 And @ComputerName = $Temp) Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' ElseIf $AccountType = 2 And @ComputerName <> $Temp Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' EndIf EndIf Next $aSystemUsers = StringTrimRight($aSystemUsers, 1) If $aSystemUsers = '' Then Return(SetError(1, 1, $aSystemUsers)) Return(SetError(0, 0, StringSplit($aSystemUsers, '|'))) Else $aSystemUsers = '' Return(SetError(2, 2, $aSystemUsers)) EndIf EndFunc ;==>_SystemUsers Thanks to your best Team.
    • By DannyJ
      Hello Forum, 
      I have one special Combo-box [with BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE) ] and if I press one button I want to change the Combo-box's background color, and after I press Button B I want to change it to the basic settings and it not works.
      I wanna do this with one combo-box.
      I have already tried several methods and I tried  GUICtrlComboSetColors that I have found on this forum.
      (But this methods works perfectly with Cobo boxes that don't have BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE). 
      Here is the example code
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= ;$CBS_DROPDOWNLIST ;$GUI_SS_DEFAULT_COMBO $Form1 = GUICreate("Form1", 504, 249, 252, 227) $Combo1 = GUICtrlCreateCombo("", 136, 24, 193, 25,BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; I want to change this special combo's background color if I press button 1 $Button1 = GUICtrlCreateButton("Button1", 112, 96, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 264, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Combo1," " & "|" & "apple" & "|" & "banana" & "|" & "cherry" ," ") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetBkColor($Combo1,0x0078D7) Case $Button2 ;Makes the original bc color GUICtrlSetBkColor($Combo1,0xFFFFFF) EndSwitch WEnd  
      Thanks you in advance your help
    • 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?
×
×
  • Create New...