Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi How to hide Startmenu (https://www.delphipraxis.net/122615-how-hide-startmenu.html)

Razor 19. Okt 2008 12:51


How to hide Startmenu
 
How to do it?Startmenu not the startbutton thats a big diffrence..
Becouse i want to create a replacement..

thanks...

jfheins 19. Okt 2008 12:58

Re: How to hide Startmenu
 
You could try to redirect the messages of the button.

IOW:

YourVariable := MessageLoopOfStartButton;
MessageLoopOfStartbutton := YourCustomMessageLoop;

In YourCustomMessageLoop you can pass every message to the former message-loop except for the click-message, which you can handle yourself. This way, the button will never notice when the user clicks it ;)

Razor 19. Okt 2008 12:59

Re: How to hide Startmenu
 
Danke,danke:D I will try this..I am making longhorn startmenu for vista..

jfheins 19. Okt 2008 13:04

Re: How to hide Startmenu
 
Zitat:

Zitat von Razor
Danke,danke:D I will try this..I am making longhorn startmenu for vista..

Correct me if I'm wrong but ... Longhorn is Vista (or the former name of vista) isn't it?

Razor 19. Okt 2008 13:05

Re: How to hide Startmenu
 
Yes i messed it up a bit i mean Longhorn 4074 :P.Vista is 6001(SP1)

Razor 19. Okt 2008 13:37

Re: How to hide Startmenu
 
Could you make an example? :-D

jfheins 19. Okt 2008 14:13

Re: How to hide Startmenu
 
An example ...... i can show you how to do it ;)
(As I have no Delphi installed I dunno if it compiles ...)

First, you need a variable that holds the old WndProc. A Pointer should do the job.

To get the pointer to the WndProc you can call GetWindowLong(), to process the messages in your program, you need a seperate function
Delphi-Quellcode:
var
  OldWndProc: Pointer;

begin // Change WndProc
  OldWndProc := GetWindowLong({Handle to the Button}, GWLP_WNDPROC);
  SetWindowLong({Handle to the Button}, GWLP_WNDPROC, @NewWndProc);
end;

function NewWndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
begin
  if ({The Message you want})
    // Handle Message
  else // Call old WndProc
    CallWindowProc(OldWndProc, hWnd, uMsg, wParam, lParam);
end;
Something like that ;)

To get the Handle of the button, you can use FindWindow.

You can find additional stuff by searching for "subclassing" ;)

Apollonius 19. Okt 2008 14:17

Re: How to hide Startmenu
 
You don't even need GetWindowLong. SetWindowLong returns the previous value of the specified attribute. You also avoid a possible race condition if you remove the call.
Note that changing the WndProc only works for Vista. According to the documentation you can't set a new one for a window in a different process.

Razor 19. Okt 2008 14:40

Re: How to hide Startmenu
 
Liste der Anhänge anzeigen (Anzahl: 1)
I made something :-D

Razor 19. Okt 2008 19:30

Re: How to hide Startmenu
 
New question> What if i disable the start button and make my own?

jfheins 19. Okt 2008 19:55

Re: How to hide Startmenu
 
New question => New Thread please ;)

Short answer: Yes, that is possible :mrgreen:

Not-that-short-answer: Close the Button windwo and create your own one ;)

Razor 19. Okt 2008 19:56

Re: How to hide Startmenu
 
But bitte tell me how to hide vista's button and then i compile and share everything so everybody can see!! ;)

Danke.

jfheins 19. Okt 2008 20:28

Re: How to hide Startmenu
 
Use the DestroyWindow() or the CloseWindow() function ;)

Please do open up a new topic for each new question :warn:

Razor 19. Okt 2008 20:29

Re: How to hide Startmenu
 
Can somebody type an example i haven't never done this type of programing..

Razor 19. Okt 2008 21:33

Re: How to hide Startmenu
 
Ok i made something,please comment it and why it won't work as it should..

Delphi-Quellcode:
var
  Form2: TForm2;
  handle1,taskBarWnd:hwnd;
implementation

uses Unit3;

{$R *.dfm}
procedure tform2.hide;
begin
taskBarWnd := FindWindow('Shell_TrayWnd', 0);
handle1:=FindWindowEx(taskBarWnd, 0, 'Button', 'Start');
closewindow(handle1);
end;

turboPASCAL 20. Okt 2008 03:16

Re: How to hide Startmenu
 
??? :gruebel:

Delphi-Quellcode:
function ShowOrHideStartWndBtn(Action: Boolean): Boolean; // save Version
var
  hShellTrayWnd, hStartBtn: HWND;
begin
  Result := FALSE;
  hStartBtn := 0;

  // find the ShellTrayWindow
  hShellTrayWnd := FindWindow('Shell_TrayWnd', nil);

  // find the Start Button
  if hShellTrayWnd <> 0 then
  begin
    hStartBtn := FindWindowEx(hShellTrayWnd, 0, 'Button', nil);

    if hStartBtn <> 0 then
    begin
      Result := TRUE;
      case Action of
         TRUE: ShowWindow(hStartBtn, SW_SHOW); // now show the Button
        FALSE: ShowWindow(hStartBtn, SW_HIDE); // where is the button now? 
      end;
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowOrHideStartWndBtn(TRUE); // Show the Start Button
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ShowOrHideStartWndBtn(FALSE); // Hide the Start Button
end;
warning bad English

Zitat:

Zitat von Razor
Ok i made something, please comment it and why it won't work as it should..

Delphi-Quellcode:
// ...

var                          // var -> def global Variable
  Form2: TForm2;             // def. Form2 as any Type of TForm2
  handle1,taskBarWnd: hwnd;  // def. handle1 and taskBarWnd as any Windowhandle

implementation               // the section of a unit begins

uses Unit3;                  // include Unit3.pas

{$R *.dfm}                    // include all Resources with "dfm"-extensions

procedure tform2.hide;       // define porocedure "hide" from "form2"
begin                        // instruction begins
  taskBarWnd := FindWindow('Shell_TrayWnd', 0); // find the window "Shell_TrayWnd"
  handle1:=FindWindowEx(taskBarWnd, 0, 'Button', 'Start'); // find in Window "Shell_TrayWnd" the Window "Button"
  closewindow(handle1);      // minimizes, but does not destroy the specified window.
end;                         // instruction ends for porocedure "hide"
you cannot close the button !

Razor 20. Okt 2008 13:36

Re: How to hide Startmenu
 
@turboPASCAL > problem is that it won't work on vista!The code that you posted...

Thanks.

Razor 20. Okt 2008 14:38

Re: How to hide Startmenu
 
Zitat:

Zitat von jfheins
An example ...... i can show you how to do it ;)
(As I have no Delphi installed I dunno if it compiles ...)

First, you need a variable that holds the old WndProc. A Pointer should do the job.

To get the pointer to the WndProc you can call GetWindowLong(), to process the messages in your program, you need a seperate function
Delphi-Quellcode:
var
  OldWndProc: Pointer;

begin // Change WndProc
  OldWndProc := GetWindowLong({Handle to the Button}, GWLP_WNDPROC);
  SetWindowLong({Handle to the Button}, GWLP_WNDPROC, @NewWndProc);
end;

function NewWndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
begin
  if ({The Message you want})
    // Handle Message
  else // Call old WndProc
    CallWindowProc(OldWndProc, hWnd, uMsg, wParam, lParam);
end;
Something like that ;)

To get the Handle of the button, you can use FindWindow.

You can find additional stuff by searching for "subclassing" ;)


Could anybody test this like if you press the button then the form will show or something.This is really new for me so i rather ask before i go in to this...

Roachford 20. Okt 2008 21:59

Re: How to hide Startmenu
 
Zitat:

Zitat von Razor
Could anybody test this like if you press the button then the form will show or something.This is really new for me so i rather ask before i go in to this...

Why should we work for you? DIY...

Razor 20. Okt 2008 22:05

Re: How to hide Startmenu
 
Hahaha another guy with a bad day you know this isn't a place to toss your mind.This a FORUM read it what it means on google.

Luckie 20. Okt 2008 22:11

Re: How to hide Startmenu
 
Keep cool. This is a message board and all the help is voluntary. So if you don't want to help just don't do it and mind your own business.

And now for something completely diffrent: "How to defend yourself against a banan." Ah well, back to topic please.

Razor 20. Okt 2008 22:12

Re: How to hide Startmenu
 
All i want is help... :(

Luckie 20. Okt 2008 22:14

Re: How to hide Startmenu
 
Cheer up. ;)

Razor 20. Okt 2008 22:20

Re: How to hide Startmenu
 
Ockey Dockey.. :-D

Razor 25. Okt 2008 21:20

Re: How to hide Startmenu
 
Ok could i made my menu its fully functional how can i make it ..

When user clicks START > my start menu opens..i know there is a code but an example would be nice
I think i am here long enough to deserve atleast that.... :oops:

toms 25. Okt 2008 23:47

Re: How to hide Startmenu
 
Zitat:

Zitat von Razor
When user clicks START > my start menu opens..i know there is a code but an example would be nice

One possibility would be to hook the onclick on the startbutton (+ hook the windows key) and show your custom starmenu
instead the default one.

Razor 26. Okt 2008 14:05

Re: How to hide Startmenu
 
So the quelcode what jfheins typed is not suitable?


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:14 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz