replace the default Windows Start Menu

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
ahen72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GloomyFriarCommented:
Firstly hide standard "Start" button.

Then make fake "Start" button from your programm.
0
ahen72Author Commented:
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
fanarCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

PeterdeBCommented:
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
fanarCommented:
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
ahen72Author Commented:
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
ahen72Author Commented:
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
fanarCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.