?
Solved

replace the default Windows Start Menu

Posted on 2003-10-23
10
Medium Priority
?
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9608713
Firstly hide standard "Start" button.

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

Author Comment

by:ahen72
ID: 9608824
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 120 total points
ID: 9611712
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:PeterdeB
ID: 9616641
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
 
LVL 1

Expert Comment

by:fanar
ID: 9617149
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
ID: 9619970
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
ID: 9620445
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
ID: 9620813
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

800 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