MFC Minimized to Pallet

Source: Internet
Author: User

#include"tlhelp32.h"#include"afxdialogex.h"voidCthsmfcappdlg::onsyscommand (UINT NID, LPARAM LPARAM) {if(NID &0xfff0) ==Idm_aboutbox)        {CAboutDlg dlgabout;    Dlgabout.domodal (); }    if(NID = =sc_minimize) {        //respond to minimized events with our own messagesTomini (); }    Else{Cdialogex::onsyscommand (NID, LParam); }}voidCthsmfcappdlg::tomini () {ShowWindow (sw_hide); Notifyicon.cbsize=sizeof(Notifyicondata); Notifyicon.hicon= AfxGetApp ()LoadIcon (IDR_MAINFRAME); Notifyicon.hwnd=m_hwnd; lstrcpy (Notifyicon.sztip, L"TEST"); Notifyicon.ucallbackmessage=WM_NC; Notifyicon.uflags= Nif_icon | Nif_message |Nif_tip; Shell_NotifyIcon (Nim_add,&NotifyIcon);}

LRESULT cthsmfcappdlg::onnotifymsg (WPARAM WPARAM, LPARAM LPARAM)//WPARAM receives the ID of the icon, and lparam receives the mouse's behavior{    //if (wparam! = idr_mainframe)//return 1;    Switch(lparam) { CaseWm_rbuttonup://The shortcut menu pops up when you right-click, there's only one "off"{lppoint Lpoint=NewTagpoint; :: GetCursorPos (lpoint);//Get mouse positionCMenu menu; Menu. CreatePopupMenu ();//declaring a pop-up menu//Add menu item "Close", click to Send Message Wm_destroy to main window (already//hidden) to end the program. Menu. AppendMenu (mf_string, Wm_destroy, _t ("Close")); //determine the location of the pop-up menuMenu. TrackPopupMenu (Tpm_leftalign, lpoint->x, Lpoint->y, This); //Resource RecyclingHMENU HMENU =menu.        Detach (); Menu.        DestroyMenu (); DeleteLpoint; }     Break;  CaseWM_LBUTTONDBLCLK://left-click Processing    {         This->showwindow (Sw_show);//Simple Display main window finished    }     Break; }    return 0;}

Reference sources

MFC Minimized to Pallet

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.