here's a simple menu api for oxygen. place it into "example/GUI" folder for running.
'
' simple example how to setup a menu for oxygen basic
' converted from powerbasic by frankolinox (frank brĂ¼bach), 11.juni.2013, bsa
' taken some part from petzolds menubar example
' folder: "example/GUI"
'
'
$ filename "t.exe"
includepath "$/inc/"
'#include "RTL32.inc"
'#include "RTL64.inc"
#include "MinWin.inc"
#lookahead ' for procedures
s=error()
'
if s then
print s
end
end if
%ID_TIMER = 1
%IDM_FILE_NEW = 40001
%IDM_FILE_OPEN = 40002
%IDM_FILE_SAVE = 40003
%IDM_FILE_SAVE_AS = 40004
%IDM_APP_EXIT = 40005
%IDM_EDIT_UNDO = 40006
%IDM_EDIT_CUT = 40007
%IDM_EDIT_COPY = 40008
%IDM_EDIT_PASTE = 40009
%IDM_EDIT_CLEAR = 40010
%IDM_BKGND_WHITE = 40011
%IDM_BKGND_LTGRAY = 40012
%IDM_BKGND_GRAY = 40013
%IDM_BKGND_DKGRAY = 40014
%IDM_BKGND_BLACK = 40015
%IDM_TIMER_START = 40016
%IDM_TIMER_STOP = 40017
%IDM_APP_HELP = 40018
%IDM_APP_ABOUT = 40019
%MF_INSERT = &H00000000???
%MF_CHANGE = &H00000080???
%MF_APPEND = &H00000100???
%MF_DELETE = &H00000200???
%MF_REMOVE = &H00001000???
%MF_BYCOMMAND = &H00000000???
%MF_BYPOSITION = &H00000400???
%MF_SEPARATOR = &H00000800???
'%MF_ENABLED = &H00000000???
'%MF_GRAYED = &H00000001???
'%MF_DISABLED = &H00000002???
'%MF_UNCHECKED = &H00000000???
'%MF_CHECKED = &H00000008???
%MF_USECHECKBITMAPS = &H00000200???
%MF_STRING = &H00000000???
%MF_BITMAP = &H00000004???
%MF_OWNERDRAW = &H00000100???
%MF_POPUP = &H00000010???
%MF_MENUBARBREAK = &H00000020???
%MF_MENUBREAK = &H00000040???
declare InitCommonControlsEx lib "ComCtl32.dll" (INITCOMMONCONTROLSEXtype*ic) as sys
indexbase 0
DECLARE FUNCTION GetMenu LIB "USER32.DLL" ALIAS "GetMenu" ( _
BYVAL hWnd AS SYS _ ' __in HWND hWnd
) AS SYS ' HMENU
DECLARE FUNCTION SetMenu LIB "USER32.DLL" ALIAS "SetMenu" ( _
BYVAL hWnd AS SYS _ ' __in HWND hWnd
, OPTIONAL BYVAL hMenu AS SYS _ ' __in_opt HMENU hMenu
) AS LONG ' BOOL
DECLARE FUNCTION AppendMenuA LIB "USER32.DLL" ALIAS "AppendMenuA" ( _
BYVAL hMenu AS SYS _ ' __in HMENU hMenu
, BYVAL uFlags AS SYS _ ' __in UINT uFlags
, BYVAL uIDNewItem AS SYS _ ' __in UINT_PTR uIDNewItem
, OPTIONAL BYREF lpNewItem AS ASCIIZ _ ' __in_opt LPCSTR lpNewItem
) AS LONG ' BOOL
%DESKTOP_CREATEMENU = &H0004???
DECLARE FUNCTION CreateMenu LIB "USER32.DLL" ALIAS "CreateMenu" ( _
) AS SYS ' HMENU
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr, inst as sys
&cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS START
'=============
'
WinMain inst,0,cmdline,SW_NORMAL
end
'--------------------------------------------------------------------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
WndClass wc
MSG wm
sys hwnd, wwd, wht, wtx, wty, tax
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc = @WndProc
wc.cbClsExtra =0
wc.cbWndExtra =0
wc.hInstance =inst
wc.hIcon=LoadIcon 0, IDI_APPLICATION
wc.hCursor=LoadCursor 0,IDC_ARROW
wc.hbrBackground = GetStockObject WHITE_BRUSH
wc.lpszMenuName =null
wc.lpszClassName = strptr "Demo"
RegisterClass (@wc)
Wwd = 420 : Wht = 300
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
hwnd = CreateWindowEx 0,wc.lpszClassName,"Menu+Oxygen Basic",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
'---------------------------------------------------------- // MENU START ---------------
sys hMenu,hMenuPopup,iCmdShow
hMenu = CreateMenu()
hMenuPopup = CreateMenu()
AppendMenuA hMenuPopup, %MF_STRING, %IDM_FILE_NEW, "&New"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_FILE_OPEN, "&Open..."
AppendMenuA hMenuPopup, %MF_STRING, %IDM_FILE_SAVE, "&Save"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_FILE_SAVE_AS, "Save &As..."
AppendMenuA hMenuPopup, %MF_SEPARATOR, 0,0 ' BYVAL %NULL
AppendMenuA hMenuPopup, %MF_STRING, %IDM_APP_EXIT, "E&xit"
AppendMenuA hMenu, %MF_POPUP, hMenuPopup, "&File"
SetMenu hwnd, hMenu
hMenuPopup = CreateMenu()
AppendMenuA hMenuPopup, %MF_STRING, %IDM_EDIT_UNDO, "&Undo"
AppendMenuA hMenuPopup, %MF_SEPARATOR, 0, BYVAL %NULL
AppendMenuA hMenuPopup, %MF_STRING, %IDM_EDIT_CUT, "Cu&t"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_EDIT_COPY, "&Copy"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_EDIT_PASTE, "&Paste"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_EDIT_CLEAR, "De&lete"
AppendMenuA hMenu, %MF_POPUP, hMenuPopup, "&Edit"
hMenuPopup = CreateMenu()
AppendMenuA hMenuPopup, %MF_STRING, %IDM_APP_HELP, "&Help"
AppendMenuA hMenuPopup, %MF_STRING, %IDM_APP_ABOUT, "&About MenuDemo..."
AppendMenuA hMenu, %MF_POPUP, hMenuPopup, "&Help"
'---------------------------------------------------------- // MENU END ---------------
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
dim as rect crect 'for WndProc and TimerProc
'--------------------------------------------------------------
function WndProc ( hWnd, wMsg, wParam, lparam ) as sys callback
'==============================================================
static as sys hdc
static as String txt
static as PaintStruct Paintst
sys id
'==========
select wMsg
'==========
case WM_COMMAND
hMenu = GetMenu(hwnd)
if wparam = %IDM_APP_EXIT THEN
print "hello and exit"
SendMessage hwnd, WM_CLOSE, 0, 0
end if
'--------------
case WM_CREATE
'=============
GetClientRect hWnd,&cRect
'--------------
case WM_DESTROY
'===============
PostQuitMessage 0
'------------
case WM_PAINT
'============
GetClientRect hWnd,&cRect
hDC=BeginPaint hWnd,&Paintst
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,yellow
SetTextColor hdc,red
DrawText hDC,"Hello Menu World!",-1,&cRect,0x25
EndPaint hWnd,&Paintst
'--------------
case WM_KEYDOWN
'==============
'============
Select wParam
'============
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function
best regards, frank
X