안녕하셨습니까? 사랑합니다. 부산의 월천 박영목입니다.
트레이 영역 강제 갱신.. 죽은 프로세스의 트레이 아이콘 없애기..
NSIS로 Setup 프로그램을 만들어 내부에서 강제로 죽이고 시작하는데 이때 트레이가 있으면
갱신이 되지 않아 2개로 보이지요... 물론 마우스 가면 갱시되지만 조금 지저분해서....
그리고 NSIS에서 메세지를 보내고 응용에서 받고... 찾아야 하고 일도 많이 늘어날 것 같아 계속 이것을 사용하기로 합니다.
2007-04-09 에 델마당에 올린 것인데... 오늘 C++Builder로 할 것이 있어서
볼랜드포름에 찾으려고 하니 없네요.... 제가 이곳에 올려 놓은 줄 알고....
그래서 다시 찾아 C++Builder용으로 만들었습니다.
----------------------------------------------------------------------------------------------------------------------------------------------------
C++Builder로 앞전 프로젝트에서 이 부분 그냥 넘어갔는데... 영 찝찝하여 검색하다가 여기를 찾게 되었는데... 지금 델파이로 코딩 중이라... ㅋㅋㅋ...
아래의 소스를 그대로 하니 저는 잘 안되네요... 그래서 google로 검색헀습니다.
당연히 찾았지요.... ㅋㅋㅋㅋ 이것으로 하니 되네요.... 호호호...
그런데 아래의 소스도 그 사이트에 위쪽에 있고 아래에 이 소스로 답변을 해 두었더군요... 잘 안되시는 분 이것으로 한번 해 보시길.....
부산에서 박영목 어... 전자우편 주소 저것 어떻게 바꾸지요... 저것 옛날 것인데.... 어디서 바꾸는지 아시는 연락요망... gsbsoft@naver.com인데....
--------------------------------------------------------------------------------
>
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21625030.
void __fastcall RemoveDeadIcons()
{
HWND wnd;
TRect rec;
DWORD w,h;
DWORD x,y;
// find a handle of a tray
wnd = FindWindow( "Shell_TrayWnd", NULL );
if( wnd!=NULL )
wnd = FindWindowEx( wnd, 0, "TrayNotifyWnd", NULL );
if( wnd!=NULL )
wnd = FindWindowEx( wnd, 0, "SysPager", NULL );
if( wnd!=NULL )
wnd = FindWindowEx( wnd, 0, "ToolbarWindow32", NULL );
// get client rectangle (needed for width and height of tray)
if( wnd!=NULL )
{
::GetClientRect( wnd, &rec );
// get size of small icons
w = (DWORD)GetSystemMetrics(SM_CXSMICON); // sm_cxsmicon);
h = (DWORD)GetSystemMetrics(SM_CYSMICON); // sm_cysmicon);
// initial y position of mouse - half of height of icon
y = w>>1;
while( y < (DWORD)rec.Bottom ) // while y < height of tray
{
x = h>>1; // initial x position of mouse - half of width of icon
while( x < (DWORD)rec.Right ) // while x < width of tray
{
SendMessage( wnd, WM_MOUSEMOVE, 0, (y<<16)|x); // simulate moving mouse over an icon
x = x + w; // add width of icon to x position
}
y = y + h; // add height of icon to y position
}
}
}
아래는 델파이.......
procedure RemoveDeadIcons;
var
wnd : cardinal;
rec : TRect;
w,h : integer;
x,y : integer;
begin
// find a handle of a tray
wnd := FindWindow('Shell_TrayWnd', nil);
wnd := FindWindowEx(wnd, 0, 'TrayNotifyWnd', nil);
wnd := FindWindowEx(wnd, 0, 'SysPager', nil);
wnd := FindWindowEx(wnd, 0, 'ToolbarWindow32', nil);
// get client rectangle (needed for width and height of tray)
windows.GetClientRect(wnd, rec);
// get size of small icons
w := GetSystemMetrics(sm_cxsmicon);
h := GetSystemMetrics(sm_cysmicon);
// initial y position of mouse - half of height of icon
y := w shr 1;
while y < rec.Bottom do begin // while y < height of tray
x := h shr 1; // initial x position of mouse - half of width of icon
while x < rec.Right do begin // while x < width of tray
SendMessage(wnd, wm_mousemove, 0, y shl 16 or x); // simulate moving mouse over an icon
x := x + w; // add width of icon to x position
end;
y := y + h; // add height of icon to y position
end;
end;