I've got this C++ code but I'm not so good on C++. So is there any kind soul
out there that can translate the following code into Pascal for use in
Delphi?? Please!!! I'm desperat!
LRESULT CALLBACK WndProcBar(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
blah, blah, blah
case WM_COPYDATA:
// Undocumented: This is how we can make our own system tray
// and eventually handle app bar windows. Once a window in
// the system has the "Shell_TrayWnd" class name, it
receives
// this message!
{
int i;
RECT r;
HWND iconWnd;
int targetMsg=-1;
NOTIFYICONDATA *data;
COPYDATASTRUCT *d;
HICON targetIcon=NULL;
char targetTip[256]="";
d = (COPYDATASTRUCT *)lParam;
switch (d->dwData)
{
case 1: // Forward System Tray
data = (NOTIFYICONDATA *)(((char*)d->lpData)+8);
switch (*(int *)(((char*)d->lpData)+4))
{
case NIM_ADD:
{
HWND p;
if (appBar) p = hTrayWnd; else p = hMainWnd;
if (dockToWharf) p = systray;
i = getTrayByWnd(data->hWnd);
if (i >= 0 && data->uID == trayWnds[i].uID) goto _modifySecurity;
if (data->uFlags & NIF_MESSAGE)
targetMsg = data->uCallbackMessage;
if (data->uFlags & NIF_TIP && data->szTip)
{
memset(targetTip, 0, sizeof(targetTip));
if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
WideCharToMultiByte
(
CP_ACP,
0,
(wchar_t *) data->szTip,
wcslen ((wchar_t *) data->szTip),
targetTip,
sizeof (targetTip),
NULL,
NULL
);
}
else
{
strcpy(targetTip, data->szTip);
}
}
iconWnd = CreateWindowEx(
WS_EX_TRANSPARENT, // exstyles
szTrayIcon, // our window class name
"", // use description for a window title
WS_CHILD,
4, 3, // position
trayIconSize, trayIconSize, // width & height of window
p, // parent window (winamp main window)
NULL, // no menu
dll, // hInstance of DLL
NULL); // no window creation data
if (!iconWnd)
MessageBox(parent,"Error creating window",szTrayIcon,MB_OK);
return 1;
}
if (data->uFlags & NIF_ICON)
targetIcon = CopyIcon(data->hIcon);
SetWindowLong(iconWnd, GWL_USERDATA, (long)targetIcon);
i = addToTray(iconWnd, data->hWnd, targetMsg, targetIcon,
data->uID, targetTip);
SetWindowPos(iconWnd, 0, trayWnds[i].x, trayWnds[i].y, 0, 0,
SWP_NOZORDER|SWP_NOSIZE);
ShowWindow(iconWnd,SW_SHOWNORMAL);
break;
}
case NIM_DELETE:
removeFromTray(data->hWnd);
break;
case NIM_MODIFY:
{
BOOL need_to_pack_tray;
i = getTrayByWnd(data->hWnd);
if (i < 0) break;
_modifySecurity:
need_to_pack_tray = FALSE;
targetMsg = trayWnds[i].message;
targetIcon = trayWnds[i].hIcon;
if (data->uFlags & NIF_TIP && trayWnds[i].szTip)
strcpy(targetTip, trayWnds[i].szTip);
if (data->uFlags & NIF_MESSAGE && data->uCallbackMessage)
targetMsg = data->uCallbackMessage;
if (targetIcon != NULL && data->hIcon && data->uFlags & NIF_ICON)
DestroyIcon(targetIcon);
if (data->uFlags & NIF_ICON)
{
if ((targetIcon && !data->hIcon) || (!targetIcon && data->hIcon))
{
// If the icon has been hidden or shown
need_to_pack_tray = TRUE;
}
}
if (data->uFlags & NIF_ICON && data->hIcon)
targetIcon = CopyIcon(data->hIcon);
if (data->uFlags & NIF_TIP && data->szTip)
{
memset(targetTip, 0, sizeof(targetTip));
if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
WideCharToMultiByte
(
CP_ACP,
0,
(wchar_t *) data->szTip,
wcslen ((wchar_t *) data->szTip),
targetTip,
sizeof (targetTip),
NULL,
NULL
);
}
else
{
strcpy(targetTip, data->szTip);
}
}
trayWnds[i].message = targetMsg;
trayWnds[i].hIcon = targetIcon;
trayWnds[i].uID = data->uID;
if (targetTip) strcpy(trayWnds[i].szTip, targetTip);
SetWindowLong(trayWnds[i].trayWnd, GWL_USERDATA,
(long)targetIcon);
if (need_to_pack_tray)
{
i = packScreenTray(i);
}
if (appBar)
{
r.top = trayWnds[i].y; r.bottom = trayWnds[i].y+trayIconSize;
r.left = trayWnds[i].x; r.right = trayWnds[i].x+trayIconSize;
InvalidateRect(hTrayWnd, &r, TRUE);
}
else
{
r.top = trayWnds[i].y; r.bottom =
trayWnds[i].y+trayIconSize; r.left = trayWnds[i].x; r.right =
trayWnds[i].x+trayIconSize;
InvalidateRect(hMainWnd, &r, TRUE);
}
r.top = 0; r.bottom = trayIconSize; r.left = 0; r.right =
trayIconSize;
if (data->uFlags & NIF_TIP)
{
UpdateTooltips (trayWnds[i].trayWnd, trayWnds[i].szTip, &r);
}
InvalidateRect(trayWnds[i].trayWnd, &r, TRUE);
break;
}
}
return TRUE;
blah, blah, blah