Minimized window to pallet area-vc++

Source: Internet
Author: User

1. Add the variable in the. h file of the window class: Notifyicondata Pnid;

2, in the window class. CPP file in custom message: Wm_mymessage

3. Add code to the initialization function OnInitDialog of the window class:

Pnid.cbsize = (DWORD) sizeof (NOTIFYICONDATA);

Pnid.hwnd = m_hwnd;

Pnid.uid = (UINT) M_hicon;

Pnid.uflags = nif_icon| nif_message| Nif_tip;

Icon Valid | Custom message valid | Mouse pointing to display text valid

Pnid.ucallbackmessage = Wm_mymessage;

Pnid.hicon = M_hicon;

strcpy (Pnid.sztip, "LAN Monitoring System Client");

4. Add a message response function for Wm_mymessage:

Begin_message_map (Cclientdlg, CDialog)

On_message (Wm_mymessage,onmymessage)

On_wm_size ()//window message (added in the Class wizard)

End_message_map ()

5, the implementation of OnMyMessage function:

LRESULT cclientdlg::onmymessage (WPARAM WPARAM, LPARAM LPARAM)

{

if (LParam = = wm_lbuttondown)//If you left-click in the icon to restore

{

Shell_NotifyIcon (Nim_delete,&pnid);//delete tray icon

ShowWindow (SW_SHOWNORMAL);//Display main window

Make the window always on the front

This->setwindowpos (&wndtopmost,0,0,0,0,

swp_nomove| Swp_nosize);

}

return 0;

}

6. Add the On_wm_size () message to the dialog box in the Class Wizard and implement the OnSize function

void Cclientdlg::onsize (UINT nType, int cx, int cy)

{

Cdialog::onsize (NType, CX, CY);

if (ntype==size_minimized)//If the event is minimized

{

Shell_NotifyIcon (Nim_add,&pnid);//Add icon to Tray area

ShowWindow (sw_hide);//Hide main window

}

}


This article is from "Mu Ming" blog, please be sure to keep this source http://10437084.blog.51cto.com/10427084/1679031

Minimized window to pallet area-vc++

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.