Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance, Force
- CoordMode, Mouse, Screen
- pToken := Gdip_Startup()
- OnExit, Exit
- Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
- Gui, 1: Show, NA
- hwnd1 := WinExist()
- w := 200, h := 300
- bw := 2
- w += bw//2, h += bw//2
- info := {title: "My Feed", item: ["Some information", "Click me!", "And me!", "Just another test", "Last piece of information"]}
- o := {x: Round(w*0.05), y: 0, w: Round(w*0.9), h: 35, hpos: "Centre", vpos: "vCentre", color: "bbffffff", size: "14", style: ["Normal"]}
- options := {}, optionsHover := {}
- Loop, % info.item.MaxIndex() ;%
- {
- oLocal := o.Clone()
- oLocal.y := 60+(A_Index-1)*35
- options[A_Index] := oLocal
- oHover := oLocal.Clone(), oHover.style := ["Bold"]
- optionsHover[A_Index] := oHover
- }
- hbm := CreateDIBSection(w, h), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
- G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4)
- pBrush := Gdip_BrushCreateSolid(Gdip_ToARGB(200, 70, 70, 70))
- Gdip_FillRoundedRectangle(G, pBrush, bw//2, bw//2, w-bw, h-bw, 5)
- pPen := Gdip_CreatePen(Gdip_ToARGB(255, 200, 200, 200), bw)
- Gdip_DrawRoundedRectangle(G, pPen, bw//2, bw//2, w-bw, h-bw, 5)
- titleOptions := o.Clone(), titleOptions.y := 20, titleOptions.size := 20, titleOptions.style := ["Bold", "Underline"]
- Gdip_TextToGraphics2(G, info.title, titleOptions, "Arial", w, h)
- Loop, % info.item.MaxIndex() ;%
- Gdip_TextToGraphics2(G, info.item[A_Index], options[A_Index], "Arial", w, h)
- UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-w)//2, (A_ScreenHeight-h)//2, w, h)
- OnMessage(0x201, "WM_LBUTTONDOWN")
- SetTimer, Update, 50
- return
- ;#######################################################################
- Gdip_TextToGraphics2(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0)
- {
- static replace := {x: "x", y: "y", w: "w", h: "h", hpos: "", vpos: "", color: "c", size: "s"}
- for k, v in Options
- {
- if (k = "style")
- {
- Loop, % v.MaxIndex() ;%
- o .= " " v[A_Index]
- }
- else
- o .= " " replace[k] Options[k]
- }
- return Gdip_TextToGraphics(pGraphics, Text, o, Font, Width, Height, Measure)
- }
- ;#######################################################################
- Update:
- MouseGetPos, x, y, window
- WinGetPos, wx, wy,,, ahk_id %hwnd1%
- x -= wx, y -= wy
- match := 0
- Loop, % info.item.MaxIndex() ;%
- {
- tx := options[A_Index].x, ty := options[A_Index].y
- tw := options[A_Index].w, th := options[A_Index].h
- if (x >= tx && y >= ty && x <= tx+tw && y <= ty+th)
- {
- match := A_Index
- break
- }
- }
- if (match = omatch)
- return
- Loop, 2
- {
- i := (A_Index = 1) ? match : omatch
- Gdip_SetClipRect(G, options[i].x, options[i].y, options[i].w, options[i].h)
- Gdip_SetCompositingMode(G, 1)
- Gdip_FillRectangle(G, pBrush, 0, 0, w, h)
- Gdip_SetCompositingMode(G, 0)
- Gdip_TextToGraphics2(G, info.item[i], (A_Index = 1) ? optionsHover[i] : options[i], "Arial", w, h)
- Gdip_ResetClip(G)
- }
- omatch := match
- UpdateLayeredWindow(hwnd1, hdc)
- return
- ;#######################################################################
- CheckClick:
- if !match
- SetTimer, CheckClick, Off
- else if !GetKeyState("LButton", "P")
- {
- SetTimer, CheckClick, Off
- MsgBox, % info.item[match] ;%
- }
- return
- ;#######################################################################
- WM_LBUTTONDOWN()
- {
- PostMessage, 0xA1, 2
- SetTimer, CheckClick, 50
- }
- ;#######################################################################
- Exit:
- SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
- Gdip_DeleteBrush(pBrush), Gdip_DeletePen(pPen)
- Gdip_Shutdown(pToken)
- ExitApp
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement