Solved

replace the default Windows Start Menu

Posted on 2003-10-23
10
344 Views
Last Modified: 2010-04-05
Hello,

I want to replace the default Windows Start Menu with my own popupmenu.
Left and right mouse click for different popupmenus.

I hope you can help me.

Best regards
Achim Henning
0
Comment
Question by:ahen72
10 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
Firstly hide standard "Start" button.

Then make fake "Start" button from your programm.
0
 

Author Comment

by:ahen72
Comment Utility
That's what I already did - works ... but I need do have different Start button bitmaps for different types of operating sytems ... and
I need to lock the taskbar, because my new start button is just always on top of the start buttons starting positonm.

I'm looking for a way to hook the mouse ... any ideas/solutios ?

regards
Achim

0
 
LVL 1

Accepted Solution

by:
fanar earned 30 total points
Comment Utility
Hey sup

Do this get the handle of the start button then make it invisible.
Then make your own button and put it there instead of the real one.

You can use a hook in a dll to get the mouse right and left clicks so u can pop up a menu.

I have some expamples such as this on this comp if i find them i will post it.

I have not been doing such things for long time or i would write a small example

Anar
0
 

Expert Comment

by:PeterdeB
Comment Utility
Hello Achim, I read your post and what you're doing picked my interest Therefore I wanted to ask you something about the swapping startbutton-thing. (sorry but I really haven't got a clue as to how I could help you out  > it seems the other way around actually but I'm more than willing to reward you for an answer to my question and I'm far from greedy so;)
How do you get a hold of the startbutton and place your own on the taskbar? i manage to hide it but I'd like to know how I could add something to it like for instance a startbutton. Can you perhaps share your code with me since uptil now I didnot think this was possible and to be honest I'm still not convinced it can......Thanks in advance and tell me what you need for sharing your code which does the swapping thing okay?

My regards,

Paul
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Expert Comment

by:fanar
Comment Utility
Hey they code below was not written by me but it shows u how to use a journal hook which monitors the mouse and when the user clicks anywhere it tells u the window on which it was clicked( the HWND of the window) so u can put ur own button there and check to see its hwnd then popup menu.

Or

U could put this into a dll and make a mouse hook but thats longer and more complicated.

unit MouseButton;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, AppEvnts;

type
  TForm1 = class(TForm)
    Button_StartJour: TButton;
    Button_StopJour: TButton;
    ApplicationEvents1: TApplicationEvents;
    Memo1: TMemo;
    procedure Button_StartJourClick(Sender: TObject);
    procedure Button_StopJourClick(Sender: TObject);
    procedure ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  JHook: THandle;
Track: Boolean;

implementation

{$R *.dfm}

function JournalProc(Code, wParam: Integer; var EventStrut: TEVENTMSG): Integer; stdcall;
var
Char1: PChar;
Title: array[0..256] of char;
begin
{this is the JournalRecordProc}
Result := CallNextHookEx(JHook, Code, wParam, Longint(@EventStrut));
{the CallNextHookEX is not really needed for journal hook since it it not
really in a hook chain, but it's standard for a Hook}
if Code < 0 then Exit;
{you should cancel operation if you get HC_SYSMODALON}
if Code = HC_SYSMODALON then Exit;
if (Code = HC_ACTION) then
begin
{the EventStrut record has the Information about the mouse or keyboard
event. You said you just wanted the mouse button events so I get the
mouse down and mouse up event messages}
  if EventStrut.message = WM_LBUTTONDOWN then
  begin
   GetWindowText(GetActiveWindow,Title,256);
   form1.Memo1.Lines.Add(String(Title)+'-'+IntToStr((EventStrut.hwnd)));
  end;
end;
end;


procedure TForm1.Button_StartJourClick(Sender: TObject);

begin
if Track then
begin
ShowMessage('Mouse is already being Journaled, can not restart');
Exit;
end;

JHook := SetWindowsHookEx(WH_JOURNALRECORD , @JournalProc, hInstance,0);
{SetWindowsHookEx starts the Hook}
if JHook > 0 then
begin
Track := True;
end else
ShowMessage('No Journal Hook availible');
end;



procedure TForm1.Button_StopJourClick(Sender: TObject);
begin
Track := False;
UnhookWindowsHookEx(JHook);
JHook := 0;
end;


procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
{the journal hook is automaticly camceled if the Task manager
(Ctrl-Alt-Del) or the Ctrl-Esc keys are pressed, you restart it
when the WM_CANCELJOURNAL is sent to the parent window, Application}
Handled := False;
if (Msg.message = WM_CANCELJOURNAL) and Track then
JHook := SetWindowsHookEx(WH_JOURNALRECORD , @JournalProc, 0, 0);
end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnhookWindowsHookEx(JHook);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.


DFM File

object Form1: TForm1
  Left = 192
  Top = 123
  Width = 544
  Height = 375
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnClose = FormClose
  PixelsPerInch = 96
  TextHeight = 13
  object Button_StartJour: TButton
    Left = 32
    Top = 24
    Width = 113
    Height = 25
    Caption = 'Button_StartJour'
    TabOrder = 0
    OnClick = Button_StartJourClick
  end
  object Button_StopJour: TButton
    Left = 32
    Top = 88
    Width = 105
    Height = 25
    Caption = 'Button_StopJour'
    TabOrder = 1
    OnClick = Button_StopJourClick
  end
  object ListBox1: TListBox
    Left = 160
    Top = 56
    Width = 305
    Height = 273
    ItemHeight = 13
    TabOrder = 2
  end
  object ApplicationEvents1: TApplicationEvents
    OnMessage = ApplicationEvents1Message
    Left = 224
    Top = 8
  end
end


0
 

Author Comment

by:ahen72
Comment Utility
Fanar,

I can see now where the user clicks and I can show my own startmenu when he is clicking on the startbutton, but the problem is that the original startmenu is then already opened ! Do you you now how to disable this, too ?


Best regards and thanks so far
Achim
0
 

Author Comment

by:ahen72
Comment Utility
I also find a very good solution on: http://www.swissdelphicenter.ch/en/showcode.php?id=328 --> Code at the end !

With that solution it's possible to complete hide the start button and put a new button where the original was.
But that's only working with normal buttons not with BITBTN ... but I need a BITBTN !
Perhaps someone can help again !

Thanks in advance
Achim

The code from http://www.swissdelphicenter.ch/en/showcode.php?id=328:



{
  The ShowStartButton function shows how to hide the start
  button, how to disable the windows buttons (LWin and RWin)
  (indirectly) and consequently how to hide the start menu.
}

procedure ShowStartButton(bvisible: Boolean);
var
  h: hwnd;
  TaskWindow: hwnd;
begin
  if bvisible then
  begin
    h := FindWindowEx(GetDesktopWindow, 0, 'Button', nil);
    TaskWindow := FindWindow('Shell_TrayWnd', nil);
    ShowWindow(h, 1);
    Windows.SetParent(h, TaskWindow);
  end  
  else
  begin
    h := FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil);
    ShowWindow(h, 0);
    Windows.SetParent(h, 0);
  end;
end;


{Example to hide/reshow the Startbutton}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowStartButton(False); // or true to reshow
end;

{Furthermore, you could create your own Startbutton and
replace the original one with your own.}
var
  b: TButton;  // or another Type of button
  h, Window: hwnd;
begin
  Window := FindWindow('Shell_TrayWnd', nil);
  b := TButton.Create(nil);
  b.ParentWindow := Window;
  b.Caption := 'Start';
  b.Width := 52;
  b.Height := 22;
  b.Font.Style := [fsbold];
end;
0
 
LVL 1

Expert Comment

by:fanar
Comment Utility
Hey check this out this is a hook program that subclasses msn and then adds a menu to it. It incluedes event handling also

You should find everything u need in here

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20429026.html#7621675

Hope this helps ,
Anar
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now