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

C++빌더 Q&A
C++Builder Programming Q&A
[28055] Re:TrayIcon에서 PopUp메뉴없애는 방법
유영인 Cuperido [cuperido] 1097 읽음    2003-12-02 13:47
기본적으로만 사용하지만 저 같은 경우에는 자동으로 이루어지는것 같네요.
그런데, Window 자체적인 문제로 MSN이나 볼륨조절기 같은 다른 프로그램도
Popup이 없어지지 않는 경우가 발생하곤 합니다.

참고가 되실까봐 이전에 기본적으로 사용한 루틴 올려드립니다.

/****************************************************************
Tmain
- Main Initialize
****************************************************************/
__fastcall TMain::TMain(TComponent* Owner) : TForm(Owner)
{

// Receive Register Message From Windows
uiTrayMessage = RegisterWindowMessage ("MyIconNotify");

}

/****************************************************************
AddTray
- Add icon to tray-bar
****************************************************************/
void __fastcall TMain::AddTray()
{

NOTIFYICONDATA   niIcon;

memset(&niIcon, 0x00, sizeof(niIcon));

niIcon.cbSize           = sizeof(niIcon);
niIcon.hWnd             = Handle;
strncpy(niIcon.szTip, "Hi-Net Communicator", sizeof(niIcon.szTip));

niIcon.hIcon            = Application->Icon->Handle;
niIcon.uCallbackMessage = WM_USER + 1;

niIcon.uFlags           = NIF_MESSAGE | NIF_ICON | NIF_TIP;

Shell_NotifyIcon(NIM_ADD, &niIcon);

}

/****************************************************************
RemoveTray
- Remove icon from tray-bar
****************************************************************/
void __fastcall TMain::RemoveTray()
{

NOTIFYICONDATA    niIcon;

memset(&niIcon, 0x00, sizeof(niIcon));

niIcon.cbSize     = sizeof(niIcon);
niIcon.hWnd       = Handle;

Shell_NotifyIcon(NIM_DELETE, &niIcon);

}

/****************************************************************
FormDestroy
- Destory processing
****************************************************************/
void __fastcall TMain::FormDestroy(TObject *Sender)
{

RemoveTray();

}

/****************************************************************
TrayEvent
- Process tray-bar event
****************************************************************/
void __fastcall TMain::TrayEvent(TMessage &Msg)
{

POINT             P;

if(Msg.LParam == WM_LBUTTONDOWN)
   if(!blCertification) {
     // If doesn't certified not yet...
     if(PasswordCheck()) {
       // Input password, and turn to administrator mode.
       blCertification = true;
       ShowMessage("Administrator Mode");
     }

    } else {
     // If mode was administrator already.
     GetCursorPos(&P);
     SetForegroundWindow(Handle);
     Menu->Popup(P.x, P.y);

   }

}

alberddo 님이 쓰신 글 :
: TrayIcon에서 PopUp가 띄워져 있는 상태에서 PopUp메뉴를 선택하지 않고 바탕화면같은 다른곳을 클릭했을때 PopUp메뉴가 없어졌으면 좋겠는 데 방법을 모르겠습니다.
: Tray상에 있는 다른TrayIcon들은 어떻게 처리했는 지 다 PopUp메뉴가 없어지는 데 방법을 알고 계시면 알려주시기 바랍니다.
: 후킹기능을 사용하는 것 외에는 방법이 없나요?

+ -

관련 글 리스트
28053 TrayIcon에서 PopUp메뉴없애는 방법 alberddo 874 2003/12/02
28055     Re:TrayIcon에서 PopUp메뉴없애는 방법 유영인 Cuperido 1097 2003/12/02
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.