gluglu
15-12-2006, 17:51:04
Hola de nuevo compañeros del foro !
Estoy indagando acerca de modificar el SysMenu de un form, u otras opciones de tratar la barra de título de un form.
He conseguido añadir mi opción al Sysmenu que se despliega cuando se pincha en el icono del Form que aparece en la barra de título, o bien cuando (en mi caso particular por ser un Form MDI), cuando se minimiza el form y aparece abajo en el contenedor MDI.
Para ello utilizo el siguiente código
const
SC_MyMenuItem1 = WM_USER + 1;
...
procedure TMain.FormCreate(Sender: TObject);
const
sMyMenuCaption1 = 'Mi opción de Menu';
var
SysMenu : HMenu;
begin
{Get system menu}
SysMenu := GetSystemMenu(Handle, FALSE) ;
{Add a seperator bar to main form-form1}
AppendMenu(SysMenu, MF_SEPARATOR, 0, '') ;
{add our menu}
AppendMenu(SysMenu, MF_STRING, SC_MyMenuItem1, sMyMenuCaption1) ;
...
end;
Quiero intentar conseguir dos opciones más. Una ponerle un icono a mi opción del Sysmenu. Para ello he encontrado la referencia a :
SetMenuItemBitmaps Function
The SetMenuItemBitmaps function associates the specified bitmap with a menu item. Whether the menu item is selected or clear, the system displays the appropriate bitmap next to the menu item.
Syntax
BOOL SetMenuItemBitmaps( HMENU hMenu, UINT uPosition, UINT uFlags, HBITMAP hBitmapUnchecked, HBITMAP hBitmapChecked);
Parameters
hMenu Handle to the menu containing the item to receive new check-mark bitmaps. [I]uPosition Specifies the menu item to be changed, as determined by the [I]uFlags parameter. uFlags Specifies how the [I]uPosition parameter is interpreted. The uFlags parameter must be one of the following values. MF_BYCOMMAND Indicates that uPosition gives the identifier of the menu item. If neither MF_BYCOMMAND nor MF_BYPOSITION is specified, MF_BYCOMMAND is the default flag. MF_BYPOSITION Indicates that uPosition gives the zero-based relative position of the menu item.hBitmapUnchecked Handle to the bitmap displayed when the menu item is not selected. [I]hBitmapChecked [in] Handle to the bitmap displayed when the menu item is selected.
Lo que no sé es como obtener el Handle de un Bitmap cualquiera que quiera insertar. (Utilizo Delphi 2006 VCL.Net y a mi entender no me permite utilizar punteros).
También me gustaría añadir una combinación de teclas 'ShortCut' a mi opción del SysMenu.
Y por último preguntar si existe la opción de interceptar de alguna manera la pulsación del botón derecho del ratón sobre la barra de título, que también me serviría a falta de modificación del SysMenu.
Muchas gracias por vuestra ayuda.
Edito : Quiero de nuevo especificar que el evento que quiero capturar con respecto al botón derecho del ratón sobre la barra de título es en un form MDIChild. He visto que sobre el Form principal se aplica lo mismo que lo explicado para el SysMenu.
Estoy indagando acerca de modificar el SysMenu de un form, u otras opciones de tratar la barra de título de un form.
He conseguido añadir mi opción al Sysmenu que se despliega cuando se pincha en el icono del Form que aparece en la barra de título, o bien cuando (en mi caso particular por ser un Form MDI), cuando se minimiza el form y aparece abajo en el contenedor MDI.
Para ello utilizo el siguiente código
const
SC_MyMenuItem1 = WM_USER + 1;
...
procedure TMain.FormCreate(Sender: TObject);
const
sMyMenuCaption1 = 'Mi opción de Menu';
var
SysMenu : HMenu;
begin
{Get system menu}
SysMenu := GetSystemMenu(Handle, FALSE) ;
{Add a seperator bar to main form-form1}
AppendMenu(SysMenu, MF_SEPARATOR, 0, '') ;
{add our menu}
AppendMenu(SysMenu, MF_STRING, SC_MyMenuItem1, sMyMenuCaption1) ;
...
end;
Quiero intentar conseguir dos opciones más. Una ponerle un icono a mi opción del Sysmenu. Para ello he encontrado la referencia a :
SetMenuItemBitmaps Function
The SetMenuItemBitmaps function associates the specified bitmap with a menu item. Whether the menu item is selected or clear, the system displays the appropriate bitmap next to the menu item.
Syntax
BOOL SetMenuItemBitmaps( HMENU hMenu, UINT uPosition, UINT uFlags, HBITMAP hBitmapUnchecked, HBITMAP hBitmapChecked);
Parameters
hMenu Handle to the menu containing the item to receive new check-mark bitmaps. [I]uPosition Specifies the menu item to be changed, as determined by the [I]uFlags parameter. uFlags Specifies how the [I]uPosition parameter is interpreted. The uFlags parameter must be one of the following values. MF_BYCOMMAND Indicates that uPosition gives the identifier of the menu item. If neither MF_BYCOMMAND nor MF_BYPOSITION is specified, MF_BYCOMMAND is the default flag. MF_BYPOSITION Indicates that uPosition gives the zero-based relative position of the menu item.hBitmapUnchecked Handle to the bitmap displayed when the menu item is not selected. [I]hBitmapChecked [in] Handle to the bitmap displayed when the menu item is selected.
Lo que no sé es como obtener el Handle de un Bitmap cualquiera que quiera insertar. (Utilizo Delphi 2006 VCL.Net y a mi entender no me permite utilizar punteros).
También me gustaría añadir una combinación de teclas 'ShortCut' a mi opción del SysMenu.
Y por último preguntar si existe la opción de interceptar de alguna manera la pulsación del botón derecho del ratón sobre la barra de título, que también me serviría a falta de modificación del SysMenu.
Muchas gracias por vuestra ayuda.
Edito : Quiero de nuevo especificar que el evento que quiero capturar con respecto al botón derecho del ratón sobre la barra de título es en un form MDIChild. He visto que sobre el Form principal se aplica lo mismo que lo explicado para el SysMenu.