fix tray icon config dialog for the first icon
Modified: trunk/reactos/subsys/system/explorer/taskbar/desktopbar.cpp
Modified: trunk/reactos/subsys/system/explorer/taskbar/traynotify.cpp
Modified: trunk/reactos/subsys/system/explorer/taskbar/traynotify.h

Modified: trunk/reactos/subsys/system/explorer/taskbar/desktopbar.cpp
--- trunk/reactos/subsys/system/explorer/taskbar/desktopbar.cpp	2005-04-02 11:21:46 UTC (rev 14438)
+++ trunk/reactos/subsys/system/explorer/taskbar/desktopbar.cpp	2005-04-02 11:40:58 UTC (rev 14439)
@@ -47,7 +47,7 @@
 	WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
 #endif
 {
-	SetWindowIcon(hwnd, IDI_REACTOS/*IDI_SEARCH*/);	// icon in for TrayNotifyDlg
+	SetWindowIcon(hwnd, IDI_REACTOS);
 
 	SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0);
 }

Modified: trunk/reactos/subsys/system/explorer/taskbar/traynotify.cpp
--- trunk/reactos/subsys/system/explorer/taskbar/traynotify.cpp	2005-04-02 11:21:46 UTC (rev 14438)
+++ trunk/reactos/subsys/system/explorer/taskbar/traynotify.cpp	2005-04-02 11:40:58 UTC (rev 14439)
@@ -905,7 +905,7 @@
 		_show_hidden_org = _pNotifyArea->_show_hidden;
 	}
 
-	SetWindowIcon(hwnd, IDI_REACTOS/*IDI_SEARCH*/);
+	SetWindowIcon(hwnd, IDI_REACTOS);
 
 	_haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_TRAYNOTIFY));
 
@@ -1053,7 +1053,7 @@
 void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo& entry,
 								HDC hdc, HICON hicon, NOTIFYICONMODE mode)
 {
-	int idx = _info.size();
+	int idx = _info.size() + 1;
 	_info[idx] = entry;
 
 	String mode_str = string_from_mode(mode);
@@ -1163,42 +1163,10 @@
 	switch(pnmh->code) {
 	  case TVN_SELCHANGED: {
 		NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh;
-		LPARAM lparam = pnmtv->itemNew.lParam;
+		int idx = pnmtv->itemNew.lParam;
 
-		if (lparam) {
-			const NotifyIconDlgInfo& entry = _info[lparam];
-
-			SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, entry._tipText);
-			SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, entry._windowTitle);
-			SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, entry._modulePath);
-
-			CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW+entry._mode);
-
-			String change_str;
-			if (entry._lastChange)
-				change_str.printf(TEXT("before %d s"), (GetTickCount()-entry._lastChange+500)/1000);
-			SetDlgItemText(_hwnd, IDC_LAST_CHANGE, change_str);
-
-			HICON hicon = 0; //get_window_icon_big(entry._hWnd, false);
-
-			 // If we could not find an icon associated with the owner window, try to load one from the owning module.
-			if (!hicon && !entry._modulePath.empty()) {
-				hicon = ExtractIcon(g_Globals._hInstance, entry._modulePath, 0);
-
-				if (!hicon) {
-					SHFILEINFO sfi;
-
-					if (SHGetFileInfo(entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_LARGEICON))
-						hicon = sfi.hIcon;
-				}
-			}
-
-			if (hicon) {
-				SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, (LPARAM)hicon, 0);
-				DestroyIcon(hicon);
-			} else
-				SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, 0, 0);
-
+		if (idx) {
+			RefreshProperties(_info[idx]);
 			_selectedItem = pnmtv->itemNew.hItem;
 		} else {
 			/*
@@ -1214,14 +1182,48 @@
 	return 0;
 }
 
+void TrayNotifyDlg::RefreshProperties(const NotifyIconDlgInfo& entry)
+{
+	SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, entry._tipText);
+	SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, entry._windowTitle);
+	SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, entry._modulePath);
+
+	CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW+entry._mode);
+
+	String change_str;
+	if (entry._lastChange)
+		change_str.printf(TEXT("before %d s"), (GetTickCount()-entry._lastChange+500)/1000);
+	SetDlgItemText(_hwnd, IDC_LAST_CHANGE, change_str);
+
+	HICON hicon = 0; //get_window_icon_big(entry._hWnd, false);
+
+	 // If we could not find an icon associated with the owner window, try to load one from the owning module.
+	if (!hicon && !entry._modulePath.empty()) {
+		hicon = ExtractIcon(g_Globals._hInstance, entry._modulePath, 0);
+
+		if (!hicon) {
+			SHFILEINFO sfi;
+
+			if (SHGetFileInfo(entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_LARGEICON))
+				hicon = sfi.hIcon;
+		}
+	}
+
+	if (hicon) {
+		SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, (LPARAM)hicon, 0);
+		DestroyIcon(hicon);
+	} else
+		SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, 0, 0);
+}
+
 void TrayNotifyDlg::SetIconMode(NOTIFYICONMODE mode)
 {
-	LPARAM lparam = TreeView_GetItemData(_tree_ctrl, _selectedItem);
+	int idx = TreeView_GetItemData(_tree_ctrl, _selectedItem);
 
-	if (!lparam)
+	if (!idx)
 		return;
 
-	NotifyIconConfig& entry = _info[lparam];
+	NotifyIconConfig& entry = _info[idx];
 
 	if (entry._mode != mode) {
 		entry._mode = mode;

Modified: trunk/reactos/subsys/system/explorer/taskbar/traynotify.h
--- trunk/reactos/subsys/system/explorer/taskbar/traynotify.h	2005-04-02 11:21:46 UTC (rev 14438)
+++ trunk/reactos/subsys/system/explorer/taskbar/traynotify.h	2005-04-02 11:40:58 UTC (rev 14439)
@@ -230,6 +230,7 @@
 	void	InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyInfo&, HDC);
 	void	InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo&, HDC, HICON, NOTIFYICONMODE);
 	void	SetIconMode(NOTIFYICONMODE mode);
+	void	RefreshProperties(const NotifyIconDlgInfo& entry);
 };