Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

程式最小化至系統工具列

所需要用到的API為Shell_NotifyIcon
BOOL Shell_NotifyIcon(
DWORD dwMessage,
PNOTIFYICONDATA lpdata
);

傳入的Message有NIM_ADD、NIM_MODIFY、NIM_DELETE、NIM_SETFOCUS、NIM_SETVERSION
其所需傳入的結構為 NOTIFYICONDATA
typedef struct _NOTIFYICONDATAA{
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
#if (NTDDI_VERSION < NTDDI_WIN2K)
TCHAR szTip[64];
#endif
#if (NTDDI_VERSION >= NTDDI_WIN2K)
TCHAR szTip[128];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union{
UINT uTimeout;
UINT uVersion; // Used with Shell_NotifyIcon flag NIM_SETVERSION.
} DUMMYUNIONNAME;
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
#endif
#if (NTDDI_VERSION >= NTDDI_WINXP)
GUID guidItem;
#endif
#if (NTDDI_VERSION >= NTDDI_VISTA)
HICON hBalloonIcon;
#endif
}

如有需要針對滑鼠點擊System tray裡面的Icon反應的話,則需在uCallbackMessage給定回傳之訊息。

之後再於
LRESULT CDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
裡面去接收所需要的資訊並作相對應的動作即可

Sample-縮到System Tray:
bool CMainDlg::GotoSystemTray()
{
NOTIFYICONDATA NotifyIconData;

NotifyIconData.cbSize = sizeof (NOTIFYICONDATA);
NotifyIconData.hWnd = this->m_hWnd;
NotifyIconData.uID = IDD_MAINDLG;
NotifyIconData.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
NotifyIconData.hIcon = hIcon;
strcpy(NotifyIconData.szTip, "This is tip!!");
NotifyIconData.dwState = NIS_SHAREDICON;
strcpy(NotifyIconData.szInfo, "This is Info!!");
strcpy(NotifyIconData.szInfoTitle,"This is Info title!!");
NotifyIconData.dwInfoFlags = NIIF_INFO;
NotifyIconData.uCallbackMessage = WM_USER;


if ( !::Shell_NotifyIcon(NIM_ADD, &NotifyIconData) )
{
CString cstrDis;
cstrDis.Format("Err = %d", ::GetLastError());
::AfxMessageBox(cstrDis);
return false;
}

return true;
}

WinProc code:
LRESULT CMainDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch ( message )
{
case WM_USER: //NOTE:滑鼠移到上面就會送這個進來了
if ( lParam == WM_LBUTTONDBLCLK )
{
::AfxMessageBox("OnMessage_Left button");
}else if ( lParam == WM_RBUTTONDOWN ) {
::AfxMessageBox("OnMessage_Right button");
}
break;
case WM_SYSCOMMAND: //NOTE:OnCancel會進來到這邊
if ( wParam == SC_MINIMIZE || wParam == SC_CLOSE)
{
::AfxMessageBox("OnSystem bar");
}
break;
}

return CDialog::WindowProc(message, wParam, lParam);
}

Reference:http://blog.chinaunix.net/u2/67530/showart_603037.html

Comments

Popular Posts