私のプログラムは、アプリ内でバルーン通知バブルを使用してユーザーをガイドします。WindowsXPでは、バルーンウィンドウの右上隅に小さな「X」があり、クリックするとウィンドウが閉じます。また、ウィンドウ内のどこかをクリックすると、ウィンドウが閉じます。 「X」をクリックしないでください。
ただし、プログラムがWindows Server 2008で実行されている場合、バルーンは表示されますが、「X」ボタンがなく、クリックしても閉じません。
誤って、次の内容を含む.MANIFESTファイルを削除して、WindowsXPでの動作を再現することができました。
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="2.0.0.0" processorArchitecture="x86" name="SofrwareName" type="win32" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="<Removed>" language="*" processorArchitecture="x86" />
</dependentAssembly>
</dependency>
</assembly>
このマニフェストを削除してWindowsXPでプログラムを実行すると、バルーンはWindows Server 2008の場合と同じように動作します。これは、WindowsServer2008のCommonControlsv6との何らかの非互換性を意味する可能性があると思います。
クリック時にバルーンが閉じず、「X」閉じるボタンがない原因を誰かが知っていますか?
更新:バルーン作成コードは次のとおりです。
m_tool = new MessageTool(); //internal class MessageTool : NativeWindow {...}
CreateParams cp = new CreateParams();
cp.ClassName = TOOLTIPS_CLASS; //TOOLTIPS_CLASS = "tooltips_class32";
cp.Style =
WS_POPUP |
TTS_BALLOON |
TTS_NOPREFIX |
TTS_ALWAYSTIP |
TTS_CLOSE;
m_ti = new TOOLINFO();
/*
[StructLayout(LayoutKind.Sequential)]
private struct TOOLINFO
{
public int cbSize;
public int uFlags;
public IntPtr hwnd;
public IntPtr uId;
public RECT rect;
public IntPtr hinst;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpszText;
public uint lParam;
}
*/
m_ti.cbSize = Marshal.SizeOf(m_ti);
m_tool.CreateHandle(cp);
m_ti.uFlags = TTF_TRACK |
TTF_CLOSEONMOUSECLICK |
TTF_TRANSPARENT |
TTF_SUBCLASS |
TTF_PARSELINKS;
m_ti.uId = m_tool.Handle;
m_ti.lpszText = m_text;
m_ti.hwnd = m_parent.Handle;
WindowsAPI.GetClientRect(m_parent.Handle, ref m_ti.rect);
ClientToScreen(m_parent.Handle, ref m_ti.rect);
WindowsAPI.SetWindowPos(
m_tool.Handle,
HWND_TOP,
0, 0, 0, 0,
(int)SetWindowPosFlags.SWP_NOACTIVATE |
(int)SetWindowPosFlags.SWP_NOMOVE |
(int)SetWindowPosFlags.SWP_NOSIZE);
IntPtr ptrStruct = Marshal.AllocHGlobal(Marshal.SizeOf(m_ti));
Marshal.StructureToPtr(m_ti, ptrStruct, true);
WindowsAPI.SendMessage(
m_tool.Handle, TTM_ADDTOOL, 0, ptrStruct);
m_ti = (TOOLINFO)Marshal.PtrToStructure(ptrStruct,
typeof(TOOLINFO));
WindowsAPI.SendMessage(
m_tool.Handle, TTM_SETMAXTIPWIDTH,
0, new IntPtr(m_maxWidth));
WindowsAPI.SendMessage(
m_tool.Handle, TTM_SETTITLE,
(int)m_titleIcon, ptrTitle);
SetBalloonPosition(m_ti.rect);
Marshal.FreeHGlobal(ptrStruct);
Marshal.FreeHGlobal(ptrTitle);
およびWindowsビルド情報:Windows Server Standard、SP2、32ビット