Languages :: Visual Basic :: Disable windows start button |
|||
| By: VB guy |
Date: 09/10/2002 00:00:00 |
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 | 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 | 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 | Type : Comment |
|
| Well, that is the translation in VB of the last procedure I posted ;-)) |
|||
|
Do register to be able to answer |
|||
©2012 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








