Ooops
March 06, 2021, 05:32:14 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
BlitzPlus Gui
»
[bb] Popupmenus! by cyberseth [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Popupmenus! by cyberseth [ 1+ years ago ] (Read 619 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bb] Popupmenus! by cyberseth [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:42 AM »
Title :
Popupmenus!
Author :
cyberseth
Posted :
1+ years ago
Description :
THIS CODE WAS UPDATED AS OF BLITZPLUS 1.34
- No need for GetCursor. MouseX(),MouseY() takes care of that.
- Had to change the FindWindow class to "BLITZMAX_WINDOW_CLASS"
This app uses a userlib to refer to the user32.dll library and get some popupmenu commands! Make sure you add the code at the top (in comments) to a "user32.decls" file and put it in your blitzplususerlibs directory...
Code :
Code: BlitzBasic
; .lib "user32.dll"
; FindWindow$ ( hwnd ):"FindWindowA"
; GetMenu%( hnd )
; GetSubMenu%( hnd,npos )
; TrackPopupMenuEx%( mnu,flags,x,y,hwnd,tpm )
Const
TPM_RETURNCMD = $100
;Create window
win = CreateWindow
(
"Popupmenu Test"
,
100
,
100
,
400
,
300
)
txt = CreateLabel
(
"Right-click anywhere to open popupmenu"
,
10
,
10
,
250
,
50
,win
)
mnuFile = CreateMenu
(
"&File"
,
0
,WindowMenu
(
win
)
)
mnuFileOpen = CreateMenu
(
"&Open"
,
1
,mnuFile
)
mnuFileOpen = CreateMenu
(
"&Save"
,
1
,mnuFile
)
mnuFileOpen = CreateMenu
(
"&Exit"
,
1
,mnuFile
)
mnuEdit = CreateMenu
(
"&Edit"
,
0
,WindowMenu
(
win
)
)
mnuEditCut = CreateMenu
(
"&Cut"
,
1
,mnuEdit
)
mnuEditCopy = CreateMenu
(
"&Copy"
,
2
,mnuEdit
)
mnuEditPaste = CreateMenu
(
"&Paste"
,
3
,mnuEdit
)
mnuEditMore = CreateMenu
(
"More"
,
4
,mnuEdit
)
mnuEditMoreStuff = CreateMenu
(
"Stuff"
,
5
,mnuEditMore
)
UpdateWindowMenu
(
win
)
;Find handle for "Edit" submenu
hwnd = FindWindow
(
"BLITZMAX_WINDOW_CLASS"
,
"Popupmenu Test"
)
hmnu = GetSubMenu
(
GetMenu
(
hwnd
)
,
1
)
;0 = File, 1 = Edit, etc...
Repeat
If
WaitEvent
(
1
)
=$803
Or
KeyHit
(
1
)
Then
End
If
MouseHit
(
2
)
Then
index = TrackPopupMenuEx
(
hmnu,TPM_RETURNCMD,
MouseX
(
)
,
MouseY
(
)
,hwnd,
0
)
SetGadgetText txt,
"You clicked item : "
+ index
End If
Forever
Comments :
Phoenix(Posted 1+ years ago)
This doesn't work...
Zeachco(Posted 1+ years ago)
I dont know "user32.dll" but i guess you should add lib ref as :FindWindow$ ( <win app name>, hwnd :"FindWindowA"instead of :FindWindow$ ( hwnd ):"FindWindowA"since you call this command in your code as :FindWindow("BLITZMAX_WINDOW_CLASS","Popupmenu Test")
Zeachco(Posted 1+ years ago)
By the way i tried adding an argument but it return 0.Is that that "BLITZMAX_WINDOW_CLASS" or is that im using a wrong argument vars type (class$,class% or class#...)?
N(Posted 1+ years ago)
6 years old. I suggest you go to MSDN.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
BlitzPlus Gui
»
[bb] Popupmenus! by cyberseth [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal