Jump to content

TrayCreateItem (can you popup a pic?)


 Share

Recommended Posts

Looked around, but could not find anything, and thought I would just ask if it was possible. Looking to pop a png or jpg file on hover over a TrayCreateItem - is that possible (similar to HTML, where you hover over an item, and either a larger pic or a different pic shows while hover (just as a reference to what I am looking to achieve)?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

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 comment
Share on other sites

I am looking at that, but having some issues with it, as I do not have a GUI, it is all in the tray. I have got it to pop to the center, but after that it just stays there - I think if I change the GUICreate, so that it has a exit button it may work...still looking into it - thanks for the link

 

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I do not believe I have created what I want, but here is as far as I got...

 

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Opt("MustDeclareVars", 1)
Opt("TrayMenuMode", 3)


Global Const $STM_SETIMAGE = 0x0172
Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
Global $sImage1 = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\msoobe.jpg"
Global $sImage2 = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\Torus.png"

Global $hGui_PreviewSize = 200, $iBGColor = 0xF0F0F0

Global $aMouseInfo, $aPosCtrl, $aPosWin, $hBmp_Tmp, $sFile, $bShow = False, $bHide = False

_GDIPlus_Startup()
TrayCreateItem("")
Global $tmPhone = TrayCreateMenu('PHONE DOCS')
TrayCreateItem('ONCALL List', $tmPhone)
Global $t101 = TrayCreateItem('101', $tmPhone)
;TrayItemSetState(-1, $GUI_DISABLE)
Global $tSOP = TrayCreateItem('SOP', $tmPhone)
;TrayItemSetState(-1, $GUI_DISABLE)
Global $tEXIT = TrayCreateItem('Exit', $tmPhone)
;TrayItemSetState(-1, $GUI_DISABLE)

Global $hGui_Preview = GUICreate("", $hGui_PreviewSize, $hGui_PreviewSize + 58, -1, -1, -1, $WS_EX_TOPMOST) ;$WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST)
Global $idPic = GUICtrlCreatePic("", 0, 0, $hGui_PreviewSize, $hGui_PreviewSize)
Global $idLabel_Info = GUICtrlCreateLabel("", 0, $hGui_PreviewSize + 8, $hGui_PreviewSize * 2, 50)
GUICtrlSetFont(-1, 9, 400, 0, "Arial", 5)
GUICtrlSetColor(-1, $iBGColor)
GUICtrlSetBkColor(-1, 0x222222)
GUISetState(@SW_HIDE, $hGui_Preview)

Global $hGui_PreviewSize = 200, $iBGColor = 0xF0F0F0

While 1
    Switch TrayGetMsg()
        Case $tSOP
            ConsoleWrite('fadfadf')
            ;MsgBox('','','')
            ShowPreview($sImage1, $tSOP)
        Case $tEXIT
            ;If $hBmp_Tmp Then _WinAPI_DeleteObject($hBmp_Tmp)
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func ShowPreview($sFile, $iCtrl = '')
    ;$aPosWin = WinGetPos($tmPhone)
    $aPosCtrl = ControlGetPos($tmPhone, "", $iCtrl)
    _ArrayDisplay($aPosCtrl)
    ;WinMove($tmPhone, "", $aPosWin[0] + $aPosCtrl[0] + $aPosCtrl[2], $aPosWin[1] + $aPosCtrl[1] + $aPosCtrl[3])
    $hBmp_Tmp = _GetImage($sFile, $hGui_PreviewSize, $iBGColor)
    ;_hBmpToPicControl($idPic, $hBmp_Tmp, 1)
    GUISetState(@SW_SHOWNOACTIVATE, $hGui_Preview)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE

                GUISetState(@SW_HIDE, $hGui_Preview)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>ShowPreview

Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF)
    Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2, $aFTS
    $aFTS = FileGetTime($sFile)
    If @error Then Return SetError(1, 0, 0)
    $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32)
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _WinAPI_DeleteObject($hBmp1)
    _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr))
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    GUICtrlSetData($idLabel_Info, StringRegExpReplace($sFile, ".*\\(.*)", "$1") & @LF & Round(FileGetSize($sFile) / 1024, 0) & " kb (" & $iW & " x " & $iH & ")" & @LF & $aFTS[0] & "/" & $aFTS[1] & "/" & $aFTS[2] & " " & $aFTS[3] & ":" & $aFTS[4] & ":" & $aFTS[5])
    $aGS = _GetScale($iW, $iH, $iWH)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3])
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic)
    $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hBmp2
EndFunc   ;==>_GetImage

Func _GetScale($iW, $iH, $iWH)
    Local $aRet[4]
    If $iW <= $iWH And $iH <= $iWH Then
        $aRet[2] = $iW
        $aRet[3] = $iH
        $aRet[0] = ($iWH - $aRet[2]) / 2
        $aRet[1] = ($iWH - $aRet[3]) / 2
    ElseIf $iW > $iH Then
        $aRet[2] = $iWH
        $aRet[3] = $iH / ($iW / $iWH)
        $aRet[0] = 0
        $aRet[1] = ($iWH - $aRet[3]) / 2
    ElseIf $iW < $iH Then
        $aRet[2] = $iW / ($iH / $iWH)
        $aRet[3] = $iWH
        $aRet[0] = ($iWH - $aRet[2]) / 2
        $aRet[1] = 0
    ElseIf $iW = $iH Then
        $aRet[2] = $iWH
        $aRet[3] = $iWH
        $aRet[0] = 0
        $aRet[1] = 0
    EndIf
    Return $aRet
EndFunc   ;==>_GetScale

Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local $hOldBmp
    $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp)
    If $iFlag Then _WinAPI_DeleteObject($hBmp)
EndFunc   ;==>_hBmpToPicControl

And this does not do your code justice lol, as I belive I could do the same thing, with just creating the regular gui for this.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...