Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to disable and reenable the Windows start button Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
03-Oct-02
Category
System
Language
Delphi 2.x
Views
90
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Jonas Bilinkevicius

How can I disable the Windows start button and prevent the user from accessing it 
by clicking on it or by pressing [CTRL] + [ESC] ?

Answer:

Solve 1:

To disable the Start button:

1   var
2     h: hwnd;
3   begin
4     h := FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil);
5     EnableWindow(h, false);
6   end;


But the user can still access the start menu by pressing [CTL] + [ESC] or the 
windows key. Even hiding the Start button doesn't work. But hiding the Start button 
and using the SetParent function seems to work:

7   var
8     h: hwnd;
9   begin
10    h := FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil)
11      ShowWindow(h, 0);
12    Windows.SetParent(h, 0);
13  end;
14  
15  //To enable the Start button again:
16  
17  var
18    h: hwnd;
19    TaskWindow: hwnd;
20  begin
21    h := FindWindowEx(GetDesktopWindow, 0, 'Button', nil);
22    TaskWindow := FindWindow('Shell_TrayWnd', nil);
23    Windows.SetParent(h, TaskWindow);
24    ShowWindow(h, 1);
25  end;


Furthermore, you could create your own Start button and "replace" it with your own.

26  var
27    b: TButton; {or another button type that can hold a bitmap}
28    h, Window: hwnd;
29  begin
30    Window := FindWindow('Shell_TrayWnd', nil);
31    b := TButton.Create(nil);
32    b.ParentWindow := Window;
33    b.Caption := 'Start';
34    b.Width := 60;
35    b.font.style := [fsbold];
36  end;



Solve 2:

37  procedure TForm1.Button1Click(Sender: TObject);
38  var
39    Rgn: hRgn;
40  begin
41    {Hide the start button}
42    Rgn := CreateRectRgn(0, 0, 0, 0);
43    SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil), 
44  Rgn,
45      true);
46  end;
47  
48  procedure TForm1.Button2Click(Sender: TObject);
49  begin
50    {Turn the start button back on}
51    SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil), 0,
52      true);
53  end;
54  
55  procedure TForm1.Button3Click(Sender: TObject);
56  begin
57    {Disable the start button}
58    EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil),
59      false);
60  end;
61  
62  procedure TForm1.Button4Click(Sender: TObject);
63  begin
64    {Enable the start button}
65    EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil),
66      true);
67  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC