CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sun Jul 13, 2003 9:44 am Post subject: Adding Custom Items to System Menu |
|
|
Adding Custom Items to System Menu :
This Script demonstrates how to add new custom items to the system menu and to respond to custom WM_SYSCOMMAND message generated by clicking that menu item.
The principle is similar to subclassing in VB but here we use the command provided by VDS 5 itself.
Please note that this script uses Non VDS dll and API calls.
Any errors/mistakes will crash VDS/Operating system.
Try at your own risk.
Enjoy.
Code: |
#-----------------------------------------------------------------------------#
#-Calling a Non-VDs dll aDD Custom Items to System Menu by CodeScript---------#
#-Author: CodeScript----------------------------------------------------------#
#-Copyright: You can remove this info while Using this code in your app.------#
#------------but may be kind enough to add a word to documentation------------#
REM USE AT YOUR OWN RISK !!
REM MISTAKES MADE WHILE USING A NON VDS DLL MAY INVITE A VDS/SYSTEM CRASH.
REM SAVE YOUR WORK BEFORE RUNNING/DEBUGGING THIS SCRIPT.
Title Adding Custom Items to System Menu by CodeScript
OPTION MSGEVENT, $112, About,
rem thanx to mindpower for pointing that out !
DIALOG CREATE,Adding Custom Items to System Menu - CodeScript,-1,0,422,62,CLASS
MYWIN,RESIZABLE
DIALOG ADD,TEXT,TEXT1,24,90,240,16,Right click on the sysbar to see the custom items !
DIALOG SHOW
LOADLIB USER32
%H = @strdel(@WINEXISTS(#MYWIN),1,1)
IF %H
%I = @lib(user32,GetSystemMenu,INT:,%H, 0)
REM NOW %I IS THE HANDLE TO THE SYSTEM MENU TO BE REFERENCED IN
REM ALL THE SUBSEQUENT COMMANDS
%M = @lib(user32,AppendMenuA,BOOL:,%I,$800,false,0)
%M = @lib(user32,AppendMenuA,BOOL:,%I,0,1,&About)
%M = @lib(user32,AppendMenuA,BOOL:,%I,0,2,&Version)
%M = @lib(user32,DrawMenuBar,BOOL:,%H)
ELSE
ERROR -1
end
FREELIB USER32
:evloop
Wait event
goto @EVENT()
:About
IF @EQUAL(@MSGPARAMS(W),1)
Info Message event and adding a custom menu Item @CR()by Codescript
else
IF @EQUAL(@MSGPARAMS(W),2)
INFO There is no need for any version I say !@CR()Any way version is 1.0.0.0
end
END
goto EVLOOP
:RESIZE
goto EVLOOP
:CLOSE
Exit
|
_____________________________________________________________________________________ _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|