# HG changeset patch # User Frank Benoit # Date 1211152125 -7200 # Node ID 82b599d219836642becd49389ddbdc24c2eb7557 # Parent f54496748313fa8d7da516bd3c1e464eae7b852a Fix tooltips for normal controls and the tray. diff -r f54496748313 -r 82b599d21983 dwt/internal/win32/OS.d --- a/dwt/internal/win32/OS.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/internal/win32/OS.d Mon May 19 01:08:45 2008 +0200 @@ -113,14 +113,14 @@ return lgid & 0x3FF; } - private static int getNOTIFYICONDATAA_V2_SIZE (){ - // hm, NOTIFYICONDATAA.dwInfoFlags.offsetof did not compile - return IsWinCE ? NOTIFYICONDATAA.sizeof : cast(int)(&(cast(NOTIFYICONDATAA*)null).dwInfoFlags) + int.sizeof; - } - - private static int getNOTIFYICONDATAW_V2_SIZE (){ - return IsWinCE ? NOTIFYICONDATAW.sizeof : cast(int)(&(cast(NOTIFYICONDATAW*)null).dwInfoFlags) + int.sizeof; - } +// private static int getNOTIFYICONDATAA_V2_SIZE (){ +// // hm, NOTIFYICONDATAA.dwInfoFlags.offsetof did not compile +// return IsWinCE ? NOTIFYICONDATAA.sizeof : cast(int)(&(cast(NOTIFYICONDATAA*)null).dwInfoFlags) + int.sizeof; +// } +// +// private static int getNOTIFYICONDATAW_V2_SIZE (){ +// return IsWinCE ? NOTIFYICONDATAW.sizeof : cast(int)(&(cast(NOTIFYICONDATAW*)null).dwInfoFlags) + int.sizeof; +// } /* * DWT Windows flags diff -r f54496748313 -r 82b599d21983 dwt/internal/win32/WINTYPES.d --- a/dwt/internal/win32/WINTYPES.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/internal/win32/WINTYPES.d Mon May 19 01:08:45 2008 +0200 @@ -15028,17 +15028,18 @@ UINT uFlags; UINT uCallbackMessage; HICON hIcon; - char szTip[64]; + char szTip[128] = '\0'; DWORD dwState; DWORD dwStateMask; - char szInfo[256]; -// union { -// UINT uTimeout; + char szInfo[256] = '\0'; + union { + UINT uTimeout; UINT uVersion; -// }; - char szInfoTitle[64]; + }; + char szInfoTitle[64] = '\0'; DWORD dwInfoFlags; -// GUID guidItem; + //GUID guidItem; + //HICON hBalloonIcon; } alias NOTIFYICONDATAA* PNOTIFYICONDATAA, LPNOTIFYICONDATAA; struct NOTIFYICONDATAW { @@ -15048,18 +15049,20 @@ UINT uFlags; UINT uCallbackMessage; HICON hIcon; - WCHAR szTip[64]; + WCHAR szTip[128] = '\0'; DWORD dwState; DWORD dwStateMask; - WCHAR szInfo[256]; -// union { -// UINT uTimeout; + WCHAR szInfo[256] = '\0'; + union { + UINT uTimeout; UINT uVersion; -// }; - WCHAR szInfoTitle[64]; + } + WCHAR szInfoTitle[64] = '\0'; DWORD dwInfoFlags; -// GUID guidItem; -} + //GUID guidItem; + //HICON hBalloonIcon; +} + alias NOTIFYICONDATAW* PNOTIFYICONDATAW, LPNOTIFYICONDATAW; version(ANSI){ alias NOTIFYICONDATAA NOTIFYICONDATA; diff -r f54496748313 -r 82b599d21983 dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/widgets/Composite.d Mon May 19 01:08:45 2008 +0200 @@ -1770,7 +1770,7 @@ shell.setToolTipText (lpnmtdi, bytes); //OS.MoveMemory (lParam, cast(NMTTDISPINFOA)lpnmtdi, NMTTDISPINFOA.sizeof); } else { - shell.setToolTipText (lpnmtdi, chars); + shell.setToolTipText (lpnmtdi, StrToTCHARs(chars,true)); //OS.MoveMemory (lParam, cast(NMTTDISPINFOW)lpnmtdi, NMTTDISPINFOW.sizeof); } return LRESULT.ZERO; diff -r f54496748313 -r 82b599d21983 dwt/widgets/Display.d --- a/dwt/widgets/Display.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/widgets/Display.d Mon May 19 01:08:45 2008 +0200 @@ -289,9 +289,7 @@ int lastHittest; /* Message Only Window */ - //Callback messageCallback; HWND hwndMessage; - int messageProc_; /* System Resources */ LOGFONT* lfSystemFont; diff -r f54496748313 -r 82b599d21983 dwt/widgets/Shell.d --- a/dwt/widgets/Shell.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/widgets/Shell.d Mon May 19 01:08:45 2008 +0200 @@ -1687,7 +1687,7 @@ } } -void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) { +void setToolTipText (NMTTDISPINFO* lpnmtdi, byte [] buffer) { /* * Ensure that the current position of the mouse * is inside the client area of the shell. This @@ -1713,10 +1713,9 @@ if (!hasCursor ()) return; auto hHeap = OS.GetProcessHeap (); if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); - TCHAR[] charz = buffer;//StrToTCHARs( 0, buffer ); - int byteCount = charz.length * TCHAR.sizeof; + int byteCount = buffer.length * 2; lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); - OS.MoveMemory (lpstrTip, charz.ptr, byteCount); + OS.MoveMemory (lpstrTip, buffer.ptr, byteCount); lpnmtdi.lpszText = lpstrTip; } @@ -1741,14 +1740,14 @@ return; } if (hwndToolTip is toolTipHandle_) { - if (text is toolTitle || (toolTitle !is null && toolTitle ==/*eq*/text )) { + if (text is toolTitle || (toolTitle !is null && toolTitle.equals (text) )) { if (icon is toolIcon) return; } toolTitle = text; toolIcon = icon; } else { if (hwndToolTip is balloonTipHandle_) { - if (text is balloonTitle || (balloonTitle !is null && balloonTitle==/*eq*/text)) { + if (text is balloonTitle || (balloonTitle !is null && balloonTitle.equals (text))) { if (icon is toolIcon) return; } balloonTitle = text; diff -r f54496748313 -r 82b599d21983 dwt/widgets/TrayItem.d --- a/dwt/widgets/TrayItem.d Sun May 18 20:52:15 2008 +0200 +++ b/dwt/widgets/TrayItem.d Mon May 19 01:08:45 2008 +0200 @@ -29,7 +29,6 @@ import dwt.dwthelper.utils; - /** * Instances of this class represent icons that can be placed on the * system tray or task bar status area. @@ -469,19 +468,20 @@ checkWidget (); toolTipText = value; NOTIFYICONDATA iconData; - TCHAR[] buffer = StrToTCHARs (0, toolTipText is null ? "" : toolTipText, true); + TCHAR[] buffer = StrToTCHARs (0, toolTipText is null ? "X"[1..1] : toolTipText, true); + assert( buffer.ptr !is null ); /* * Note that the size of the szTip field is different in version 5.0 of shell32.dll. */ - int length = OS.SHELL32_MAJOR < 5 ? 64 : 128; + int length_ = OS.SHELL32_MAJOR < 5 ? 64 : 128; static if (OS.IsUnicode) { - TCHAR [] szTip = iconData.szTip; - length = Math.min (length - 1, buffer.length ); - System.arraycopy (buffer, 0, szTip, 0, length); + TCHAR [] szTip = iconData.szTip[]; + length_ = Math.min (length_ - 1, buffer.length ); + System.arraycopy (buffer, 0, szTip, 0, length_); } else { - TCHAR [] szTip = iconData.szTip; - length = Math.min (length - 1, buffer.length ); - System.arraycopy (buffer, 0, szTip, 0, length); + TCHAR [] szTip = iconData.szTip[]; + length_ = Math.min (length_ - 1, buffer.length ); + System.arraycopy (buffer, 0, szTip, 0, length_); } iconData.cbSize = NOTIFYICONDATA.sizeof; iconData.uID = id;