Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[207] 죽은 프로세스의 트레이 아이콘(TrayIcon) 없애기
박영목 [gsbsoft] 6662 읽음    2007-04-09 16:36
Re: 트레이 영역 강제 갱신.. 죽은 프로세스의 트레이 아이콘 없애기..  -> 델마당에 올렸다가... 여기가 생각... 더 자주오니까? C++Builder 때문에... ㅋㅋㅋㅋ


C++Builder로 앞전 프로젝트에서 이 부분 그냥 넘어갔는데... 영 찝찝하여 검색하다가 여기를 찾게 되었는데... 지금 델파이로 코딩 중이라... ㅋㅋㅋ...
아래의 소스를 그대로 하니 저는 잘 안되네요... 그래서 google로 검색헀습니다.

당연히 찾았지요.... ㅋㅋㅋㅋ  이것으로 하니 되네요.... 호호호...
그런데 아래의 소스도 그 사이트에 위쪽에 있고 아래에 이 소스로 답변을 해 두었더군요...  잘 안되시는 분 이것으로 한번 해 보시길..... 
                                        부산에서 박영목  어... 전자우편 주소 저것 어떻게 바꾸지요... 저것 옛날 것인데.... 어디서 바꾸는지 아시는 연락요망... gsbsoft@naver.com인데....
--------------------------------------------------------------------------------

98에서 원본으로 돌리는 얼어버리네.... ㅋㅋㅋㅋ   아마 윈도우 핸들이 다른가 보지....
그리고 핸들이 안잡힐 경우도 있을 테니...

이렇게 금방 고쳐씀

procedure RemoveDeadIcons;
var
  wnd : cardinal;
  rec : TRect;
  w,h : DWORD;  //integer;
  x,y : DWORD;  //integer;
begin
  // find a handle of a tray
  wnd := FindWindow('Shell_TrayWnd', nil);

  if wnd<>0 then
    wnd := FindWindowEx(wnd, 0, 'TrayNotifyWnd', nil);

  if wnd<>0 then
    wnd := FindWindowEx(wnd, 0, 'SysPager', nil);

  if wnd<>0 then
  wnd := FindWindowEx(wnd, 0, 'ToolbarWindow32', nil);

  // get client rectangle (needed for width and height of tray)

  if wnd<>0 then
  begin

    windows.GetClientRect(wnd, rec);

    // get size of small icons
    w := DWORD(GetSystemMetrics(sm_cxsmicon));
    h := DWORD(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;
end;


98에서도 잘 돌아가게 하려면 Spy로 디져봐야 할 것 같음.... 오늘은 바빠서...  98은 포기하는 것을
제가 어거지로 하고 있는 중이기 때문에... ICON이 2개 생겨도... 지나 갈 것.... 같음....
TEST도 안했더군요.... 인력이 없이요....  구하려고 해도.... C++도 하고 Delphi도 하고 하는 사람이 구하기가 쩝....
부산이라.... 그렇게지요,....  ㅋㅋㅋ   부산 좀 내려오세요....   음 그런데 책임은 못집니다.... 열악해서... ㅋㅋㅋㅋ
그럼 물러갑니다.



원본/////



http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21625030.html


Here it is... It will simulate moving mouse cursor without actual moving.

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;
지성아빠 [raguru]   2008-05-20 14:14 X
올만이네 영목씨..

+ -

관련 글 리스트
207 죽은 프로세스의 트레이 아이콘(TrayIcon) 없애기 박영목 6662 2007/04/09
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.