void CJabberDlgGcJoin::OnInitDialog()
{
	CSuper::OnInitDialog();

	Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP));

	JabberGcRecentInfo *pInfo = NULL;
	if (m_jid)
		pInfo = new JabberGcRecentInfo(m_proto, m_jid);
	else if (OpenClipboard(m_hwnd)) {
		HANDLE hData = GetClipboardData(CF_UNICODETEXT);

		if (hData) {
			TCHAR *buf = (TCHAR *)GlobalLock(hData);
			if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' ')))
				pInfo = new JabberGcRecentInfo(m_proto, buf);
			GlobalUnlock(hData);
		}
		CloseClipboard();
	}

	if (pInfo) {
		pInfo->fillForm(m_hwnd);
		delete pInfo;
	}

	ptrT tszNick(m_proto->getTStringA("Nick"));
	if (tszNick == NULL)
		tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
	SetDlgItemText(m_hwnd, IDC_NICK, tszNick);

	TEXTMETRIC tm = { 0 };
	HDC hdc = GetDC(m_hwnd);
	GetTextMetrics(hdc, &tm);
	ReleaseDC(m_hwnd, hdc);
	sttTextLineHeight = tm.tmHeight;
	SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight - 1);

	LOGFONT lf = { 0 };
	HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
	GetObject(hfnt, sizeof(lf), &lf);
	lf.lfWeight = FW_BOLD;
	SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);

	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0);

	m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");

	int i;
	for (i = 0; i < 5; i++) {
		TCHAR jid[JABBER_MAX_JID_LEN];
		JabberGcRecentInfo info(m_proto);
		if (!info.loadRecent(i))
			break;

		mir_sntprintf(jid, _T("%s@%s (%s)"), info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>"));
		SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid);
	}
	sttJoinDlgShowRecentItems(m_hwnd, i);
}
void CJabberDlgGcJoin::OnInitDialog()
{
	CSuper::OnInitDialog();

	WindowSetIcon( m_hwnd, m_proto, "group" );

	JabberGcRecentInfo *info = NULL;
	if ( m_jid )
		info = new JabberGcRecentInfo( m_proto, m_jid );
	else
	{
		OpenClipboard(m_hwnd);
#ifdef UNICODE
		HANDLE hData = GetClipboardData(CF_UNICODETEXT);
#else
		HANDLE hData = GetClipboardData(CF_TEXT);
#endif
		if (hData)
		{
			TCHAR *buf = (TCHAR *)GlobalLock(hData);
			if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' ')))
				info = new JabberGcRecentInfo( m_proto, buf );
			GlobalUnlock(hData);
		}
		CloseClipboard();
	}

	if (info)
	{
		info->fillForm(m_hwnd);
		delete info;
	}

	DBVARIANT dbv;
	if ( !m_proto->JGetStringT( NULL, "Nick", &dbv )) {
		SetDlgItemText( m_hwnd, IDC_NICK, dbv.ptszVal );
		JFreeVariant( &dbv );
	}
	else {
		TCHAR* nick = JabberNickFromJID( m_proto->m_szJabberJID );
		SetDlgItemText( m_hwnd, IDC_NICK, nick );
		mir_free( nick );
	}

	{
		TEXTMETRIC tm = {0};
		HDC hdc = GetDC(m_hwnd);
		GetTextMetrics(hdc, &tm);
		ReleaseDC(m_hwnd, hdc);
		sttTextLineHeight = tm.tmHeight;
		SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight-1);
	}

	{
		LOGFONT lf = {0};
		HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
		GetObject(hfnt, sizeof(lf), &lf);
		lf.lfWeight = FW_BOLD;
		SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
	}

	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, 0, 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, 0, 0);

	m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");

	int i = 0;
	for ( ; i < 5; ++i)
	{
		TCHAR jid[JABBER_MAX_JID_LEN];
		JabberGcRecentInfo info( m_proto );
		if (info.loadRecent(i))
		{
			mir_sntprintf(jid, SIZEOF(jid), _T("%s@%s (%s)"),
				info.room, info.server,
				info.nick ? info.nick : TranslateT("<no nick>") );
			SetDlgItemText(m_hwnd, IDC_RECENT1+i, jid);
		} else
		{
			break;
		}
	}
	sttJoinDlgShowRecentItems(m_hwnd, i);
}