visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Visual Basic :: Disable windows start button


By: VB guy Canada  Date: 09/10/2002 00:00:00  English  Points: 500 Status: Answered
Quality : Excellent
How to disable windows start button keyboard press from visual basic program

By: VGR Date: 09/10/2002 21:08:00 English  Type : Answer
Well, I would have said "just catch the appropriate VK_ event", but in stead I found this that you may fond useful :

1) from <A HREF="http://www.scalabium.com/faq/dct0097.htm">http://www.scalabium.com/faq/dct0097.htm</A>

If you needs to hide/show the Start button from Windows Taskbar, you can use the next procedure:

procedure HideShowStartButton(boolVisible: Boolean);
var
 Tray, Child: hWnd;
 C: array[0..127] of Char;
 S: string;
begin
 Tray := FindWindow('Shell_TrayWnd', nil);
 Child := GetWindow(Tray, GW_CHILD);
 while Child <> 0 do
 begin
   if GetClassName(Child, C, SizeOf(C)) > 0 then
   begin
     S := StrPas(C);
     if UpperCase(S) = 'BUTTON' then
     begin
       startbutton_handle := child;
       ShowWindow(Child, Integer(boolVisible))
     end;
   end;
   Child := GetWindow(Child, GW_HWNDNEXT);
 end;
end

2) from <A HREF="http://delphi.about.com/bltip0699.htm">http://delphi.about.com/bltip0699.htm</A>
even simplier :
//Enable:
EnableWindow(FindWindowEx(FindWindow
 ('Shell_TrayWnd', nil), 0,'Button',nil),TRUE);
//Disable:
EnableWindow(FindWindowEx(FindWindow
 ('Shell_TrayWnd', nil), 0,'Button',nil),FALSE);

3) from <A HREF="http://www.delphipages.com/tips/thread.cfm?ID=11">http://www.delphipages.com/tips/thread.cfm?ID=11</A>
worse but more API-proof

How to Hide, Enable, or Disable the Start Button in Windows

procedure TForm1.Button1Click(Sender: TObject);
var Rgn : hRgn;
begin
{Hide the start button}
 Rgn := CreateRectRgn(0, 0, 0, 0);
 SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd', nil),0,'Button',nil),Rgn, true);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{Turn the start button back on}
 SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd', nil),0,'Button',nil),0,true);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
{Disable the start button}
 EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil),0, 'Button', nil),false);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
{Enable the start button}
 EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil),0,'Button',nil),true);
end;  


the last code is pure API, works for Win 9X

Good luck

By: VB guy Date: 09/10/2002 21:12:00 English  Type : Comment
This small code sample shows how to disable the Start Menu button through code, simply paste it into a BAS module and use :



'
' Paste this into a Code Mode (BAS)
'
option Explicit
'
private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (byval hWnd1 as Long, byval hWnd2 as Long, byval lpsz1 as string, byval lpsz2 as string) as Long
'
private Declare Function EnableWindow Lib "user32" (byval hwnd as Long, byval fEnable as Long) as Long

public Sub EnableStartMenuButton(byval bEnable as Boolean)
'
' Don't forget to re-enable it !
'
   Dim lHwnd as Long
'
    lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
   lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
   Call EnableWindow(lHwnd, bEnable)
'
End Sub
'
'

Make sure that you remember to re-enable the start menu button at some point or it could get very frustrating !

By: VGR Date: 09/10/2002 21:23:00 English  Type : Comment
Well, that is the translation in VB of the last procedure I posted ;-))

Do register to be able to answer

EContact
browser fav
page generated in 388.966080 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page