Hi,
I was wonder if someone might be so kind and point me in the right direction regarding creating Gui rightclick context Menus on the fly based on a channellist that varies in lenght depending on what channels the user has. In my case I have 14 favourite channels in an array and I wonder if it might be possible to create 14 Menu items and 14 Labels with a function or something like that? Right now I have done it the common way with one Menu command and one label for each channel. However some other user could for example have +50 channels. But spawning a context menu for +50 channels when it cover most of the screen area, wouldnt look very nice though.
So if any of you guys have done this before or knows some good scripts in this area or simply having good ideas upon an approach, please let me know.
Add Gui context Menu items on the fly
-
- Posts: 28
- Joined: 10 Apr 2017, 11:31
Re: Add Gui context Menu items on the fly
It would have been cool if this had worked although I dont understand why it wouldnt:
Code: Select all
FavArray := ["S1HD", "SV2HD", "TV3"]
Menu, DVBVContextMenu, Add
Menu, DVBVContextMenu, DeleteAll
For k, v in FavArray {
ChannelName := v
ChannelNumber := "FavChannel_" . k
;msgbox % ChannelName "`n" ChannelNumber
Menu, DVBVContextMenu, Add, %ChannelName%, %ChannelNumber%, +Radio
}
Re: Add Gui context Menu items on the fly
Hi zcooler, why do you need a special label for each menu item?
Re: Add Gui context Menu items on the fly
Hello just me,
Well, each menu item label sends a different channel switching command (postmessage) or COM SendCommand.Im not sure if I want to continue finding out if dynamic assigning of Menus is possible, cuz it turns out displaying tooltips on menus items are somewhat complicated and therefor a less interesting option to venture further into. So I decided to try out building a GUI Context Menu instead, but am struggeling hard with alingning the colums of radio pic controls with channelnames text controls
Later on Im planning to mimic the blue highlighting OnMouseOver Menu items on the GUI also, but first things first.
Well, each menu item label sends a different channel switching command (postmessage) or COM SendCommand.
Code: Select all
FavChannel_1:
PostMessage, 0xB2C2, 0x0815, 0x08D,, ahk_class TfrmMain ;Channelchange to SVT1 HD 0x08E=SVT2, 0x08F=TV3 etc.
;iDVBViewer.SendCommand(11) ;Channelchange to Favourite 1
Code: Select all
CheckedIMG := "F:\TV\test\MediaLauncher\icons\radiobutton_checked.png"
MaxChannelsPerColumn := "15" ; max number of rows per column for show checkboxes
FavArray := ["SVT1 HD", "SVT2 HD", "TV3", "TV4", "Kanal 5", "TV6", "Sjuan", "TV8", "Kanal 9", "TV10", "TV12", "Discovery Channel", "Barnkanalen/SVT24", "Kunskapskanalen"]
Gui, ChannelContextMenu:New, ;-Border +Caption +OwnerDVBV
;Gui, Margin, 0, 0
Gui, Margin, 10, 10
;Gui, Color, FFFFFF
Gui, Font, s9, Arial
For index, title in FavArray {
;ChannelName := v
;ChannelNumber := "FavChannel_" . k
;msgbox % ChannelName "`n" ChannelNumber
;Menu, DVBVContextMenu, Add, %ChannelName%, %ChannelNumber%, +Radio
IsChecked := Channel_name[title]
PicOptions := A_Index = 1 ? "xm Section w10 h10" : (Mod(A_Index, MaxChannelsPerColumn) = 1) ? "ys Section" : "xs y+10 w10 h10"
Gui, Add, Pic, %PicOptions% Checked%IsChecked% vCRadio%index% +hwndHRADIO gCheckChannel AltSubmit, %CheckedIMG%
RBControls .= "|CRadio" . index
RadioControls[HRADIO + 0] := title
TextOptions := A_Index = 1 ? "ys" : (Mod(A_Index, MaxChannelsPerColumn) = 1) ? "ys Section" : "ys y+10"
Gui, Add, Text, %TextOptions% vShowCB%index% +hwndHShowCB gFavChannel_, % title
GBControls .= "|ShowCB" . index
CopyControls[HShowCB + 0] := title
}
; Alternatively, Link controls can be used:
Gui, Add, Link,, Click <a href="www.google.com">here</a> to launch Channel List.
Gui, Font, norm
Gui, Show
return
CheckChannel:
return
FavChannel_:
return
Re: Add Gui context Menu items on the fly
You might store the different values for PostMessage in an associative array (key = favchannel name), too.
Re: Add Gui context Menu items on the fly
Yes, that was how i though I would handle it when the GUI context menu is working. Nonetheless I will abandon the Menu because of the Tooltip issue. The tooltip is an important key feature displaying Now and Next StartTime and TVshowEPGName for each channel
Who is online
Users browsing this forum: JoeWinograd, yabab33299 and 138 guests