We help IT Professionals succeed at work.

Possible to change the popup menu cursor?

Khan Consultoria
on
Hello Guys,

I don't know if it is possible, but could I change the popup menu cursor?

Thanks
Alex
Comment
Watch Question

Software architect
CERTIFIED EXPERT
Top Expert 2012
Commented:
With help of this example ... made own:
const
    CM_MENU_CLOSED = CM_BASE + 1001;
    CM_ENTER_MENU_LOOP = CM_BASE + 1002;
    CM_EXIT_MENU_LOOP = CM_BASE + 1003;
    CM_MENU_SELECT = CM_BASE + 1004;
type
    TPopupListEx = class(TPopupList)
    protected
      procedure WndProc(var Message: TMessage) ; override;
    private
      procedure PerformMessage(cm_msg : integer; msg : TMessage) ;
    end;

..

type
  TForm1 = class(TForm)
    ...
  private
    { Private declarations }
    procedure CM_MenuClosed(var msg: TMessage) ; message CM_MENU_CLOSED;
    procedure CM_EnterMenuLoop(var msg: TMessage) ; message CM_ENTER_MENU_LOOP;
    procedure CM_ExitMenuLoop(var msg: TMessage) ; message CM_EXIT_MENU_LOOP;
    procedure CM_MenuSelect(var msg: TMessage) ; message CM_MENU_SELECT;
  public
...


procedure TForm1.CM_EnterMenuLoop(var msg: TMessage);
begin
  //SetCursor( Screen.Cursors[crHandPoint] );
end;

procedure TForm1.CM_ExitMenuLoop(var msg: TMessage);
begin
  SetCursor( Screen.Cursors[crDefault] );
end;
                                                            
procedure TForm1.CM_MenuClosed(var msg: TMessage);
begin
  SetCursor( Screen.Cursors[crDefault] );
end;

procedure TForm1.CM_MenuSelect(var msg: TMessage);
begin
  SetCursor( Screen.Cursors[crHandPoint] );
end;

...

{ TPopupListEx }

procedure TPopupListEx.PerformMessage(cm_msg: integer; msg: TMessage);
begin
  if Screen.Activeform <> nil then
      Screen.ActiveForm.Perform(cm_msg, msg.WParam, msg.LParam) ;
end;

procedure TPopupListEx.WndProc(var Message: TMessage);
begin
  case message.Msg of
    WM_ENTERMENULOOP: PerformMessage(CM_ENTER_MENU_LOOP, Message) ;
    WM_EXITMENULOOP : PerformMessage(CM_EXIT_MENU_LOOP, Message) ;
    WM_MENUSELECT :
      begin
        with TWMMenuSelect(Message) do
        begin
          if (Menu = 0) and (Menuflag = $FFFF) then
          begin
            PerformMessage(CM_MENU_CLOSED, Message) ;
          end
          else if (Menu <> 0) and ((Menuflag and MF_MOUSESELECT)= MF_MOUSESELECT) then
          begin
            PerformMessage(CM_MENU_SELECT, Message) ;
          end;
        end;
      end;
  end;
  inherited;
end;


initialization
    Popuplist.Free; //free the "default", "old" list
    PopupList:= TPopupListEx.Create; //create the new one
    // The new PopupList will be freed by
    // finalization section of Menus unit.

Open in new window


When detect that mouse is over menu item .. SELECT message will send to main form and there you can change cursor.

Author

Commented:
thanks very much for your help

Explore More ContentExplore courses, solutions, and other research materials related to this topic.