Hide any application icon from the taskbar
https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543%28v=vs.85%29.aspx
*this was applied on osk:http://yousfi.over-blog.com/2015/03/windows-keyboard-on-screen-osk.html
These codes are tested on win8.1
*Begin code
_Screen.WindowState=1
Do ydeclare
If ! ShellExecute(0, "open", "notepad.exe","","",1)>32
Messagebox("An error was occured !",16+4096,"Error",1000)
Return .F.
Endi
sleep(2000)
Local m.xtitle
m.xtitle="Sans titre - Bloc-notes" &&warning ! localized (depends on langage on use in system)-here french
Do yprocess With m.xtitle
Procedure yprocess
Lparameters ytitle
*Important: must be the EXACT Caption of the window depending on language used on system-place it in the form
Local i,fail,yhwnd
i=0
m.fail=.F.
m.yhwnd=0
*findwindow recquires a loop to find a window/title-adapt times intervals
Do While .t.
m.yhwnd = FindWindow(Null, Allt(ytitle)) &&localized
sleep(100)
i=i+1
if m.yhwnd<>0
exit
endi
If i>20
m.fail=.T.
Exit
Endi
Enddo
If m.fail=.T.
Messagebox("Fail to find "+ytitle,16+4096,"error",1000)
Return .F.
Endi
Do yhideonTaskbar With yhwnd
Endproc
Procedure yhideonTaskbar
Lparameters HWnd
#Define GWL_STYLE -16
#Define WS_CAPTION 0x00C00000
#Define WS_THICKFRAME 0x00040000
#Define WS_DLGFRAME 0x00400000
*this extened style dont show any window (hwnd) on the taskbar
#Define SW_HIDE 0
#Define SW_SHOW 5
#Define WS_EX_NOACTIVATE 0x08000000 &&L
#Define GWL_EXSTYLE -20
ShowWindow(HWnd, SW_HIDE) &&important hide/set/hide window
SetWindowLong(HWnd, GWL_EXSTYLE , WS_EX_NOACTIVATE)
ShowWindow(HWnd, SW_SHOW)
messagebox("icon hidden from taskbar!",0+32+4096,'',1000)
Endproc
Procedure ydeclare
Declare Integer Sleep In kernel32 Integer
Declare Integer GetWindowLong In User32 Integer HWnd, Integer nIndex
Declare Integer SetWindowLong In user32 Integer HWnd,;
INTEGER nIndex, Integer dwNewLong
Declare Long FindWindow In "user32" String lpClassName, String lpWindowName
Declare Integer ShowWindow In user32;
INTEGER HWnd,;
INTEGER nCmdShow
Declare Integer ShellExecute In SHELL32.Dll Integer nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
Endproc
*End code
*End code
*Pass a window title(localized) or a portion of this title to this code and it returns the handle+title
*if the window exists on desktop hierarchy
*if dont pass any param all desktop windows hierarchy are listed.CTRL+F to search for a title in browse window.
*Begin code
lparameters tcTitle &&if empty the code browses all windows only
DO ydeclare
LOCAL hParent, hWindow, cTitle
hParent = GetDesktopWindow()
hWindow = 0
CREATE CURSOR ycurs (winhandle I, wintitle C(150))
DO WHILE .T.
STORE REPLICATE(CHR(0),255) TO cClass, cTitle
hWindow = FindWindowEx(hParent, hWindow, Null, Null)
IF hWindow = 0
EXIT
ELSE
cTitle = GetWinText(hWindow)
INSERT INTO ycurs VALUES (hWindow,cTitle)
ENDIF
ENDDO
SELECT ycurs
locate
BROWSE title trans(reccount())+" windows on desktop" NORMAL NOWAIT
Locate
Browse Name ybrow Title Trans(reccount())+" Windows on desktop" Nowait &&window as oop object
With ybrow
.DeleteMark=.F.
.GridLines=0
.RecordMark=.F.
.fontsize=12
.fontbold=.t.
.column2.width=300
.Columns(1).DynamicBackColor="RGB(100,150,190)"
.Columns(2).DynamicBackColor="RGB(10,170,180)"
Endwith
if not empty(tctitle)
sele ycurs
local m.x
m.x=""
scan
if lower(allt(tcTitle)) $ lower(allt(winTitle))
m.x=m.x+trans(recno())+" HWND="+trans(winhandle)+" Title="+allt(trans(wintitle))+chr(13)
endi
endscan
_cliptext=m.x
messagebox( m.x,0+32+4096,"Result In clipboard")
endi
return
FUNCTION GetWinText(hWindow)
LOCAL cBuffer
cBuffer = REPLICATE(CHR(0), 255)
= GetWindowText(hWindow, @cBuffer, LEN(cBuffer))
RETURN STRTRAN(cBuffer, CHR(0), "")
PROCEDURE yDeclare
DECLARE INTEGER GetLastError IN kernel32
DECLARE INTEGER GetDesktopWindow IN user32
DECLARE INTEGER FindWindowEx IN user32;
INTEGER hwndParent, INTEGER hwndChildAfter,;
STRING @lpszClass, STRING @lpszWindow
DECLARE INTEGER GetWindowText IN user32;
INTEGER hWnd, STRING @lpString, INTEGER nMaxCount
endproc
*End code
*can see original news2news code here:http://www.news2news.com/vfp/index.php?example=27