コード例 #1
0
ファイル: richcall.cpp プロジェクト: Seldom/miranda-ng
bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew)
{
	RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd);
	if (rdt == NULL) {
		IRichEditOle* RichEditOle;
		if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0)
			return false;
		RichEditOle->Release();

		rdt = new RichEditData;

		rdt->hwnd = hwnd;
		rdt->hContact = hContact;
		rdt->inputarea = (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY) == 0;
		rdt->dontReplace = false;
		rdt->tipActive = -1;
		rdt->hToolTip = NULL;
		g_RichEditList.insert(rdt);

		if (subnew)
			mir_subclassWindow(hwnd, RichEditSubclass);
	}
	else {
		if (hContact && !rdt->hContact)
			rdt->hContact = hContact; 

		if (subany) 
			mir_subclassWindow(hwnd, RichEditSubclass);
	}
	return true;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: truefriend-cz/miranda-ng
static int OnModulesLoded(WPARAM, LPARAM)
{
	HookEvent(ME_CLIST_CONTACTICONCHANGED, OnContactIconChanged);
	HookEvent(ME_SKIN_ICONSCHANGED, OnSkinIconsChanged);
	HookEvent(ME_CLUI_CONTACTDRAGGING, OnContactDrag);
	HookEvent(ME_CLUI_CONTACTDROPPED, OnContactDrop);
	HookEvent(ME_CLUI_CONTACTDRAGSTOP, OnContactDragStop);
	HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
	HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted);
	HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize);
	HookEvent(ME_CLIST_STATUSMODECHANGE, OnStatusModeChange);
	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu);

	hwndMiranda = pcli->hwndContactList;
	mir_subclassWindow(hwndMiranda, newMirandaWndProc);

	// No thumbs yet
	bEnableTip = ServiceExists("mToolTip/ShowTip");

	RegisterWindowClass();
	GetScreenRect();
	LoadDBSettings();
	CreateBackgroundBrush();
	CreateThumbsFont();
	LoadContacts();
	LoadMenus();

	if (fcOpt.bToTop) {
		fcOpt.ToTopTime = (fcOpt.ToTopTime < 1) ? 1 : fcOpt.ToTopTime;
		fcOpt.ToTopTime = (fcOpt.ToTopTime > TOTOPTIME_MAX) ? TOTOPTIME_MAX : fcOpt.ToTopTime;
		ToTopTimerID = SetTimer(NULL, 0, fcOpt.ToTopTime*TOTOPTIME_P, ToTopTimerProc);
	}
	return 0;
}
コード例 #3
0
ファイル: userinfo.cpp プロジェクト: MrtsComputers/miranda-ng
INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
	DBVARIANT dbv;
	
	switch(msg) {
	case WM_INITDIALOG:
		mir_subclassWindow( GetDlgItem(hdlg, IDC_INFOTEXT), EditProc);
		{
			TCHAR *szout;
			if ( !db_get_ts(NULL, S_MOD, "UserStamp", &dbv)) {
				szout = ParseString(dbv.ptszVal, (HANDLE)lparam, 0);
				db_free(&dbv);
			}
			else szout = ParseString(DEFAULT_USERSTAMP, (HANDLE)lparam, 0);

			SetDlgItemText(hdlg, IDC_INFOTEXT, szout);
			if ( !lstrcmp(szout, TranslateT("<unknown>")))
				EnableWindow( GetDlgItem(hdlg, IDC_INFOTEXT), FALSE);
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wparam) == EN_SETFOCUS)
			SetFocus( GetParent(hdlg));
		break;
	}

	return 0;
}
コード例 #4
0
ファイル: clcutils.cpp プロジェクト: MrtsComputers/miranda-ng
void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat)
{
	ClcContact *contact;
	ClcGroup *group;
	POINT pt;

	KillTimer(hwnd, TIMERID_RENAME);
	ReleaseCapture();
	dat->iHotTrack = -1;
	dat->selection = cli.pfnGetRowByIndex(dat, dat->selection, &contact, &group);
	if (dat->selection == -1)
		return;
	if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP)
		return;

	RECT clRect;
	GetClientRect(hwnd, &clRect);
	cli.pfnCalcEipPosition(dat, contact, group, &pt);
	int h = cli.pfnGetRowHeight(dat, dat->selection);
	dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, pt.x, pt.y, clRect.right - pt.x, h, hwnd, NULL, cli.hInst, NULL);
	mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc);
	SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM) (contact->type == CLCIT_GROUP ? dat->fontInfo[FONTID_GROUPS].hFont : dat->fontInfo[FONTID_CONTACTS].hFont), 0);
	SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0);
	SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, (LPARAM) (-1));
	ShowWindow(dat->hwndRenameEdit, SW_SHOW);
	SetFocus(dat->hwndRenameEdit);
}
コード例 #5
0
ファイル: modern_tbbutton.cpp プロジェクト: ybznek/miranda-ng
void MakeButtonSkinned(HWND hWnd)
{
	SendMessage(hWnd, BUTTONSETCUSTOMPAINT, sizeof(TBBUTTONDATA), (LPARAM)PaintWorker);
	mir_subclassWindow(hWnd, ToolbarButtonProc);

	TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0);
	p->nFontID = -1;
	p->hThemeButton = xpt_AddThemeHandle(p->hwnd, L"BUTTON");
	p->hThemeToolbar = xpt_AddThemeHandle(p->hwnd, L"TOOLBAR");
	WindowList_Add(hButtonWindowList, hWnd, NULL);
}
コード例 #6
0
ファイル: clcutils.cpp プロジェクト: Seldom/miranda-ng
void BeginRenameSelection(HWND hwnd, struct ClcData *dat)
{
	ClcContact *contact;
	ClcGroup *group;
	int indent, x, y, h;
	RECT clRect;

	KillTimer(hwnd, TIMERID_RENAME);
	ReleaseCapture();
	dat->iHotTrack = -1;
	dat->selection = pcli->pfnGetRowByIndex(dat, dat->selection, &contact, &group);
	if (dat->selection == -1)
		return;
	if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP)
		return;
	for (indent = 0; group->parent; indent++, group = group->parent) {
		;
	}
	GetClientRect(hwnd, &clRect);
	x = indent * dat->groupIndent + dat->iconXSpace - 2;
	//y = dat->selection * dat->rowHeight - dat->yScroll;
	y = RowHeight::getItemTopY(dat, dat->selection) - dat->yScroll;

	h = dat->row_heights[dat->selection];
	{
		int i;
		for (i = 0; i <= FONTID_LAST; i++)
			if (h < dat->fontInfo[i].fontHeight + 2) h = dat->fontInfo[i].fontHeight + 2;
	}

	dat->hwndRenameEdit = CreateWindowEx(0, _T("RICHEDIT50W"), contact->szText, WS_CHILD | WS_BORDER | ES_MULTILINE | ES_AUTOHSCROLL, x, y, clRect.right - x, h, hwnd, NULL, g_hInst, NULL);
	{
		if ((contact->type == CLCIT_CONTACT && contact->pExtra->dwCFlags & ECF_RTLNICK) || (contact->type == CLCIT_GROUP && contact->isRtl)) {
			PARAFORMAT2 pf2;
			memset(&pf2, 0, sizeof(pf2));
			pf2.cbSize = sizeof(pf2);
			pf2.dwMask = PFM_RTLPARA;
			pf2.wEffects = PFE_RTLPARA;
			SetWindowText(dat->hwndRenameEdit, _T(""));
			SendMessage(dat->hwndRenameEdit, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
			SetWindowText(dat->hwndRenameEdit, contact->szText);
		}
	}

	//dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, x, y, clRect.right - x, dat->rowHeight, hwnd, NULL, g_hInst, NULL);
	mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc);
	SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM)(contact->type == CLCIT_GROUP ? dat->fontInfo[FONTID_GROUPS].hFont : dat->fontInfo[FONTID_CONTACTS].hFont), 0);
	SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0);
	SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, (LPARAM)(-1));
	ShowWindow(dat->hwndRenameEdit, SW_SHOW);
	SetFocus(dat->hwndRenameEdit);
}
コード例 #7
0
ファイル: richutil.cpp プロジェクト: Ganster41/miranda-ng
int RichUtil_SubClass(HWND hwndEdit) {
	if (IsWindow(hwndEdit)) {
		TRichUtil *ru = (TRichUtil*)malloc(sizeof(TRichUtil));
		
		ZeroMemory(ru, sizeof(TRichUtil));
		ru->hwnd = hwndEdit;
		ru->hasUglyBorder = 0;
		EnterCriticalSection(&csRich);
		slist = rlist_append(slist, ru);
		LeaveCriticalSection(&csRich);
		SetWindowLongPtr(ru->hwnd, GWLP_USERDATA, (LONG_PTR)ru); // Ugly hack
		mir_subclassWindow(ru->hwnd, RichUtil_Proc);
		RichUtil_ClearUglyBorder(ru);
		return 1;
	}
	return 0;
}
コード例 #8
0
ファイル: classPsTree.cpp プロジェクト: 0xmono/miranda-ng
/**
 * name:	BeginLabelEdit
 * class:	CPsTree
 * desc:	begins the labeledit mode
 * param:	hItem		- handle of the treeitm whose label to edit
 * return:	0
 **/
int CPsTree::BeginLabelEdit(HTREEITEM hItem)
{
	CPsTreeItem* pti;

	// tree is readonly
	if (db_get_b(NULL, MODNAME, SET_PROPSHEET_READONLYLABEL, 0))
		return 0;

	// get item text
	if (!hItem && !(hItem = TreeView_GetSelection(_hWndTree)))
		return 0;
	if (pti = FindItemByHandle(hItem))
		{
		RECT rc, rcTree;

		// create the edit control
		GetClientRect(_hWndTree, &rcTree);
		TreeView_GetItemRect(_hWndTree, hItem, &rc, TRUE);
		_hLabelEdit = CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE,
						_T( "EDIT" ),
						pti->Label(),
						WS_VISIBLE|ES_AUTOHSCROLL|WS_CHILD,
						rc.left, rc.top,
						rcTree.right - rc.left, rc.bottom - rc.top,
						_hWndTree,
						NULL,
						ghInst,
						NULL );
		if (_hLabelEdit)
		{
			_hDragItem = hItem;
			SetUserData(_hLabelEdit, this);
			mir_subclassWindow(_hLabelEdit, TPropsheetTree_LabelEditProc);
			SendMessage(_hLabelEdit, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0 );
			Edit_SetSel(_hLabelEdit, 0, -1);
			Edit_LimitText(_hLabelEdit, MAX_TINAME);
			SetFocus(_hLabelEdit);
			return 0;
		}
	}
	return 1;
}
コード例 #9
0
ファイル: richutil.cpp プロジェクト: Seldom/miranda-ng
int RichUtil_SubClass(HWND hwndEdit)
{
	if (IsWindow(hwndEdit)) {
		int idx;

		TRichUtil *ru = (TRichUtil *)mir_calloc(sizeof(TRichUtil));

		ru->hwnd = hwndEdit;
		ru->hasUglyBorder = 0;
		{
			mir_cslock lck(csRich);
			if (!List_GetIndex(&sListInt, ru, &idx))
				List_Insert(&sListInt, ru, idx);
		}
		mir_subclassWindow(ru->hwnd, RichUtil_Proc);
		RichUtil_ClearUglyBorder(ru);
		return 1;
	}
	return 0;
}
コード例 #10
0
ファイル: richcall.cpp プロジェクト: Seldom/miranda-ng
void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog)
{
	RichEditOwnerData* rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd);
	if (rdto == NULL) {
		rdto = new RichEditOwnerData;
		rdto->hwnd = hwnd;
		rdto->hwndInput = hwndInput;
		rdto->hwndLog = hwndLog;
		g_RichEditOwnerList.insert(rdto);

		if (hwndLog)
			SendMessage(hwndLog, EM_SETUNDOLIMIT, 0, 0);

		mir_subclassWindow(hwnd, RichEditOwnerSubclass);
	}
	else {
		if (rdto->hwndInput == NULL) rdto->hwndInput = hwndInput;
		if (rdto->hwndLog == NULL) rdto->hwndLog = hwndLog;
	}
}
コード例 #11
0
ファイル: profilemanager.cpp プロジェクト: Seldom/miranda-ng
    virtual void OnInitDialog()
    {
        // what, no plugins?!
        if (arDbPlugins.getCount() == 0) {
            m_driverList.Enable(false);
            m_profileName.Enable(false);
            ShowWindow(m_warning.GetHwnd(), TRUE);
        }
        else {
            for (int i = 0; i < arDbPlugins.getCount(); i++) {
                DATABASELINK *p = arDbPlugins[i];
                m_driverList.AddString(TranslateTS(p->szFullName), (LPARAM)p);
            }
        }

        // default item
        m_driverList.SetCurSel(0);

        // subclass the profile name box
        mir_subclassWindow(m_profileName.GetHwnd(), ProfileNameValidate);

        // decide if there is a default profile name given in the INI and if it should be used
        if (m_pd->noProfiles || (shouldAutoCreate(m_pd->ptszProfile) && _taccess(m_pd->ptszProfile, 0))) {
            TCHAR *profile = _tcsrchr(m_pd->ptszProfile, '\\');
            if (profile) ++profile;
            else profile = m_pd->ptszProfile;

            TCHAR *p = _tcsrchr(profile, '.');
            TCHAR c = 0;
            if (p) {
                c = *p;
                *p = 0;
            }

            m_profileName.SetText(profile);
            if (c) *p = c;
        }

        // focus on the textbox
        PostMessage(m_hwnd, WM_FOCUSTEXTBOX, 0, 0);
    }
コード例 #12
0
static void MsgWndDetect(HWND hwndDlg, HANDLE hContact, msgData* datm)
{
	MsgWndData dat;

	if (dat.IsMessageSendDialog(hwndDlg)) {
		dat.hwnd = hwndDlg;
		if (datm != NULL) {
			dat.isSend = datm->isSend != 0;
			dat.hContact = datm->hContact;
		}
		else dat.hContact = hContact;

		// Get the protocol for this contact to display correct smileys.
		char *protonam = GetContactProto( DecodeMetaContact(dat.hContact));
		if (protonam) {
			strncpy(dat.ProtocolName, protonam, sizeof(dat.ProtocolName));
			dat.ProtocolName[sizeof(dat.ProtocolName)-1] = 0;
		}

		WaitForSingleObject(g_hMutex, 2000);

		MsgWndData* msgwnd = g_MsgWndList.find((MsgWndData*)&hwndDlg);
		if (msgwnd == NULL) {
			msgwnd = new MsgWndData(dat);
			g_MsgWndList.insert(msgwnd);
		}
		else 
			msgwnd = NULL;
		ReleaseMutex(g_hMutex);

		if (msgwnd != NULL) {
			mir_subclassWindow(hwndDlg, MessageDlgSubclass);
			msgwnd->CreateSmileyButton();
			if (hContact == NULL)
				SetRichCallback(msgwnd->REdit, msgwnd->hContact, true, true);
		}
	}
}
コード例 #13
0
/**
 * name:		OpenSaveFileDialogHook
 * desc:		it subclasses the places bar to provide the own interface for adding places
 * params:		hDlg	- handle, to control's window
 *				uMsg	- the message to handle
 *				wParam	- message dependend parameter
 *				lParam	- message dependend parameter
 * return:		depends on message
 **/
static UINT_PTR CALLBACK OpenSaveFileDialogHook(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {
	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == CDN_INITDONE) {
			HWND hPlacesBar = GetDlgItem(GetParent(hDlg), ctl1);

			// we have a places bar?
			if (hPlacesBar != NULL) {
				InitAlteredPlacesBar();
				// finally subclass the places bar
				mir_subclassWindow(hPlacesBar, PlacesBarSubclassProc);
			}
		}
		break;
	case WM_DESTROY:
		// unmap registry and delete keys 
		// (is to make it sure, if somehow the last places button was not added which also calls this function)
		ResetAlteredPlaceBars();
		break;
	}
	return FALSE;
}
コード例 #14
0
void CustomizeToolbar(HWND hwnd)
{
	mir_subclassWindow(hwnd, toolbarWndProc);
	SendMessage(hwnd, TTB_SETCUSTOMDATASIZE, 0, sizeof(ModernToolbarCtrl));

	ModernToolbarCtrl* pMTBInfo = (ModernToolbarCtrl*)GetWindowLongPtr(hwnd, 0);

	CLISTFrame Frame = { sizeof(Frame) };
	Frame.tname = _T("Toolbar");
	Frame.hWnd = hwnd;
	Frame.align = alTop;
	Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_TCHAR | F_NO_SUBCONTAINER;
	Frame.height = 18;
	Frame.hIcon = LoadSkinnedIcon(SKINICON_OTHER_FRAME);
	pMTBInfo->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);

	CallService(MS_SKINENG_REGISTERPAINTSUB, (WPARAM)hwnd, (LPARAM)ToolBar_LayeredPaintProc);

	pMTBInfo->mtbXPTheme = xpt_AddThemeHandle(hwnd, L"TOOLBAR");
	pMTBInfo->bHardUpdate = TRUE;

	Modern_InitButtons();
}
コード例 #15
0
ファイル: Options.cpp プロジェクト: kxepal/miranda-ng
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	char str[20];

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, UpdateOnStartup ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, OnlyOnceADay ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), UpdateOnStartup);
		CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, UpdateOnPeriod ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), UpdateOnPeriod);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), UpdateOnPeriod);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), UpdateOnPeriod);

		SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
		SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)Period);

		Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
		mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PERIOD), MyEditProc);

		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours"));
		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
		ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure);

		CheckDlgButton(hwndDlg, IDC_REMINDER, Reminder ? BST_CHECKED : BST_UNCHECKED);
		if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
			ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE);
		}
		else {
			for (int i = 1; i < POPUPS; i++) {
				mir_snprintf(str, "Popups%dM", i);
				CheckDlgButton(hwndDlg, (i + 1029), (db_get_b(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
			}
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_UPDATEONSTARTUP:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
			break;

		case IDC_ONLYONCEADAY:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_UPDATEONPERIOD:
		{
			BOOL value = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), value);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), value);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), value);
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		}
		break;

		case IDC_PERIODMEASURE:
			if (HIWORD(wParam) == CBN_SELCHANGE)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_REMINDER:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_LINK_HOTKEY:
		{
			OPENOPTIONSDIALOG ood = { sizeof(ood) };
			ood.pszGroup = "Customize";
			ood.pszPage = "Hotkeys";
			Options_Open(&ood);
		}
		return true;

		case IDC_MSG_BOXES2:
		case IDC_ERRORS2:
		case IDC_INFO_MESSAGES2:
		case IDC_PROGR_DLG2:
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
	{
		NMHDR *hdr = (NMHDR *)lParam;
		if (hdr && hdr->code == UDN_DELTAPOS)
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

		if (hdr && hdr->code == PSN_APPLY) {
			UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
			OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);

			UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);

			char buffer[3] = { 0 };
			Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2);
			Period = atoi(buffer);

			PeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));

			InitTimer();

			db_set_b(NULL, MODNAME, "UpdateOnStartup", UpdateOnStartup);
			db_set_b(NULL, MODNAME, "OnlyOnceADay", OnlyOnceADay);
			db_set_b(NULL, MODNAME, "UpdateOnPeriod", UpdateOnPeriod);
			db_set_dw(NULL, MODNAME, "Period", Period);
			db_set_b(NULL, MODNAME, "PeriodMeasure", PeriodMeasure);
			Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER);
			db_set_b(NULL, MODNAME, "Reminder", Reminder);
			if (!ServiceExists(MS_POPUP_ADDPOPUPT)) {
				for (int i = 1; i < POPUPS; i++) {
					mir_snprintf(str, "Popups%dM", i);
					db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i + 1029))));
				}
			}
		}
		break;
	}
	}
	return FALSE;
}
コード例 #16
0
ファイル: opt_skins.cpp プロジェクト: 0xmono/miranda-ng
INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool bDlgInit = false;	//some controls send WM_COMMAND before or during WM_INITDIALOG
	static HANDLE hhkFontsReload = 0;
	static OPTTREE_OPTION *skinOptions = NULL;
	static int skinOptionsCount = 0;

	if (skinOptions) {
		int index = -1;
		OptTree_ProcessMessage(hwndDlg, msg, wParam, lParam, &index, IDC_SKIN_LIST_OPT, skinOptions, skinOptionsCount);
		if (index != -1) {
			if (lstrcmp(skinOptions[index].pszSettingName, _T("Skin options")) == 0) {
				const PopupSkin *skin = 0;
				if (skin = skins.getSkin(PopupOptions.SkinPack)) {
					skin->setFlag(skinOptions[index].Data, skinOptions[index].bState ? true : false);
				}
			}
			else if (lstrcmp(skinOptions[index].pszSettingName, _T("Global settings")) == 0) {
				switch (skinOptions[index].dwFlag) {
				case (1 << 0):
					PopupOptions.DisplayTime = skinOptions[index].bState;
					break;
				case (1 << 1):
					PopupOptions.DropShadow = skinOptions[index].bState;
					break;
				case (1 << 2):
					PopupOptions.EnableFreeformShadows = skinOptions[index].bState;
					break;
				case (1 << 3):
					PopupOptions.EnableAeroGlass = skinOptions[index].bState;
					break;
				case (1 << 4):
					PopupOptions.UseWinColors = skinOptions[index].bState;
					break;
				case (1 << 5):
					PopupOptions.UseMText = skinOptions[index].bState;
					break;
				}
			}
			updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
			return FALSE;
		}
	}

	switch (msg) {
	case WM_INITDIALOG:
		{
			HWND		hCtrl	= NULL;
			DWORD		dwIndex	= 0;

			//Skin List
			hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
			ListBox_ResetContent(hCtrl);
			LPTSTR Temp = NULL;
			for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next)
			{
				dwIndex = ListBox_AddString(hCtrl, sl->name);
				ListBox_SetItemData(hCtrl, dwIndex, sl->name);
			}
			ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));

			//Skin List reload button
			SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BUTTONSETASFLATBTN, TRUE, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD,0));
			SendMessage(GetDlgItem(hwndDlg, IDC_BTN_RELOAD), BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0);

			//Skin Option List
			SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg);

			//PreviewBox
			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox);
			updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));

			//hooks
			hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER);

			TranslateDialogDefault(hwndDlg);
			bDlgInit = true;
		}
		return TRUE;

	case WM_USER:
		updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
		return TRUE;

	case WM_COMMAND:
		{
			HWND hCtrl	= NULL;
			UINT idCtrl	= LOWORD(wParam);
			switch (HIWORD(wParam)) {
			case BN_KILLFOCUS:		//Button controls
			case BN_SETFOCUS:		//Button controls
				return TRUE;
				break;
			case BN_CLICKED:		//Button controls
				switch(idCtrl) {
				case IDC_PREVIEW:
					PopupPreview();
					break;

				case IDC_BTN_RELOAD:
					{
						LPTSTR Temp		= NULL;
						DWORD  dwIndex	= 0;
						TCHAR  szNewSkin[128];
						LPTSTR pszOldSkin = mir_tstrdup(PopupOptions.SkinPack);
						skins.load(_T(""));
						hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
						ListBox_ResetContent(hCtrl);
						for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next)
						{
							dwIndex = ListBox_AddString(hCtrl, sl->name);
							ListBox_SetItemData(hCtrl, dwIndex, sl->name);
						}
						ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));
						//make shure we have select skin (ListBox_SetCurSel may be fail)
						ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin);
						if (lstrcmp(pszOldSkin, szNewSkin) != 0) {
							mir_free(PopupOptions.SkinPack);
							PopupOptions.SkinPack = mir_tstrdup(szNewSkin);
						}
						mir_free(pszOldSkin);

						const PopupSkin *skin = 0;
						if (skin = skins.getSkin(PopupOptions.SkinPack)) {
							//update Skin Option List from reload SkinPack
							bDlgInit = false;
							bDlgInit = SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg);
						}

						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					}//end IDC_BTN_RELOAD:
					break;
				case IDC_GETSKINS:
					CallService(MS_UTILS_OPENURL,0,(LPARAM)"http://miranda-ng.org/");
					break;
				}//end switch(idCtrl)
				updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
				break;
			case CBN_SELCHANGE:		//combo box controls
				switch(idCtrl) {
				case IDC_SKINLIST:
					{
						//Skin list change
						mir_free(PopupOptions.SkinPack);
						PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage(
							hwndDlg,
							IDC_SKINLIST,
							LB_GETITEMDATA,
							(WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL,0,0),
							0));
						const PopupSkin *skin = 0;
						if (skin = skins.getSkin(PopupOptions.SkinPack)) {
							mir_free(PopupOptions.SkinPack);
							PopupOptions.SkinPack = mir_tstrdup(skin->getName());

							//update Skin Option List
							bDlgInit = false;
							bDlgInit = SkinOptionList_Update (skinOptions, &skinOptionsCount, hwndDlg);
						}
						updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
					}
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					break;
				}//end switch(idCtrl)
				break;
			}//end switch (HIWORD(wParam))
			break;
		}// end WM_COMMAND
		return FALSE;

	case WM_NOTIFY:
		if (!bDlgInit) return FALSE;
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadOption_Skins();
				return TRUE;

			case PSN_APPLY: 
				{
					//skin pack
					db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack);
					//skin options
					const PopupSkin *skin = 0;
					if (skin = skins.getSkin(PopupOptions.SkinPack))
						skin->saveOpts();
					skins.freeAllButActive();
					//more Skin options
					db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime);
					db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow);
					db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows);
					db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass);
					db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText);
				}//end PSN_APPLY:
				return TRUE;
			}//switch (((LPNMHDR)lParam)->code)
			break;
		}//end switch (((LPNMHDR)lParam)->idFrom)
		return FALSE;

	case WM_DESTROY:
		if (wndPreview) {
			delete wndPreview;
			wndPreview = NULL;
			gPreviewOk = false;
		}
		if (hhkFontsReload) UnhookEvent(hhkFontsReload);
		if (skinOptions) {
			for (int i=0; i < skinOptionsCount; ++i) {
				mir_free(skinOptions[i].pszOptionName);
				mir_free(skinOptions[i].pszSettingName);
			}
			mir_free(skinOptions);
			skinOptions = NULL;
			skinOptionsCount = 0;
		}
		return TRUE;
	}//end switch (msg)
	return FALSE;
}
コード例 #17
0
ファイル: options.cpp プロジェクト: kmdtukl/miranda-ng
INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg) {
	case WM_INITDIALOG:
		{
			char key[64];
			int count = 0;
			CMString replies;

			TranslateDialogDefault(hwndDlg);
			variables_skin_helpbutton(hwndDlg, IDC_VARIABLES);
			ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLES_HINT), ServiceExists(MS_VARS_FORMATSTRING));

			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_REPLIES), MessageEditSubclassProc);

			mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber);
			CheckDlgButton(hwndDlg, IDC_IMMEDIATELY, db_get_w(NULL, MODULE, key, 1) ? BST_CHECKED : BST_UNCHECKED);

			mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
			count = db_get_w(NULL, MODULE, key, 0);

			for (int i = 0; i < count; i++)
			{
				mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i);
				wchar_t *value = db_get_wsa(NULL, MODULE, key);
				if (value)
				{
					replies.Append(value);
					replies.Append(_T("\r\n"));
				}
				mir_free(value);
			}
			SetDlgItemText(hwndDlg, IDC_REPLIES, replies.GetBuffer());
		}
		return TRUE;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch(LOWORD(wParam)) {
			case IDC_VARIABLES:
				variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL);
				break;

			case IDC_IMMEDIATELY:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
		}
		break;

	case WM_NOTIFY:
		{
			NMHDR *p = ((LPNMHDR)lParam);

			switch (p->code) {
			case PSN_APPLY:
				{
					char key[64];
					int count = 0;
					wchar_t *tszReplies;

					mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
					count = db_get_b(NULL, MODULE, key, 0);

					for (int i = 0; i < count; i++)
					{
						mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i);
						db_unset(NULL, MODULE, key);
					}

					int length = SendDlgItemMessage(hwndDlg, IDC_REPLIES, WM_GETTEXTLENGTH, 0, 0);
					tszReplies = (wchar_t*)mir_alloc(sizeof(wchar_t)* (length + 1));
					GetDlgItemText(hwndDlg, IDC_REPLIES, tszReplies, length + 1);
					tszReplies[length] = '\0';
					{
						CMString replies = tszReplies;
						if (replies.Right(2) != _T("\r\n"))
							replies.Append(_T("\r\n"));

						count = 0;
						int pos = -1, prev = 0;
						while ((pos = replies.Find(_T("\r\n"), prev)) != -1)
						{
							mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, count++);
							db_set_ws(NULL, MODULE, key, replies.Mid(prev, pos - prev).GetBuffer());
							prev = pos + 2;
						}
					}
					mir_free(tszReplies);

					mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
					db_set_w(NULL, MODULE, key, count);

					mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber);
					db_set_b(NULL, MODULE, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY));

					return TRUE;
				}
				break;
			}
		}
		break;
	}

	if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam)
		SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

	return FALSE;
}
コード例 #18
0
ファイル: options.cpp プロジェクト: Ganster41/miranda-ng
static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	OptionsPageData *opd;
	OptionsDlgData *dat = (OptionsDlgData*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
	HWND hwndTree = GetDlgItem(hdlg, IDC_PAGETREE);

	switch (message) {
	case WM_CTLCOLORSTATIC:
		switch (GetDlgCtrlID((HWND)lParam)) {
		case IDC_WHITERECT:
		case IDC_KEYWORD_FILTER:
			SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
			return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
		}
		break;

	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);

		if (!ServiceExists(MS_MODERNOPT_SHOW))
			ShowWindow(GetDlgItem(hdlg, IDC_MODERN), FALSE);
		{
			PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam;
			OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage;

			COMBOBOXINFO cbi;
			cbi.cbSize = sizeof(COMBOBOXINFO);
			GetComboBoxInfo(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
			mir_subclassWindow(cbi.hwndItem, OptionsFilterSubclassProc);

			if (IsAeroMode()) {
				mir_subclassWindow(cbi.hwndCombo, AeroPaintSubclassProc);
				mir_subclassWindow(cbi.hwndItem, AeroPaintSubclassProc);
			}

			Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", "");
			Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS);
			EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
			dat = new OptionsDlgData;
			SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat);
			SetWindowText(hdlg, psh->pszCaption);

			LOGFONT lf;
			dat->hBoldFont = (HFONT)SendDlgItemMessage(hdlg, IDC_APPLY, WM_GETFONT, 0, 0);
			GetObject(dat->hBoldFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;
			dat->hBoldFont = CreateFontIndirect(&lf);

			dat->hPluginLoad = HookEventMessage(ME_SYSTEM_MODULELOAD, hdlg, HM_MODULELOAD);
			dat->hPluginUnload = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, hdlg, HM_MODULEUNLOAD);
			dat->currentPage = -1;

			ptrT lastPage, lastGroup, lastTab;
			if (ood->pszPage == NULL) {
				lastPage = db_get_tsa(NULL, "Options", "LastPage");

				if (ood->pszGroup == NULL)
					lastGroup = db_get_tsa(NULL, "Options", "LastGroup");
				else
					lastGroup = mir_a2t(ood->pszGroup);
			}
			else {
				lastPage = mir_a2t(ood->pszPage);
				lastGroup = mir_a2t(ood->pszGroup);
			}

			if (ood->pszTab == NULL)
				lastTab = db_get_tsa(NULL, "Options", "LastTab");
			else
				lastTab = mir_a2t(ood->pszTab);

			OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp;
			for (UINT i = 0; i < psh->nPages; i++, odp++) {
				opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
				if (!LoadOptionsPage(odp, opd)) {
					mir_free(opd);
					continue;
				}
				dat->arOpd.insert(opd);

				if (!lstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup))
					if ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab))
						dat->currentPage = (int)i;
			}

			GetWindowRect(GetDlgItem(hdlg, IDC_STNOPAGE), &dat->rcDisplay);
			MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcDisplay, 2);

			// Add an item to count in height
			TCITEM tie;
			tie.mask = TCIF_TEXT | TCIF_IMAGE;
			tie.iImage = -1;
			tie.pszText = _T("X");
			TabCtrl_InsertItem(GetDlgItem(hdlg, IDC_TAB), 0, &tie);

			GetWindowRect(GetDlgItem(hdlg, IDC_TAB), &dat->rcTab);
			MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcTab, 2);
			TabCtrl_AdjustRect(GetDlgItem(hdlg, IDC_TAB), FALSE, &dat->rcTab);

			FillFilterCombo(hdlg, dat);
			PostMessage(hdlg, DM_REBUILDPAGETREE, 0, 0);
		}
		return TRUE;

	case DM_REBUILDPAGETREE:
		RebuildPageTree(hdlg, dat);
		break;

	case HM_MODULELOAD:
		LoadOptionsModule(hdlg, dat, (HINSTANCE)lParam);
		break;

	case HM_MODULEUNLOAD:
		UnloadOptionsModule(hdlg, dat, (HINSTANCE)lParam);
		break;

	case PSM_CHANGED:
		EnableWindow(GetDlgItem(hdlg, IDC_APPLY), TRUE);

		opd = dat->getCurrent();
		if (opd)
			opd->changed = 1;

		return TRUE;

	case PSM_GETBOLDFONT:
		SetWindowLongPtr(hdlg, DWLP_MSGRESULT, (LONG_PTR)dat->hBoldFont);
		return TRUE;

	case WM_NOTIFY:
		switch (wParam) {
		case IDC_TAB:
		case IDC_PAGETREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_ITEMEXPANDING:
				SetWindowLongPtr(hdlg, DWLP_MSGRESULT, FALSE);
				return TRUE;

			case TCN_SELCHANGING:
			case TVN_SELCHANGING:
				opd = dat->getCurrent();
				if (opd && opd->hwnd != NULL) {
					PSHNOTIFY pshn;
					pshn.hdr.code = PSN_KILLACTIVE;
					pshn.hdr.hwndFrom = dat->arOpd[dat->currentPage]->hwnd;
					pshn.hdr.idFrom = 0;
					pshn.lParam = 0;
					if (SendMessage(dat->arOpd[dat->currentPage]->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) {
						SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE);
						return TRUE;
					}
				}
				break;

			case TCN_SELCHANGE:
			case TVN_SELCHANGED:
				ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_HIDE);

				opd = dat->getCurrent();
				if (opd && opd->hwnd != NULL)
					ShowWindow(opd->hwnd, SW_HIDE);

				if (wParam != IDC_TAB) {
					TVITEM tvi;
					tvi.hItem = dat->hCurrentPage = TreeView_GetSelection(hwndTree);
					if (tvi.hItem == NULL) {
						ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
						break;
					}

					tvi.mask = TVIF_HANDLE | TVIF_PARAM;
					TreeView_GetItem(hwndTree, &tvi);
					dat->currentPage = tvi.lParam;
					ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
				}
				else {
					TCITEM tie;
					tie.mask = TCIF_PARAM;
					TabCtrl_GetItem(GetDlgItem(hdlg, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hdlg, IDC_TAB)), &tie);
					dat->currentPage = tie.lParam;

					TVITEM tvi;
					tvi.hItem = dat->hCurrentPage;
					tvi.mask = TVIF_PARAM;
					tvi.lParam = dat->currentPage;
					TreeView_SetItem(hwndTree, &tvi);
				}

				opd = dat->getCurrent();
				if (opd == NULL) {
					ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_SHOW);
					break;
				}
				if (opd->hwnd == NULL) {
					opd->hwnd = CreateDialogIndirectParamA(opd->hInst, opd->pTemplate, hdlg, opd->dlgProc, opd->dwInitParam);
					if (opd->flags & ODPF_BOLDGROUPS)
						EnumChildWindows(opd->hwnd, BoldGroupTitlesEnumChildren, (LPARAM)dat->hBoldFont);

					RECT rcPage;
					GetClientRect(opd->hwnd, &rcPage);
					int w = opd->width = rcPage.right;
					int h = opd->height = rcPage.bottom;

					RECT rc;
					GetWindowRect(opd->hwnd, &rc);

					opd->offsetX = 0;
					opd->offsetY = 0;

					opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage);
					if (opd->insideTab) {
						SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcTab.left + dat->rcTab.right - w) >> 1, dat->rcTab.top, w, h, 0);
						ThemeDialogBackground(opd->hwnd, TRUE);
					}
					else {
						SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcDisplay.left + dat->rcDisplay.right - w) >> 1, (dat->rcDisplay.top + dat->rcDisplay.bottom - h) >> 1, w, h, 0);
						ThemeDialogBackground(opd->hwnd, FALSE);
					}
				}

				if (wParam != IDC_TAB) {
					opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage);
					if (opd->insideTab) {
						// Make tabbed pane
						int pages = 0, sel = 0;
						HWND hwndTab = GetDlgItem(hdlg, IDC_TAB);
						TabCtrl_DeleteAllItems(hwndTab);

						TCITEM tie;
						tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
						tie.iImage = -1;
						for (int i = 0; i < dat->arOpd.getCount(); i++) {
							if (!CheckPageShow(hdlg, dat, i))
								continue;

							OptionsPageData *p = dat->arOpd[i];
							if (lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup))
								continue;

							tie.pszText = TranslateTH(p->hLangpack, p->ptszTab);
							tie.lParam = i;
							TabCtrl_InsertItem(hwndTab, pages, &tie);
							if (!lstrcmp(opd->ptszTab, p->ptszTab))
								sel = pages;
							pages++;
						}
						TabCtrl_SetCurSel(hwndTab, sel);
						ShowWindow(hwndTab, opd->insideTab ? SW_SHOW : SW_HIDE);
					}

					if (opd->insideTab)
						ThemeDialogBackground(opd->hwnd, TRUE);
					else
						ThemeDialogBackground(opd->hwnd, FALSE);
				}

				ShowWindow(opd->hwnd, SW_SHOW);
				if (((LPNMTREEVIEW)lParam)->action == TVC_BYMOUSE)
					PostMessage(hdlg, DM_FOCUSPAGE, 0, 0);
				else
					SetFocus(hwndTree);
			}
コード例 #19
0
ファイル: options.cpp プロジェクト: kmdtukl/miranda-ng
INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{	
	switch(msg){
	case WM_INITDIALOG:{
		DWORD style;
		g_opHdlg=hdlg;
		bOptionsInit=TRUE;
		TranslateDialogDefault(hdlg); 
		if(g_iButtonsCount!=db_get_b(NULL, PLGNAME,"ButtonsCount", 0))
		{
			LOGFONT logFont;
			HFONT hFont;
			bNeedRestart=TRUE;
			EnableWindow(GetDlgItem(hdlg,IDC_BUTTONSLIST),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BLISTADD),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BLISTREMOVE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUTREE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MTREEADD),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MTREEREMOVE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BUTTONNAME),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUNAME),FALSE);	
			ShowWindow(GetDlgItem(hdlg,IDC_WARNING),SW_SHOW);

			hFont = (HFONT)SendDlgItemMessage(hdlg, IDC_WARNING, WM_GETFONT, 0, 0);
			GetObject(hFont, sizeof(logFont), &logFont);
			logFont.lfWeight = FW_BOLD;
			hFont = CreateFontIndirect(&logFont);
			SendDlgItemMessage(hdlg, IDC_WARNING, WM_SETFONT, (WPARAM)hFont, 0);
			break;
		}

		g_iOPButtonsCount=g_iButtonsCount;

		hButtonsList=GetDlgItem(hdlg,IDC_BUTTONSLIST);
		hMenuTree=GetDlgItem(hdlg,IDC_MENUTREE);

		style = GetWindowLongPtr(hButtonsList,GWL_STYLE);
		style |=TVS_NOHSCROLL;
		SetWindowLongPtr(hButtonsList,GWL_STYLE, style);

		style = GetWindowLongPtr(hMenuTree,GWL_STYLE);
		style |=TVS_NOHSCROLL;			
		SetWindowLongPtr(hMenuTree,GWL_STYLE, style);
		BuildButtonsList(hButtonsList);

		if (!TreeView_GetCount(hButtonsList))
			EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);

		mir_subclassWindow( GetDlgItem(hdlg,IDC_BUTTONNAME), EditSubclassProc);
		mir_subclassWindow( GetDlgItem(hdlg,IDC_MENUNAME),   EditSubclassProc);

		EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
		EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
		EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
		CheckDlgButton(hdlg,IDC_RAUTOSEND,(g_bRClickAuto=db_get_b(NULL,PLGNAME,"RClickAuto",0)) ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg,IDC_LAUTOSEND,(g_bLClickAuto=db_get_b(NULL,PLGNAME,"LClickAuto",0)) ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg,IDC_ENABLEQUICKMENU,(g_bQuickMenu=db_get_b(NULL, PLGNAME,"QuickMenu", 1)) ? BST_CHECKED : BST_UNCHECKED);

		bOptionsInit=FALSE;
							 }break;

	case WM_LBUTTONUP:
		if(drag) {
			TVHITTESTINFO hti; 
			HTREEITEM htiAfter=NULL;
			ButtonData* bd=NULL;
			TVITEM tvi;
			RECT rc;
			BYTE height;
			BOOLEAN bAsChild = FALSE;

			TreeView_SetInsertMark(hMenuTree, NULL, 0 );
			ReleaseCapture();
			SetCursor( LoadCursor( NULL, IDC_ARROW ));

			hti.pt.x = ( SHORT )LOWORD( lparam );
			hti.pt.y = ( SHORT )HIWORD( lparam );
			ClientToScreen(hdlg,&hti.pt);
			ScreenToClient(hMenuTree,&hti.pt);
			TreeView_HitTest( hMenuTree, &hti );

			if(TreeView_GetParent(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
				break;

			if(TreeView_GetChild(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
				break;


			if ( hti.flags & TVHT_ABOVE ) {
				htiAfter = TVI_FIRST;
			}
			else
				if ( hti.flags & ( TVHT_NOWHERE|TVHT_BELOW )) {
					htiAfter = TVI_LAST;
				}
				else
					if ( hti.flags & ( TVHT_ONITEM|TVHT_ONITEMRIGHT )) {
						// check where over the item, the pointer is
						if ( !TreeView_GetItemRect( hMenuTree, hti.hItem, &rc, FALSE )) {
							drag=0;
							break;
						}
						height = ( BYTE )( rc.bottom - rc.top );

						if ( hti.pt.y - ( height / 3 ) < rc.top ) {
							HTREEITEM hItem = hti.hItem;

							if ( !( hti.hItem = TreeView_GetPrevSibling( hMenuTree, hItem )) ) {
								if ( !( hti.hItem = TreeView_GetParent(hMenuTree, hItem )))
									htiAfter = TVI_FIRST;
								else
									bAsChild = TRUE;
							}
						}
						else 
							if ( hti.pt.y + ( height / 3 ) <= rc.bottom ) {
								bAsChild = TRUE;
							}
					}	


					if(TreeView_GetChild(hMenuTree,hDragItem)&&bAsChild)
						break;


					if(hti.hItem){
						tvi.hItem=hti.hItem;
						tvi.mask=TVIF_PARAM |TVIF_HANDLE;
						TreeView_GetItem(hMenuTree,&tvi);
						if ((bd=(ButtonData*)tvi.lParam)&&(bd->fEntryOpType&QMF_EX_SEPARATOR))
							bAsChild = FALSE;
					}

					if(TreeView_GetParent(hMenuTree,hti.hItem))
						bAsChild = FALSE;


					MoveItem( hDragItem, htiAfter?htiAfter:hti.hItem, bAsChild );
					SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
					drag=0;

		}
		break; 

		///////////////////////////////////
		//From UserInfoEx by DeathAxe
		//
	case WM_MOUSEMOVE:
		{
			if (!drag) break;
			{
				TVHITTESTINFO hti;

				hti.pt.x=(short)LOWORD(lparam);
				hti.pt.y=(short)HIWORD(lparam);
				ClientToScreen(hdlg,&hti.pt);
				ScreenToClient(hMenuTree,&hti.pt);
				TreeView_HitTest(hMenuTree,&hti);
				if ( hti.flags & ( TVHT_ONITEM|TVHT_ONITEMRIGHT )) {
					RECT rc;
					BYTE height;

					if ( TreeView_GetItemRect(hMenuTree, hti.hItem, &rc, FALSE )) {
						height = ( BYTE )( rc.bottom - rc.top );

						if ( hti.pt.y - ( height / 3 ) < rc.top ) {
							SetCursor( LoadCursor( NULL, IDC_ARROW ));
							TreeView_SetInsertMark( hMenuTree, hti.hItem, 0 );
						}
						else
							if ( hti.pt.y + ( height / 3 ) > rc.bottom ) {
								SetCursor( LoadCursor( NULL, IDC_ARROW ));
								TreeView_SetInsertMark( hMenuTree, hti.hItem, 1 );
							}
							else {
								TreeView_SetInsertMark( hMenuTree, NULL, 0 );
								SetCursor( LoadCursor( GetModuleHandle(NULL), MAKEINTRESOURCE( 183 )) );
							}
					}
				}
				else {
					if ( hti.flags & TVHT_ABOVE ) SendMessage( hMenuTree, WM_VSCROLL, MAKEWPARAM( SB_LINEUP, 0 ), 0 );
					if ( hti.flags & TVHT_BELOW ) SendMessage( hMenuTree, WM_VSCROLL, MAKEWPARAM( SB_LINEDOWN, 0 ), 0 );
					TreeView_SetInsertMark( hMenuTree, NULL, 0 );
				}
			}
		}break;
		/////////////
	case WM_DESTROY:
		if (g_varhelpDlg)
			DestroyWindow(g_varhelpDlg);
		g_varhelpDlg=NULL;
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lparam)->idFrom)	{
		case 0:
			if (((LPNMHDR)lparam)->code == PSN_APPLY ) {
				if (!bNeedRestart){
					SetMenuEntryProperties(hdlg);
					SaveMenuTree(hdlg); 
				}
				db_set_b(NULL,PLGNAME,"RClickAuto",(BYTE)(g_bRClickAuto=IsDlgButtonChecked(hdlg,IDC_RAUTOSEND)));
				db_set_b(NULL,PLGNAME,"LClickAuto",(BYTE)(g_bLClickAuto=IsDlgButtonChecked(hdlg,IDC_LAUTOSEND)));
				db_set_b(NULL,PLGNAME,"QuickMenu",(BYTE)(g_bQuickMenu=IsDlgButtonChecked(hdlg,IDC_ENABLEQUICKMENU)));
				return 1;
			}
			else if (((LPNMHDR)lparam)->code == PSN_RESET ) {
				if (!bNeedRestart)
					RestoreModuleData(hdlg);
				return 1;
			}
			break; 

		case IDC_MENUTREE:
			switch (((LPNMHDR)lparam)->code){
			case TVN_KEYDOWN:{
				TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*) ((LPNMHDR)lparam);
				if ( pTVKeyDown->wVKey == VK_F2 )
					TreeView_EditLabel(hMenuTree,TreeView_GetSelection(hMenuTree));
				else if ( pTVKeyDown->wVKey == VK_DELETE )
					SendMessage(hdlg,WM_COMMAND,IDC_MTREEREMOVE,0);
								  }break;

			case TVN_BEGINLABELEDIT:
				hwndEdit=TreeView_GetEditControl(hMenuTree);
				mir_subclassWindow(hwndEdit, LabelEditSubclassProc);
				break;

			case TVN_ENDLABELEDIT:
				{
					TVITEM tvi;
					ButtonData* bd=NULL;
					TCHAR strbuf[256];
					TCHAR szLabel[256];

					tvi.pszText = strbuf;
					tvi.cchTextMax = _countof(strbuf);
					tvi.mask=TVIF_TEXT |TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=TreeView_GetSelection(hMenuTree);
					TreeView_GetItem(hMenuTree,&tvi);

					GetWindowText(hwndEdit, szLabel, _countof(szLabel));
					hwndEdit=NULL;
					if (!mir_tstrlen(szLabel)) break;
					if (bd = (ButtonData*)tvi.lParam){
						if (!mir_tstrcmp(szLabel,_T("---"))) {
							if(TreeView_GetChild(hMenuTree,tvi.hItem))
								break;
							else{
								bd->fEntryOpType=QMF_EX_SEPARATOR;
								EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
								EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
								SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
							}
						}
						else {
							bd->fEntryOpType&=~QMF_EX_SEPARATOR;
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),TRUE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, bd->pszOpValue/*?bd->pszOpValue:bd->pszValue*/);
						}

						bd->pszOpName=mir_tstrdup(szLabel);

						tvi.pszText=szLabel;
						TreeView_SetItem(hMenuTree, &tvi);
						SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
					}
				}
				break;

			case NM_KILLFOCUS:
				TreeView_EndEditLabelNow(hButtonsList, 1);
				break;

			case TVN_BEGINDRAG:
				SetCapture(hdlg);
				drag=1;
				hDragItem=((LPNMTREEVIEW)lparam)->itemNew.hItem;
				TreeView_SelectItem(hMenuTree,hDragItem);
				break;

			case TVN_SELCHANGING:
				{
					HTREEITEM hti = TreeView_GetSelection(hMenuTree);
					if (hti==NULL)
						break;

					TVITEM tvi;
					tvi.hItem=hti;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					TreeView_GetItem(hMenuTree,&tvi);
					if (tvi.lParam == 0)
						break;

					ButtonData *bd = ( ButtonData* )tvi.lParam;
					if (bd) {
						TCHAR szValue[256];
						GetDlgItemText(hdlg, IDC_MENUVALUE, szValue, _countof(szValue));
						if(mir_tstrlen(szValue))
						{
							if(bd->pszOpValue&&(bd->pszOpValue!=bd->pszValue))
								mir_free(bd->pszOpValue);
							bd->pszOpValue=mir_tstrdup(szValue);
						}
						bd->bOpInQMenu=IsDlgButtonChecked(hdlg,IDC_INQMENU);
						bd->bIsOpServName=IsDlgButtonChecked(hdlg,IDC_ISSERVNAME);
					}
				}
				break;

			case TVN_SELCHANGED:
				{
					HTREEITEM hti = TreeView_GetSelection(hMenuTree);
					if (hti == NULL)
						break;

					TVITEM tvi;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=hti;
					TreeView_GetItem(hMenuTree,&tvi);

					ButtonData *bd = ( ButtonData* )tvi.lParam;
					if (bd) {
						if (!TreeView_GetChild(hMenuTree, tvi.hItem)&&!(bd->fEntryOpType&QMF_EX_SEPARATOR))
						{
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),TRUE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, bd->pszOpValue/*?bd->pszOpValue:bd->pszValue*/);
						}
						else
						{
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
							if (!(bd->fEntryOpType&QMF_EX_SEPARATOR))
								EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
						}
						CheckDlgButton(hdlg,IDC_INQMENU,bd->bOpInQMenu ? BST_CHECKED : BST_UNCHECKED);
						CheckDlgButton(hdlg,IDC_ISSERVNAME,bd->bIsOpServName ? BST_CHECKED : BST_UNCHECKED);
					}
				}
			}
			break;

		case IDC_BUTTONSLIST:
			switch (((LPNMHDR)lparam)->code) {
			case TVN_KEYDOWN:{
				TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*) ((LPNMHDR)lparam);
				if ( pTVKeyDown->wVKey == VK_F2 )
					TreeView_EditLabel(hButtonsList,TreeView_GetSelection(hButtonsList));
				else if ( pTVKeyDown->wVKey == VK_DELETE )
					SendMessage(hdlg,WM_COMMAND,IDC_BLISTREMOVE,0);
								  }break;

			case TVN_BEGINLABELEDIT:
				hwndEdit = TreeView_GetEditControl(hButtonsList);
				mir_subclassWindow(hwndEdit, LabelEditSubclassProc);
				break;

			case TVN_ENDLABELEDIT:
				{
					TVITEM tvi;
					TCHAR strbuf[128];
					TCHAR szLabel[128];

					tvi.pszText = strbuf;
					tvi.cchTextMax = _countof(strbuf);
					tvi.mask=TVIF_TEXT |TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=TreeView_GetSelection(hButtonsList);
					TreeView_GetItem(hButtonsList,&tvi);

					GetWindowText(hwndEdit, szLabel, _countof(szLabel));
					hwndEdit=NULL;
					if (!mir_tstrlen(szLabel)) break;

					tvi.pszText=szLabel;
					((ListData*)tvi.lParam)->dwOPFlags|=QMF_RENAMED;	

					TreeView_SetItem(hButtonsList, &tvi);
					SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
				}
				break;

			case TVN_SELCHANGING:
				SetMenuEntryProperties(hdlg);
				break;

			case TVN_SELCHANGED:
				{
					HTREEITEM hti = TreeView_GetSelection(hButtonsList);
					if(hti==NULL||!TreeView_GetCount(hButtonsList)) {
						EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),FALSE);
						SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
						break;
					}

					TVITEM tvi;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=hti;
					TreeView_GetItem(hButtonsList,&tvi);

					if(tvi.lParam==0) break;

					BuildMenuTree(hMenuTree,(SortedList *)((ListData*)tvi.lParam)->sl);

					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
					EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),TRUE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),TRUE);
					CheckDlgButton(hdlg,IDC_ISSERVNAME2,((ListData*)tvi.lParam)->bIsOpServName ? BST_CHECKED : BST_UNCHECKED);

					if (((ListData*)tvi.lParam)->ptszOPQValue) 
						SetDlgItemText(hdlg, IDC_RCLICKVALUE, ((ListData*)tvi.lParam)->ptszOPQValue);
					else
						SetDlgItemText(hdlg, IDC_RCLICKVALUE, _T(""));
				}
				break;
			}
			break;
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wparam)) {
		case IDC_VARHELP:
			if (!g_varhelpDlg)
				g_varhelpDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_HELPDIALOG), 0, HelpDlgProc);
			else
				//ShowWindow(g_varhelpDlg,SW_SHOWDEFAULT);
				SetWindowPos(g_varhelpDlg,0,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
			break;
		case IDC_BLISTADD:
			{
				TVINSERTSTRUCT tvis;
				ListData* ld=NULL;
				TCHAR namebuff[MAX_PATH]={'\0'};
				int count=TreeView_GetCount(hButtonsList);
				if (count>10) break;
				if(g_iOPButtonsCount==99){
					MessageBox(NULL, TranslateT("Congratulation!\r\nYou have clicked this button 100 times!\r\nThere was access violation at this point...\r\nAnd now function for freeing resources must be called...\r\nBut no! there's only break :D"), TranslateT("You win!"),MB_OK);
					break;
				}

				ld = (ListData *)mir_alloc(sizeof(ListData));
				ButtonsList[g_iOPButtonsCount++]=ld;

				ld->sl=List_Create(0,1);
				ld->dwOPFlags=QMF_NEW;
				ld->bIsOpServName=0;
				ld->ptszButtonName=NULL;
				ld->ptszOPQValue=NULL;
				ld->ptszQValue=NULL;
				tvis.hParent = NULL;
				tvis.hInsertAfter = TVI_LAST;

				GetDlgItemText(hdlg, IDC_BUTTONNAME, namebuff, _countof(namebuff));

				tvis.item.mask=TVIF_PARAM|TVIF_TEXT;
				tvis.item.pszText=(mir_tstrlen(namebuff))?namebuff:TranslateT("New Button");
				tvis.item.lParam=(LPARAM)ld;
				TreeView_SelectItem(hButtonsList,TreeView_InsertItem(hButtonsList,&tvis));
			}break;

		case IDC_BLISTREMOVE:
			{ 
				TVITEM tvi;
				ListData* ld;

				if (!(tvi.hItem=TreeView_GetSelection(hButtonsList)))
					break;

				tvi.mask=TVIF_HANDLE|TVIF_PARAM;
				TreeView_GetItem(hButtonsList,&tvi);

				ld= (ListData*)tvi.lParam;

				ld->dwOPFlags|=QMF_DELETNEEDED;	

				TreeView_DeleteItem(hButtonsList,tvi.hItem);
				if (!TreeView_GetCount(hButtonsList)) {
					TreeView_DeleteAllItems(hMenuTree);
					EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),FALSE);
					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
					SetDlgItemText(hdlg, IDC_RCLICKVALUE, _T(""));
				}
			}break;

		case IDC_MTREEADD:
			{
				TVINSERTSTRUCT tvis;
				TVITEM tvi;
				ButtonData *bd=NULL;
				SortedList *sl=NULL;
				TCHAR namebuff[MAX_PATH]={'\0'};

				if (!TreeView_GetCount(hButtonsList)) break;
				if (!(tvi.hItem=TreeView_GetSelection(hButtonsList))) break;

				bd = (ButtonData *)mir_alloc(sizeof(ButtonData));
				memset(bd,0,sizeof(ButtonData));

				GetDlgItemText(hdlg, IDC_MENUNAME, namebuff, _countof(namebuff));

				bd->dwOPPos=TreeView_GetCount(hMenuTree)-1;
				bd->pszOpName=mir_tstrlen(namebuff)?mir_tstrdup(namebuff):mir_tstrdup(TranslateT("New Menu Entry"));
				bd->pszOpValue=mir_tstrdup(bd->pszOpName);
				bd->fEntryOpType=!mir_tstrcmp(namebuff,_T("---"))?QMF_EX_SEPARATOR:0;
				bd->dwOPFlags=QMF_NEW;
				bd->pszName=NULL;
				bd->pszValue=NULL;


				tvi.mask=TVIF_HANDLE|TVIF_PARAM;

				TreeView_GetItem(hButtonsList,&tvi);

				sl=((ListData*)tvi.lParam)->sl;

				List_InsertPtr(sl,bd);

				tvis.hParent = NULL;
				tvis.hInsertAfter = TVI_LAST;
				tvis.item.mask=TVIF_PARAM|TVIF_TEXT;
				tvis.item.pszText=bd->pszOpName;
				tvis.item.lParam=(LPARAM)bd;
				TreeView_SelectItem(hMenuTree,TreeView_InsertItem(hMenuTree,&tvis));
			}break;

		case IDC_MTREEREMOVE:
			{
				TVITEM tvi;
				TVINSERTSTRUCT tvis;
				HTREEITEM hti=NULL;
				ButtonData *bd=NULL;
				tvi.mask=TVIF_HANDLE|TVIF_PARAM;
				if (!(tvi.hItem=TreeView_GetSelection(hMenuTree)))
					break;
				TreeView_GetItem(hMenuTree,&tvi);
				hti=tvi.hItem;

				bd= (ButtonData*)tvi.lParam;
				bd->dwOPFlags|=QMF_DELETNEEDED;			

				if(tvi.hItem=TreeView_GetChild(hMenuTree,tvi.hItem)) {
					TCHAR strbuf[128];
					while(tvi.hItem){
						tvis.hInsertAfter=hti;
						tvi.pszText = strbuf;
						tvi.cchTextMax = _countof(strbuf);
						tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT;

						TreeView_GetItem(hMenuTree,&tvi); 
						tvis.hParent=NULL;
						tvis.item=tvi;
						TreeView_InsertItem(hMenuTree,&tvis);
						tvi.hItem=TreeView_GetNextSibling(hMenuTree,tvi.hItem);
					}
				}

				TreeView_DeleteItem(hMenuTree,hti);
				if (!TreeView_GetCount(hMenuTree)) {
					EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
				}
			}break;
		}
		break;

	case WM_CLOSE:
		EndDialog(hdlg,0);
		return 0;
	}
	if (HIWORD(wparam)==BN_CLICKED && GetFocus()==(HWND)lparam)
		SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
	else if ((HIWORD(wparam) == EN_CHANGE)&&(GetFocus()==(HWND)lparam))
		if (!bOptionsInit)	SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);

	return 0;
}
コード例 #20
0
ファイル: sendmsg.cpp プロジェクト: Ganster41/miranda-ng
static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	SetAwayMsgData* dat = (SetAwayMsgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (message) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)lParam;
			dat = (SetAwayMsgData*)mir_alloc(sizeof(SetAwayMsgData));
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
			dat->statusMode = newdat->statusMode;
			dat->szProto = newdat->szProto;
			mir_free(newdat);
			SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0);
			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc);
			{
				TCHAR str[256], format[128];
				GetWindowText(hwndDlg, format, SIZEOF(format));
				mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0));
				SetWindowText(hwndDlg, str);
			}
			GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat));
			{
				TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto);
				SetDlgItemText(hwndDlg, IDC_MSG, msg);
				mir_free(msg);
			}
			dat->countdown = 6;
			SendMessage(hwndDlg, WM_TIMER, 0, 0);
			Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode);
			Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg");
			SetTimer(hwndDlg, 1, 1000, 0);
			dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN);
		}
		return TRUE;

	case WM_TIMER:
		if (--dat->countdown >= 0) {
			TCHAR str[64];
			mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown);
			SetDlgItemText(hwndDlg, IDOK, str);
		}
		else {
			KillTimer(hwndDlg, 1);
			PostMessage(hwndDlg, WM_CLOSE, 0, 0);
		}
		break;

	case WM_CLOSE:
		{
			TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto);
			ChangeAllProtoMessages(dat->szProto, dat->statusMode, msg);
			mir_free(msg);
		}
		DestroyWindow(hwndDlg);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			if (dat->countdown < 0) {
				TCHAR str[1024];
				GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str));
				ChangeAllProtoMessages(dat->szProto, dat->statusMode, str);
				db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str);
				DestroyWindow(hwndDlg);
			}
			else PostMessage(hwndDlg, WM_CLOSE, 0, 0);
			break;

		case IDC_MSG:
			if (dat->countdown >= 0) {
				KillTimer(hwndDlg, 1);
				SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
				dat->countdown = -1;
			}
			break;
		}
		break;

	case DM_SRAWAY_SHUTDOWN:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		Utils_SaveWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg");
		KillTimer(hwndDlg, 1);
		UnhookEvent(dat->hPreshutdown);
		Window_FreeIcon_IcoLib(hwndDlg);
		mir_free(dat);
		hwndStatusMsg = NULL;
		break;
	}
	return FALSE;
}
コード例 #21
0
ファイル: tlen_opt.cpp プロジェクト: Ganster41/miranda-ng
static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	char text[256];

	TlenProtocol *proto = (TlenProtocol *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	switch (msg) {
	case WM_INITDIALOG:
		{
			DBVARIANT dbv;
			proto = (TlenProtocol *)lParam;
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)proto);
			TranslateDialogDefault(hwndDlg);
			if (!db_get_ts(NULL, proto->m_szModuleName, "LoginName", &dbv)) {
				SetDlgItemText(hwndDlg, IDC_EDIT_USERNAME, dbv.ptszVal);
				db_free(&dbv);
			}
			if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
				SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
				db_free(&dbv);
			}
			CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, db_get_b(NULL, proto->m_szModuleName, "SavePassword", TRUE));

			CheckDlgButton(hwndDlg, IDC_RECONNECT, proto->tlenOptions.reconnect);
			CheckDlgButton(hwndDlg, IDC_ROSTER_SYNC, proto->tlenOptions.rosterSync);
			CheckDlgButton(hwndDlg, IDC_SHOW_OFFLINE, proto->tlenOptions.offlineAsInvisible);
			CheckDlgButton(hwndDlg, IDC_OFFLINE_MESSAGE, proto->tlenOptions.leaveOfflineMessage);
			CheckDlgButton(hwndDlg, IDC_IGNORE_ADVERTISEMENTS, proto->tlenOptions.ignoreAdvertisements);
			CheckDlgButton(hwndDlg, IDC_AVATARS, proto->tlenOptions.enableAvatars);
			CheckDlgButton(hwndDlg, IDC_VERSIONINFO, proto->tlenOptions.enableVersion);
			CheckDlgButton(hwndDlg, IDC_NUDGE_SUPPORT, proto->tlenOptions.useNudge);
			CheckDlgButton(hwndDlg, IDC_LOG_ALERTS, proto->tlenOptions.logAlerts);

			SendDlgItemMessage(hwndDlg, IDC_ALERT_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Accept all alerts"));
			SendDlgItemMessage(hwndDlg, IDC_ALERT_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore alerts from unauthorized contacts"));
			SendDlgItemMessage(hwndDlg, IDC_ALERT_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore all alerts"));
			SendDlgItemMessage(hwndDlg, IDC_ALERT_POLICY, CB_SETCURSEL, proto->tlenOptions.alertPolicy, 0);

			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Always ask me"));
			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Accept invitations from authorized contacts"));
			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Accept all invitations"));
			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore invitations from unauthorized contacts"));
			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore all invitation"));
			SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_SETCURSEL, proto->tlenOptions.groupChatPolicy, 0);

			SendDlgItemMessage(hwndDlg, IDC_IMAGE_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Accept all images"));
			SendDlgItemMessage(hwndDlg, IDC_IMAGE_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore images from unauthorized contacts"));
			SendDlgItemMessage(hwndDlg, IDC_IMAGE_POLICY, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore all images"));
			SendDlgItemMessage(hwndDlg, IDC_IMAGE_POLICY, CB_SETCURSEL, proto->tlenOptions.imagePolicy, 0);

			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Last message>"));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_ONLINE, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_AWAY, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_NA, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_DND, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_FREECHAT, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_INVISIBLE, 0));
			SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_SETCURSEL, proto->tlenOptions.offlineMessageOption, 0);

			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), TlenValidateUsernameWndProc);
			return TRUE;
		}
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_EDIT_USERNAME:
		case IDC_EDIT_PASSWORD:
			if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
			// Fall through
		case IDC_SAVEPASSWORD:
		case IDC_RECONNECT:
		case IDC_ROSTER_SYNC:
		case IDC_IGNORE_ADVERTISEMENTS:
		case IDC_SHOW_OFFLINE:
		case IDC_OFFLINE_MESSAGE:
			MarkChanges(1, hwndDlg);
			break;
		case IDC_LOG_ALERTS:
			CheckDlgButton(hwndDlg, IDC_NUDGE_SUPPORT, BST_UNCHECKED);
			MarkChanges(1, hwndDlg);
			break;
		case IDC_NUDGE_SUPPORT:
			CheckDlgButton(hwndDlg, IDC_LOG_ALERTS, BST_UNCHECKED);
			MarkChanges(1, hwndDlg);
			break;
		case IDC_REGISTERACCOUNT:
			CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) TLEN_REGISTER);
			break;
		case IDC_OFFLINE_MESSAGE_OPTION:
		case IDC_ALERT_POLICY:
		case IDC_MUC_POLICY:
			if (HIWORD(wParam) == CBN_SELCHANGE)
				MarkChanges(1, hwndDlg);
			break;
		default:
			MarkChanges(1, hwndDlg);
			break;
		}
		break;
	case WM_NOTIFY:
		switch (((LPNMHDR) lParam)->code) {
		case PSN_APPLY:
			{
				BOOL reconnectRequired = FALSE;
				DBVARIANT dbv;

				GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, sizeof(text));
				if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv) || strcmp(text, dbv.pszVal))
					reconnectRequired = TRUE;
				if (dbv.pszVal != NULL)	db_free(&dbv);
				db_set_s(NULL, proto->m_szModuleName, "LoginName", strlwr(text));

				if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
					GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
					if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
						reconnectRequired = TRUE;
					if (dbv.pszVal != NULL)	db_free(&dbv);
					db_set_s(NULL, proto->m_szModuleName, "Password", text);
				}
				else
					db_unset(NULL, proto->m_szModuleName, "Password");

				db_set_b(NULL, proto->m_szModuleName, "SavePassword", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD));
				db_set_b(NULL, proto->m_szModuleName, "Reconnect", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_RECONNECT));
				db_set_b(NULL, proto->m_szModuleName, "RosterSync", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ROSTER_SYNC));
				db_set_b(NULL, proto->m_szModuleName, "OfflineAsInvisible", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOW_OFFLINE));
				db_set_b(NULL, proto->m_szModuleName, "IgnoreAdvertisements", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_IGNORE_ADVERTISEMENTS));
				db_set_b(NULL, proto->m_szModuleName, "LeaveOfflineMessage", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_OFFLINE_MESSAGE));
				db_set_w(NULL, proto->m_szModuleName, "OfflineMessageOption", (WORD) SendDlgItemMessage(hwndDlg, IDC_OFFLINE_MESSAGE_OPTION, CB_GETCURSEL, 0, 0));
				db_set_w(NULL, proto->m_szModuleName, "AlertPolicy", (WORD) SendDlgItemMessage(hwndDlg, IDC_ALERT_POLICY, CB_GETCURSEL, 0, 0));
				db_set_w(NULL, proto->m_szModuleName, "GroupChatPolicy", (WORD) SendDlgItemMessage(hwndDlg, IDC_MUC_POLICY, CB_GETCURSEL, 0, 0));
				db_set_w(NULL, proto->m_szModuleName, "ImagePolicy", (WORD) SendDlgItemMessage(hwndDlg, IDC_IMAGE_POLICY, CB_GETCURSEL, 0, 0));
				db_set_b(NULL, proto->m_szModuleName, "EnableAvatars", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_AVATARS));
				db_set_b(NULL, proto->m_szModuleName, "EnableVersion", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_VERSIONINFO));
				db_set_b(NULL, proto->m_szModuleName, "UseNudge", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_NUDGE_SUPPORT));
				db_set_b(NULL, proto->m_szModuleName, "LogAlerts", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_LOG_ALERTS));
				if (reconnectRequired && proto->isConnected)
					MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
				ApplyChanges(proto, 1);
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}
コード例 #22
0
ファイル: opt_adv.cpp プロジェクト: MrtsComputers/miranda-ng
INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TCHAR tstr[64];
	static bool bDlgInit = false;	//some controls send WM_COMMAND before or during WM_INITDIALOG
	UINT idCtrl;

	switch (msg) {
	case WM_INITDIALOG:
		//Create preview box:
		{
			hwndBox = CreateWindowEx(
				WS_EX_TOOLWINDOW|WS_EX_TOPMOST,		// dwStyleEx
				_T(BOXPREVIEW_WNDCLASS),			// Class name
				NULL,								// Title
				DS_SETFONT|DS_FIXEDSYS|WS_POPUP,	// dwStyle
				CW_USEDEFAULT,						// x
				CW_USEDEFAULT,						// y
				CW_USEDEFAULT,						// Width
				CW_USEDEFAULT,						// Height
				HWND_DESKTOP,						// Parent
				NULL,								// menu handle
				hInst,								// Instance
				(LPVOID)0);
			ShowWindow(hwndBox, SW_HIDE);
		}
		//Group: History
		{
			CheckDlgButton(hwnd, IDC_ENABLE_HISTORY, PopupOptions.EnableHistory);
			SetDlgItemInt (hwnd, IDC_HISTORYSIZE, PopupOptions.HistorySize, FALSE);
			CheckDlgButton(hwnd, IDC_HPPLOG, PopupOptions.UseHppHistoryLog);

			HWND hCtrl = GetDlgItem(hwnd, IDC_SHOWHISTORY);
			SendMessage(hCtrl, BUTTONSETASFLATBTN, TRUE, 0);
			SendMessage(hCtrl, BUTTONADDTOOLTIP, (WPARAM)Translate("Popup History"), 0);
			SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_HISTORY,0));

			EnableWindow(GetDlgItem(hwnd, IDC_HISTORY_STATIC1),	PopupOptions.EnableHistory);
			EnableWindow(GetDlgItem(hwnd, IDC_HISTORYSIZE),		PopupOptions.EnableHistory);
			EnableWindow(GetDlgItem(hwnd, IDC_HISTORY_STATIC2),	PopupOptions.EnableHistory);
			EnableWindow(GetDlgItem(hwnd, IDC_SHOWHISTORY),		PopupOptions.EnableHistory);
			EnableWindow(GetDlgItem(hwnd, IDC_HPPLOG),			PopupOptions.EnableHistory && gbHppInstalled);
		}
		//Group: Avatars
		{
			//Borders
			CheckDlgButton(hwnd, IDC_AVT_BORDER, PopupOptions.avatarBorders);
			CheckDlgButton(hwnd, IDC_AVT_PNGBORDER, PopupOptions.avatarPNGBorders);
			EnableWindow(GetDlgItem(hwnd, IDC_AVT_PNGBORDER), PopupOptions.avatarBorders);
			//Radius
			SetDlgItemInt(hwnd, IDC_AVT_RADIUS, PopupOptions.avatarRadius, FALSE);
			SendDlgItemMessage(hwnd, IDC_AVT_RADIUS_SPIN,UDM_SETRANGE, 0, (LPARAM)MAKELONG((PopupOptions.avatarSize / 2),0));
			//Size
			mir_subclassWindow(GetDlgItem(hwnd, IDC_AVT_SIZE_SLIDE), AvatarTrackBarWndProc);

			SendDlgItemMessage(hwnd, IDC_AVT_SIZE_SLIDE, TBM_SETRANGE,FALSE,
				MAKELONG(SETTING_AVTSIZE_MIN, SETTING_AVTSIZE_MAX));
			SendDlgItemMessage(hwnd, IDC_AVT_SIZE_SLIDE, TBM_SETPOS, TRUE, 
				max(PopupOptions.avatarSize, SETTING_AVTSIZE_MIN));
			SetDlgItemInt(hwnd, IDC_AVT_SIZE, PopupOptions.avatarSize, FALSE);
			//Request avatars
			CheckDlgButton(hwnd, IDC_AVT_REQUEST, PopupOptions.EnableAvatarUpdates);
		}
		//Group: Monitor
		{
			BOOL bMonitor = 0;

			bMonitor = GetSystemMetrics(SM_CMONITORS)>1;

			CheckDlgButton(hwnd, IDC_MIRANDAWND, bMonitor ? (PopupOptions.Monitor == MN_MIRANDA) : TRUE);
			CheckDlgButton(hwnd, IDC_ACTIVEWND, bMonitor ? (PopupOptions.Monitor == MN_ACTIVE) : FALSE);
			EnableWindow(GetDlgItem(hwnd, IDC_GRP_MULTIMONITOR), bMonitor);
			EnableWindow(GetDlgItem(hwnd, IDC_MULTIMONITOR_DESC), bMonitor);
			EnableWindow(GetDlgItem(hwnd, IDC_MIRANDAWND), bMonitor);
			EnableWindow(GetDlgItem(hwnd, IDC_ACTIVEWND), bMonitor);
		}
		//Group: Transparency
		{
			//win2k+
			CheckDlgButton(hwnd, IDC_TRANS, PopupOptions.UseTransparency);
			SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(1,255));
			SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETPOS, TRUE, PopupOptions.Alpha);
			mir_subclassWindow(GetDlgItem(hwnd, IDC_TRANS_SLIDER),	AlphaTrackBarWndProc);
			mir_sntprintf(tstr, SIZEOF(tstr), _T("%d%%"), Byte2Percentile(PopupOptions.Alpha));
			SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr);
			CheckDlgButton(hwnd, IDC_TRANS_OPAQUEONHOVER, PopupOptions.OpaqueOnHover);
			{
				BOOL how = TRUE;

				EnableWindow(GetDlgItem(hwnd, IDC_TRANS), how);
				EnableWindow(GetDlgItem(hwnd, IDC_TRANS_TXT1), how && PopupOptions.UseTransparency);
				EnableWindow(GetDlgItem(hwnd, IDC_TRANS_SLIDER), how && PopupOptions.UseTransparency);
				EnableWindow(GetDlgItem(hwnd, IDC_TRANS_PERCENT), how && PopupOptions.UseTransparency);
				EnableWindow(GetDlgItem(hwnd, IDC_TRANS_OPAQUEONHOVER), how && PopupOptions.UseTransparency);
			}
			ShowWindow(GetDlgItem(hwnd, IDC_TRANS), SW_SHOW);
		}
		//Group: Effects
		{
			//Use Animations
			CheckDlgButton(hwnd, IDC_USEANIMATIONS, PopupOptions.UseAnimations);
			//Fade
			SetDlgItemInt (hwnd, IDC_FADEIN, PopupOptions.FadeIn, FALSE);
			SetDlgItemInt (hwnd, IDC_FADEOUT,PopupOptions.FadeOut,FALSE);
			UDACCEL aAccels[] = {{0,50},{1,100},{3,500}};
			SendDlgItemMessage(hwnd, IDC_FADEIN_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_FADEINTIME_MAX, SETTING_FADEINTIME_MIN));
			SendDlgItemMessage(hwnd, IDC_FADEIN_SPIN, UDM_SETACCEL, (WPARAM)SIZEOF(aAccels), (LPARAM)&aAccels);
			SendDlgItemMessage(hwnd, IDC_FADEOUT_SPIN,UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_FADEOUTTIME_MAX,SETTING_FADEOUTTIME_MIN));
			SendDlgItemMessage(hwnd, IDC_FADEOUT_SPIN,UDM_SETACCEL, (WPARAM)SIZEOF(aAccels), (LPARAM)&aAccels);

			BOOL how = PopupOptions.UseAnimations || PopupOptions.UseEffect;
			EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT1),		how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEIN),			how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_SPIN),		how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT2),		how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT1),	how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT),			how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_SPIN),	how);
			EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT2),	how);
			//effects drop down
			{
				DWORD dwItem, dwActiveItem = 0;

				BOOL how = TRUE;

				EnableWindow(GetDlgItem(hwnd, IDC_EFFECT),		how);
				EnableWindow(GetDlgItem(hwnd, IDC_EFFECT_TXT),	how);

				HWND hCtrl = GetDlgItem(hwnd, IDC_EFFECT);
				ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("No effect"))	,-2);
				ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Fade in/out"))		,-1);
				dwActiveItem = (DWORD)PopupOptions.UseEffect;
				for (int i=0; i < g_lstPopupVfx.getCount(); ++i) {
					dwItem = ComboBox_AddString(hCtrl, TranslateTS(g_lstPopupVfx[i]));
					ComboBox_SetItemData(hCtrl, dwItem, i);
					if (PopupOptions.UseEffect && !lstrcmp(g_lstPopupVfx[i], PopupOptions.Effect))
						dwActiveItem = dwItem;
				}
				SendDlgItemMessage(hwnd, IDC_EFFECT, CB_SETCURSEL, dwActiveItem, 0);
			}
		}

		//later check stuff
		SetDlgItemInt(hwnd, IDC_MAXPOPUPS, PopupOptions.MaxPopups, FALSE);
		TranslateDialogDefault(hwnd);	//do it on end of WM_INITDIALOG
		bDlgInit = true;
		return TRUE;

	case WM_HSCROLL:
		switch (idCtrl = GetDlgCtrlID((HWND)lParam)) {
		case IDC_AVT_SIZE_SLIDE:
			PopupOptions.avatarSize = SendDlgItemMessage(hwnd,IDC_AVT_SIZE_SLIDE, TBM_GETPOS,0,0);
			SetDlgItemInt(hwnd, IDC_AVT_SIZE ,PopupOptions.avatarSize,FALSE);
			SendDlgItemMessage(hwnd, IDC_AVT_RADIUS_SPIN,UDM_SETRANGE, 0, (LPARAM)MAKELONG((PopupOptions.avatarSize / 2),0));
			SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			break;

		case IDC_TRANS_SLIDER:
			PopupOptions.Alpha = (BYTE)SendDlgItemMessage(hwnd,IDC_TRANS_SLIDER, TBM_GETPOS, 0,0);
			mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("%d%%"), Byte2Percentile(PopupOptions.Alpha));
			SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr);
			SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_COMMAND:
		idCtrl = LOWORD(wParam);
		switch (HIWORD(wParam)) {
		case BN_CLICKED:		//Button controls
			switch(idCtrl) {
			case IDC_ENABLE_HISTORY:
				PopupOptions.EnableHistory = !PopupOptions.EnableHistory;
				EnableWindow(GetDlgItem(hwnd, IDC_HISTORY_STATIC1),	PopupOptions.EnableHistory);
				EnableWindow(GetDlgItem(hwnd, IDC_HISTORYSIZE),		PopupOptions.EnableHistory);
				EnableWindow(GetDlgItem(hwnd, IDC_HISTORY_STATIC2),	PopupOptions.EnableHistory);
				EnableWindow(GetDlgItem(hwnd, IDC_SHOWHISTORY),		PopupOptions.EnableHistory);
				EnableWindow(GetDlgItem(hwnd, IDC_HPPLOG), PopupOptions.EnableHistory && gbHppInstalled);
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_SHOWHISTORY:
				PopupHistoryShow();
				break;

			case IDC_HPPLOG:
				PopupOptions.UseHppHistoryLog = !PopupOptions.UseHppHistoryLog;
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_AVT_BORDER:
				PopupOptions.avatarBorders = !PopupOptions.avatarBorders;
				EnableWindow(GetDlgItem(hwnd, IDC_AVT_PNGBORDER),	PopupOptions.avatarBorders);
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_AVT_PNGBORDER:
				PopupOptions.avatarPNGBorders = !PopupOptions.avatarPNGBorders;
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_AVT_REQUEST:
				PopupOptions.EnableAvatarUpdates = !PopupOptions.EnableAvatarUpdates;
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_MIRANDAWND:
				PopupOptions.Monitor = MN_MIRANDA;
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_ACTIVEWND:
				PopupOptions.Monitor = MN_ACTIVE;
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
				break;

			case IDC_TRANS:
				PopupOptions.UseTransparency = !PopupOptions.UseTransparency;
				{
					BOOL how = TRUE;
					EnableWindow(GetDlgItem(hwnd, IDC_TRANS_TXT1)			,how && PopupOptions.UseTransparency);
					EnableWindow(GetDlgItem(hwnd, IDC_TRANS_SLIDER)			,how && PopupOptions.UseTransparency);
					EnableWindow(GetDlgItem(hwnd, IDC_TRANS_PERCENT)		,how && PopupOptions.UseTransparency);
					EnableWindow(GetDlgItem(hwnd, IDC_TRANS_OPAQUEONHOVER)	,how && PopupOptions.UseTransparency);
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_TRANS_OPAQUEONHOVER:
				PopupOptions.OpaqueOnHover = !PopupOptions.OpaqueOnHover;
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				break;

			case IDC_USEANIMATIONS:
				PopupOptions.UseAnimations = !PopupOptions.UseAnimations;
				{
					BOOL enable = PopupOptions.UseAnimations || PopupOptions.UseEffect;
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT1),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN),			enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_SPIN),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT2),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT1),	enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT),			enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_SPIN),	enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT2),	enable);
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_PREVIEW:
				PopupPreview();
				break;
			}
			break;

		case CBN_SELCHANGE:
			//lParam = Handle to the control
			switch(idCtrl) {
			case IDC_EFFECT:
				{
					int iEffect = ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
					PopupOptions.UseEffect = (iEffect != -2) ? TRUE : FALSE;
					mir_free(PopupOptions.Effect);
					PopupOptions.Effect = mir_tstrdup((iEffect >= 0) ? g_lstPopupVfx[iEffect] : _T(""));

					BOOL enable = PopupOptions.UseAnimations || PopupOptions.UseEffect;
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT1),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN),			enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_SPIN),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEIN_TXT2),		enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT1),	enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT),			enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_SPIN),	enable);
					EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT2),	enable);
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;
			}
			break;

		case EN_CHANGE:			//Edit controls change
			if (!bDlgInit) break;
			//lParam = Handle to the control
			switch(idCtrl) {
			case IDC_MAXPOPUPS:
				{
					int maxPop = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (maxPop > 0){
						PopupOptions.MaxPopups = maxPop;
						SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
				}
				break;
			case IDC_HISTORYSIZE:
				{
					int histSize = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (	histSize > 0 &&
						histSize <= SETTING_HISTORYSIZE_MAX){
							PopupOptions.HistorySize = histSize;
							SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
				}
				break;
			case IDC_AVT_RADIUS:
				{
					int avtRadius = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (	avtRadius <= SETTING_AVTSIZE_MAX / 2 ) {
						PopupOptions.avatarRadius = avtRadius;
						SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
				}
				break;
			case IDC_FADEIN:
				{
					int fadeIn = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (	fadeIn >= SETTING_FADEINTIME_MIN &&
						fadeIn <= SETTING_FADEINTIME_MAX ) {
							PopupOptions.FadeIn = fadeIn;
							SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
				}
				break;
			case IDC_FADEOUT:
				{
					int fadeOut =  GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (	fadeOut >= SETTING_FADEOUTTIME_MIN &&
						fadeOut <= SETTING_FADEOUTTIME_MAX){
							PopupOptions.FadeOut = fadeOut;
							SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
				}
				break;
			}
			break;

		case EN_KILLFOCUS:		//Edit controls lost fokus
			//lParam = Handle to the control
			switch(idCtrl) {
			case IDC_MAXPOPUPS:
				{
					int maxPop = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (maxPop <= 0)
						PopupOptions.MaxPopups = 20;
					if (maxPop != PopupOptions.MaxPopups) {
						SetDlgItemInt(hwnd, idCtrl, PopupOptions.MaxPopups, FALSE);
						//ErrorMSG(1);
						SetFocus((HWND)lParam);
					}
				}
				break;
			case IDC_HISTORYSIZE:
				{
					int histSize = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (histSize <= 0)
						PopupOptions.HistorySize = SETTING_HISTORYSIZE_DEFAULT;
					else if (histSize > SETTING_HISTORYSIZE_MAX)
						PopupOptions.HistorySize = SETTING_HISTORYSIZE_MAX;
					if (histSize != PopupOptions.HistorySize) {
						SetDlgItemInt(hwnd, idCtrl, PopupOptions.HistorySize, FALSE);
						ErrorMSG(1, SETTING_HISTORYSIZE_MAX);
						SetFocus((HWND)lParam);
					}
				}
				break;
			case IDC_AVT_RADIUS:
				{
					int avtRadius = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (avtRadius > SETTING_AVTSIZE_MAX / 2)
						PopupOptions.avatarRadius = SETTING_AVTSIZE_MAX / 2;
					if (avtRadius != PopupOptions.avatarRadius) {
						SetDlgItemInt(hwnd, idCtrl, PopupOptions.avatarRadius, FALSE);
						ErrorMSG(0, SETTING_AVTSIZE_MAX / 2);
						SetFocus((HWND)lParam);
					}
				}
				break;
			case IDC_FADEIN:
				{
					int fade = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (fade < SETTING_FADEINTIME_MIN)
						PopupOptions.FadeIn = SETTING_FADEINTIME_MIN;
					else if (fade > SETTING_FADEINTIME_MAX)										
						PopupOptions.FadeIn = SETTING_FADEINTIME_MAX;
					if (fade != PopupOptions.FadeIn) {
						SetDlgItemInt(hwnd, idCtrl, PopupOptions.FadeIn, FALSE);
						ErrorMSG(SETTING_FADEINTIME_MIN, SETTING_FADEINTIME_MAX);
						SetFocus((HWND)lParam);
					}
				}
				break;
			case IDC_FADEOUT:
				{
					int fade = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE);
					if (fade < SETTING_FADEOUTTIME_MIN)
						PopupOptions.FadeOut = SETTING_FADEOUTTIME_MIN;
					else if (fade > SETTING_FADEOUTTIME_MAX)
						PopupOptions.FadeOut = SETTING_FADEOUTTIME_MAX;
					if (fade != PopupOptions.FadeOut) {
						SetDlgItemInt(hwnd, idCtrl, PopupOptions.FadeOut, FALSE);
						ErrorMSG(SETTING_FADEOUTTIME_MIN, SETTING_FADEOUTTIME_MAX);
						SetFocus((HWND)lParam);
					}
				}
			}
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadOption_AdvOpts();
				return TRUE;

			case PSN_APPLY:
				//History
				db_set_b(NULL, MODULNAME, "EnableHistory", (BYTE)PopupOptions.EnableHistory);
				db_set_w(NULL, MODULNAME, "HistorySize", PopupOptions.HistorySize);
				PopupHistoryResize();
				db_set_b(NULL, MODULNAME, "UseHppHistoryLog", PopupOptions.UseHppHistoryLog);
				//Avatars
				db_set_b(NULL, MODULNAME, "AvatarBorders", PopupOptions.avatarBorders);
				db_set_b(NULL, MODULNAME, "AvatarPNGBorders", PopupOptions.avatarPNGBorders);
				db_set_b(NULL, MODULNAME, "AvatarRadius", PopupOptions.avatarRadius);
				db_set_w(NULL, MODULNAME, "AvatarSize", PopupOptions.avatarSize);
				db_set_b(NULL, MODULNAME, "EnableAvatarUpdates", PopupOptions.EnableAvatarUpdates);
				//Monitor
				db_set_b(NULL, MODULNAME, "Monitor", PopupOptions.Monitor);
				//Transparency
				db_set_b(NULL, MODULNAME, "UseTransparency", PopupOptions.UseTransparency);
				db_set_b(NULL, MODULNAME, "Alpha", PopupOptions.Alpha);
				db_set_b(NULL, MODULNAME, "OpaqueOnHover", PopupOptions.OpaqueOnHover);

				//Effects
				db_set_b(NULL, MODULNAME, "UseAnimations", PopupOptions.UseAnimations);
				db_set_b(NULL, MODULNAME, "Fade", PopupOptions.UseEffect);
				db_set_ts(NULL, MODULNAME, "Effect", PopupOptions.Effect);
				db_set_dw(NULL, MODULNAME, "FadeInTime", PopupOptions.FadeIn);
				db_set_dw(NULL, MODULNAME, "FadeOutTime", PopupOptions.FadeOut);
				//other old stuff
				db_set_w(NULL, MODULNAME, "MaxPopups", (BYTE)PopupOptions.MaxPopups);
			}
			return TRUE;
		}
		break;

	case WM_DESTROY:
		bDlgInit = false;
		break;
	}
	return FALSE;
}
コード例 #23
0
ファイル: linklist_dlg.cpp プロジェクト: Seldom/miranda-ng
/*
MainDlgProc handles messages to the main dialog box
*/
INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DIALOGPARAM *DlgParam = (DIALOGPARAM*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
	HMENU listMenu;

	switch (msg) {
	case WM_INITDIALOG: {
		MCONTACT hContact;
		TCHAR title[256];
		TCHAR filter[FILTERTEXT];
		RECT rc;
		POINT pt;
			
		SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
		DlgParam = (DIALOGPARAM*)lParam;
		listMenu = GetMenu(hDlg);
		TranslateDialogDefault(hDlg);
		TranslateMenu(listMenu);

		hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
		if (db_get_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0) {
			// First use of this plugin! Set default size!
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistWidth", 400);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistHeight", 450);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistX", 0);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistY", 0);
				
			db_set_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1);
		}

		DlgParam->splitterPosNew = (int)db_get_dw(hContact, LINKLIST_MODULE, LINKLIST_SPLITPOS, -1);

		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
		DlgParam->minSize.cx = rc.right - rc.left;
		DlgParam->minSize.cy = rc.bottom - rc.top;

		GetWindowRect(GetDlgItem(hDlg, IDC_SPLITTER), &rc);
		pt.y = (rc.top + rc.bottom) / 2;
		pt.x = 0;
		ScreenToClient(hDlg, &pt);
			
		DlgParam->splitterPosOld = rc.bottom - 20 - pt.y;
		if(DlgParam->splitterPosNew == -1)
			DlgParam->splitterPosNew = DlgParam->splitterPosOld;
			
		Utils_RestoreWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");

		SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON))); 
		WindowList_Add(hWindowList, hDlg, DlgParam->hContact);
		mir_sntprintf(title, _T("%s [%s]"), TranslateT("Linklist plugin"), pcli->pfnGetContactDisplayName(DlgParam->hContact, 0));
		SetWindowText(hDlg, title);
		GetFilterText(listMenu, filter, _countof(filter));
		SetDlgItemText(hDlg, IDC_STATUS, filter);
			
		mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterProc);
			
		SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)ENM_LINK);
		SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 );
		// This is used in srmm... and I think he knew what he did... :)
		SendDlgItemMessage(hDlg, IDC_MAIN, EM_LIMITTEXT, (WPARAM)-1, 0);

		WriteLinkList(hDlg, WLL_ALL, (LISTELEMENT*)DlgParam->listStart, NULL, 0);

		return TRUE;
		} break;
	// open browser an load url if link is pressed
	// found at
	// http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2004-03/0133.html
	//
	// Popup menu on right mouse button is mainly taken from the miranda 
	// send/receive messaging plugin.
	case WM_NOTIFY: {  
		if (lParam == NULL)
			break;
		if (((LPNMHDR)lParam)->code != EN_LINK)
			break;
		LPTSTR link;
		BYTE mouseEvent;
		ENLINK *pENLink = (ENLINK*)lParam;

		mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);

		switch (pENLink->msg) {
		case WM_MOUSEMOVE:
			if (mouseEvent != 0x01)
				break;
			memcpy(&DlgParam->chrg, &pENLink->chrg, sizeof(CHARRANGE));
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg);
			WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
			break;
		case WM_LBUTTONUP:
			link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 2) * sizeof(TCHAR));
			if (link == NULL)
				break;
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); 
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
			if (_tcsstr(link, _T("mailto:")) != NULL)
				ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
			else {
				bool openNewWindow = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF) != 0xFF;
				Utils_OpenUrlT(link,openNewWindow);
			}
			mir_free(link);
			break;
		case WM_RBUTTONDOWN: { 
			HMENU hPopup, hSubMenu;
			POINT pt;
			hPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2));
			hSubMenu = GetSubMenu(hPopup, 0);

			// Disable Menuoption if "mouse over" events are active
			mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
			if (mouseEvent == 0x01)
				EnableMenuItem(hSubMenu, IDM_SHOWMESSAGE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);	
			TranslateMenu(hSubMenu);
			link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 4) * sizeof(TCHAR));
			if (link == NULL)
				break;
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); 
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);

			pt.x = (short)LOWORD(pENLink->lParam);
			pt.y = (short)HIWORD(pENLink->lParam);
			ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt);

			switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL)) {
			case IDM_LINK_OPEN:
				if (_tcsstr(link, _T("mailto:")) != NULL)
					ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
				else
					Utils_OpenUrlT(link,false);
				break;
			case IDM_LINK_OPENNEW:
				if (_tcsstr(link, _T("mailto:")) != NULL)
					ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
				else
					Utils_OpenUrlT(link);
				break;
			case IDM_LINK_COPY: {
				if (!OpenClipboard(hDlg))
					break;
				EmptyClipboard();

				size_t dataLen = ((mir_tstrlen(link) + 1) * sizeof(TCHAR));
				HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, dataLen);
				memcpy((LPTSTR)GlobalLock(hData), link, dataLen);
				GlobalUnlock(hData);
				SetClipboardData(CF_UNICODETEXT, hData);
				CloseClipboard();
				} break;
			case IDM_SHOWMESSAGE:
				WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
				break;
			}
			mir_free(link);
			DestroyMenu(hPopup);
			} break;
		}
		} break;
	case WM_COMMAND: {
		TCHAR filter[40];

		listMenu = GetMenu(hDlg);
		switch (wParam) {
		case IDM_SEARCH: // open Search Box
			if (DlgParam != 0) {	
				HWND hWndSearchDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCH_DLG), hDlg, SearchDlgProc, (LPARAM)DlgParam);
				EnableMenuItem(listMenu, IDM_SEARCH, (MF_BYCOMMAND | MF_DISABLED | MF_GRAYED));
				ShowWindow(hWndSearchDlg, SW_SHOW);
				SetFocus(GetDlgItem(hWndSearchDlg, IDC_SEARCHSTRING));
			}
			break;
		case IDM_CLEARSEARCH: // clear search results
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			break;
		case IDM_SAVE: // save button
			SaveEditAsStream(hDlg);
			SetFocus(GetDlgItem(hDlg, IDC_MAIN));
			break;
		case IDCANCEL: // Esc or Close pressed
		case IDM_CLOSE:
			SendMessage(hDlg, WM_CLOSE, 0, 0);
			break;
		case IDM_DIR_IN: // view only incoming messages
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}		
			GetFilterText(GetMenu(hDlg), filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_DIR_OUT: // view only outgoing messages
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_TYPE_WEB: // view only e-mail addresses
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			// not possible if search dialog is open
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break;
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_TYPE_MAIL: // view only URLs
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);				
			} else {
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		}
		} break;
	// Taken from srmm.
	// Btw: The longer I searched the source of this plugin
	// to learn how things work, the more I became a fan of
	// the programmer! 
	case WM_GETMINMAXINFO: {
		MINMAXINFO *mmi = (MINMAXINFO *)lParam;
		RECT rcWindow, rcMain;

		GetWindowRect(hDlg, &rcWindow);
		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rcMain);
		mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcMain.right - rcMain.left) - DlgParam->minSize.cx);
		mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcMain.bottom - rcMain.top) - DlgParam->minSize.cy);
		} break;
	case WM_SIZE:
		Utils_ResizeDialog(hDlg, hInst, MAKEINTRESOURCEA(IDD_MAIN_DLG), LinklistResizer, (LPARAM)DlgParam);
		// To get some scrollbars if needed...
		RedrawWindow(GetDlgItem(hDlg, IDC_MAIN), NULL, NULL, RDW_INVALIDATE);
		RedrawWindow(GetDlgItem(hDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
		break;
	
	case DM_LINKSPLITTER: {
		POINT pt;
		RECT rc;
		int splitPosOld;

		GetClientRect(hDlg, &rc);
		pt.x = 0;
		pt.y = wParam;
		ScreenToClient(hDlg, &pt);

		splitPosOld = DlgParam->splitterPosNew;
		DlgParam->splitterPosNew = rc.bottom - pt.y;
			
		GetWindowRect(GetDlgItem(hDlg, IDC_MESSAGE), &rc);
		if (rc.bottom - rc.top + (DlgParam->splitterPosNew - splitPosOld) < 0)
			DlgParam->splitterPosNew = splitPosOld + 0 - (rc.bottom - rc.top);

		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
		if (rc.bottom - rc.top - (DlgParam->splitterPosNew - splitPosOld) < DlgParam->minSize.cy)
			DlgParam->splitterPosNew = splitPosOld - DlgParam->minSize.cy + (rc.bottom - rc.top);
		SendMessage(hDlg, WM_SIZE, 0, 0);
		} break;
	case WM_CLOSE:
		DestroyWindow(hDlg);
		break;
	case WM_DESTROY:
		if (DlgParam != NULL) {
			MCONTACT hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
			Utils_SaveWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");
			db_set_dw(NULL, LINKLIST_MODULE, LINKLIST_SPLITPOS, DlgParam->splitterPosNew);
			RemoveList(DlgParam->listStart);
			mir_free(DlgParam);
		}
		// Remove entry from Window list
		WindowList_Remove(hWindowList, hDlg);
		break;
	}
	return FALSE;
}
コード例 #24
0
ファイル: moduletree.cpp プロジェクト: 0xmono/miranda-ng
void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hwnd here is to the main window, NOT the treview
{
	switch (((NMHDR *)lParam)->code) {
	case TVN_ITEMEXPANDINGA:
	case TVN_ITEMEXPANDINGW:
		if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) {
			ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam;
			if (mtis && (mtis->type == (CONTACT | EMPTY))) {
				TVINSERTSTRUCT tvi;
				HTREEITEM item = {0};
				ModuleTreeInfoStruct *_lParam;
				HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES);
				ModSetLinkLinkItem *module;
				ModuleSettingLL modlist;
				MCONTACT hContact = mtis->hContact;

				mtis->type = CONTACT;

				if (!EnumModules(&modlist)) {
					msg(Translate("Error loading module list"), modFullname);
					break;
				}

				module = modlist.first;
				while (module && hwnd2mainWindow) {
					if (module->name[0] && !IsModuleEmpty(hContact, module->name)) {
						tvi.hParent = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
						tvi.hInsertAfter = TVI_SORT;
						tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
						tvi.item.pszText = module->name;

						_lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
						_lParam->hContact = hContact;

						tvi.item.iImage = 5;
						tvi.item.iSelectedImage = 6;
						_lParam->type = KNOWN_MODULE;

						tvi.item.lParam = (LPARAM)_lParam;
						TreeView_InsertItem(hwnd2Tree, &tvi);
					}
					module = (ModSetLinkLinkItem *)module->next;
				}

				FreeModuleSettingLL(&modlist);
			}
		}
		break;

	case TVN_SELCHANGEDA:
	case TVN_SELCHANGEDW:
		{
			ModuleTreeInfoStruct *mtis;
			LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
			TVITEM tvi = {0};
			char text[264];
			MCONTACT hContact;
			HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS);
			tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
			tvi.hItem = pnmtv->itemNew.hItem;
			tvi.pszText = text;
			tvi.cchTextMax = 264;
			TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi);

			if (tvi.lParam) {
				mtis = (ModuleTreeInfoStruct *)tvi.lParam;
				hContact = mtis->hContact;

				if (mtis->type == STUB)
					break;

				if (populating)
					Select = 0;

				if (mtis->type == MODULE) {
					SettingListInfo *info = (SettingListInfo *)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA);
					BOOL refresh = 1;

					if (info) {
						if (info->hContact == hContact && !mir_strcmp(info->module, text))
							refresh = 0;
					}

					if (refresh)
						PopulateSettings(hwnd2Settings, hContact, text);
				}
				else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) {
					char data[32], szProto[256];
					int index, loaded, multi = 0;
					LVITEM lvi = {0};
					lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
					lvi.iImage = 6;

					ClearListview(hwnd2Settings);
					SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, 0);
					if (himl2)
						ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL);

					if (mtis->type == CONTACT_ROOT_ITEM && !hContact) {
						multi = 1;
						hContact = db_find_first();
					}

					while (hContact && hwnd2mainWindow) {
						if (multi) {
							// filter
							if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto)))
								loaded = IsProtocolLoaded(szProto);
							else
								loaded = 0;

							if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) {
								hContact = db_find_next(hContact);
								continue;
							}
						}

						lvi.iItem = 0;
						lvi.pszText = (char *)GetContactName(hContact, NULL, FALSE);

						index = ListView_InsertItem(hwnd2Settings, &lvi);

						mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact);

						ListView_SetItemText(hwnd2Settings, index, 1, data);
						ListView_SetItemText(hwnd2Settings, index, 2, Translate("HANDLE"));
						ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)");

						if (!multi)
							break;

						hContact = db_find_next(hContact);
					}
				}
				else
					ClearListview(hwnd2Settings);
			}
			else // clear any settings that may be there...
				ClearListview(hwnd2Settings);
		}
		break; //TVN_SELCHANGED:

	case NM_RCLICK:
		if (((NMHDR *)lParam)->code == NM_RCLICK)
			moduleListRightClick(hwnd, wParam, lParam);
		break;

	case TVN_BEGINLABELEDITA: // subclass it..
	case TVN_BEGINLABELEDITW:
		{
			LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
			ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam;
			HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES));
			if (!mtis->type || (mtis->type == CONTACT)) {
				SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
				break;
			}
			mir_subclassWindow(hwnd2Edit, ModuleTreeLabelEditSubClassProc);
			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
		}
		break;

	case TVN_ENDLABELEDITA:
	case TVN_ENDLABELEDITW:
		LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
		TVITEM tvi = {0};
		char text[264];
		char *newtext;
		ModuleTreeInfoStruct *mtis;
		tvi.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_PARAM;
		tvi.hItem = ptvdi->item.hItem;
		tvi.pszText = text;
		tvi.cchTextMax = 264;
		TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi);
		mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam;

		newtext = u2a((WCHAR *)ptvdi->item.pszText);

		if (!newtext // edit control failed
			|| !mtis->type // its a root item
			|| mtis->type == CONTACT // its a contact
			|| *newtext == 0)  // empty string
			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
		else {
			if (mir_strcmp(tvi.pszText, newtext)) {
				renameModule(tvi.pszText, newtext, mtis->hContact);

				findAndRemoveDuplicates(((LPNMHDR)lParam)->hwndFrom, mtis->hContact, newtext);

				if (TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi)) {
					tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
					tvi.iImage = 1;
					tvi.iSelectedImage = 2;
					TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &tvi);

					PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext);
				}
			}
			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
		}

		mir_free(newtext);
		break;
	}
}
コード例 #25
0
static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendMessage(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), EM_LIMITTEXT, MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE - 1, 0);
		mir_subclassWindow(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), StatusMsgEditSubclassProc);
		return TRUE;

	case WMU_SETDATA:
		{
			SetStatusMessageData *data = (SetStatusMessageData *) malloc(sizeof(SetStatusMessageData));
			data->status = (int)wParam;
			data->proto_num = (int)lParam;

			SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG) data);

			if (data->proto_num >= 0) {
				Protocol *proto = protocols->Get(data->proto_num);

				HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0);
				if (hIcon != NULL) {
					SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
					DestroyIcon(hIcon);
				}

				TCHAR title[256];
				mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Status Message for %s"), proto->description);
				SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title);

				SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg());
			}
			else if (data->status != 0)
			{
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(Status2SkinIcon(data->status)));

				TCHAR title[256];
				mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Status Message for %s"),
					CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, data->status, GSMDF_TCHAR));
				SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title);

				SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg(data->status));
			}
			else
			{
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA));

				SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg());
			}

			return TRUE;
		}
	case WM_COMMAND:
		switch(wParam) {
		case IDOK:
			{
				TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
				GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, sizeof(tmp));

				SetStatusMessageData *data = (SetStatusMessageData *) GetWindowLong(hwndDlg, GWLP_USERDATA);

				if (data->proto_num >= 0)
					protocols->Get(data->proto_num)->SetStatusMsg(tmp);
				else if (data->status == 0)
					protocols->SetStatusMsgs(tmp);
				else
					protocols->SetStatusMsgs(data->status, tmp);

				DestroyWindow(hwndDlg);
			}
			break;

		case IDCANCEL:
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		SetWindowLong(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_WNDPROC, 
			GetWindowLong(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_USERDATA));
		free((SetStatusMessageData *) GetWindowLong(hwndDlg, GWLP_USERDATA));
		InterlockedExchange(&status_msg_dialog_open, 0);
		break;
	}

	return FALSE;
}
コード例 #26
0
//this is the history list window handler
INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static int bInitializing;

	switch (msg) {
	case WM_INITDIALOG:
		bInitializing = 1;
		{
			int renderer = lstPopupHistory.GetRenderer();

			SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY,0));
			SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY,1));

			LoadRenderer(hWnd, renderer);

			TranslateDialogDefault(hWnd);
			HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY);

			ListView_SetExtendedListViewStyleEx(hHistoryList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

			mir_subclassWindow(hHistoryList, PopupsListSubclassProc);

			LoadHistoryColumns(hHistoryList);

			RefreshPopupHistory(hWnd, renderer);
		}
		bInitializing = 0;
		return TRUE;

	case WM_DESTROY:
		UnloadRenderer(hWnd, lstPopupHistory.GetRenderer());
		hHistoryWindow = NULL;
		break;

	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;

	case WM_WINDOWPOSCHANGING:
		{
			WINDOWPOS *wndPos = (WINDOWPOS *) lParam;

			if (wndPos->cx < MIN_HISTORY_WIDTH)
				wndPos->cx = MIN_HISTORY_WIDTH;
			if (wndPos->cy < MIN_HISTORY_HEIGHT)
				wndPos->cy = MIN_HISTORY_HEIGHT;

			RECT rParent;
			GetWindowRect(hWnd, &rParent);
			HDWP hdWnds = BeginDeferWindowPos(4);

			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM);
			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM);
			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM);
			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_LST_HISTORY), &rParent, wndPos, ANCHOR_ALL);

			EndDeferWindowPos(hdWnds);
			MoveCustomControl(hWnd, lstPopupHistory.GetRenderer()); //move the custom control too, if any
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CLOSE:
			SendMessage(hWnd, WM_CLOSE, 0, 0);
			break;

		case IDC_HISTORY_FILTER_CASESENSITIVE:
			if (HIWORD(wParam) == BN_CLICKED)
				RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer());

		case IDC_HISTORY_FILTER:
			if (HIWORD(wParam) == EN_CHANGE)
				if (!bInitializing)
					RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer());
			break;
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->idFrom) {
		case IDC_LST_HISTORY:
			switch (((LPNMHDR)lParam)->code) {
			case LVN_COLUMNCLICK:
				{
					LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam;
					int column = lv->iSubItem;
					SortParams params = {0};
					params.hList = GetDlgItem(hWnd, IDC_LST_HISTORY);
					params.column = column;

					ListView_SortItemsEx(params.hList, PopupsCompare, (LPARAM) &params);
					lastColumn = (params.column == lastColumn) ? -1 : params.column;

					break;
				}
			}
		}
		break;
	}

	return 0;
}
コード例 #27
0
ファイル: Options.cpp プロジェクト: MrtsComputers/miranda-ng
INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{	
	switch(msg) {
	case WM_INITDIALOG:
		{
			int startupmode,exitmode;
			COMBOBOXINFO cbi={0};
			cbi.cbSize = sizeof(cbi);

			opses_count=0;
			g_opHdlg=hdlg;
			bOptionsInit=TRUE;
			TranslateDialogDefault(hdlg);
			hMarked = Skin_GetIconByHandle(iconList[1].hIcolib);
			hNotMarked = Skin_GetIconByHandle(iconList[2].hIcolib);

			hIcon=(bChecked=IsMarkedUserDefSession(opses_count))?hMarked:hNotMarked;

			SetDlgItemInt(hdlg, IDC_TRACK,ses_limit=db_get_b(0, MODNAME, "TrackCount", 10), FALSE);
			SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
			SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE));

			SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
			SetDlgItemInt(hdlg, IDC_STARTDELAY, db_get_w(NULL, MODNAME, "StartupModeDelay", 1500), FALSE);
			startupmode = db_get_b(NULL, MODNAME, "StartupMode", 3);
			exitmode = db_get_b(NULL, MODNAME, "ShutdownMode", 2);

			g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0);
			g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0);
			g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1);
			g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0);

			CheckDlgButton(hdlg,IDC_EXCLHIDDEN,g_bExclHidden?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_LASTHIDDENWARN,g_bWarnOnHidden?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_WARNINGS,g_bOtherWarnings?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_CRASHRECOVERY,g_bCrashRecovery?BST_CHECKED:BST_UNCHECKED);


			if (startupmode == 1)
				CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
			else if (startupmode == 3) {
				CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
				CheckDlgButton(hdlg,IDC_CHECKLAST,BST_CHECKED);
			}
			else if (startupmode == 2) {
				CheckDlgButton(hdlg,IDC_RLOADLAST,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			}
			else if (startupmode == 0)	{
				CheckDlgButton(hdlg,IDC_RNOTHING,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			}

			if (exitmode == 0) {
				CheckDlgButton(hdlg,IDC_REXDSAVE,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE);
			}
			else if (exitmode == 1)
				CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED);
			else if (exitmode == 2)
				CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED);

			LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
			if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
				SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
				if (!OpLoadSessionContacts(0,opses_count))
					EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}

			GetComboBoxInfo(GetDlgItem(hdlg,IDC_LIST),&cbi);
			mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc);

			hComboBoxEdit=cbi.hwndItem;
			hComboBox=cbi.hwndCombo;

			SetWindowPos( hComboBoxEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );

			bOptionsInit=FALSE;
		}
		break;

	case WM_CTLCOLORLISTBOX:
		switch(GetDlgCtrlID((HWND) lparam)) {
		case IDC_OPCLIST:
			SetBkMode((HDC) wparam, TRANSPARENT);
			return (BOOL) CreateSolidBrush(GetSysColor(COLOR_3DFACE));
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lparam)->code) {
		case PSN_APPLY:
			{
				int iDelay=GetDlgItemInt(hdlg, IDC_STARTDELAY,NULL, FALSE);
				db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
				db_set_b(0, MODNAME, "TrackCount", (BYTE)(ses_limit=GetDlgItemInt(hdlg, IDC_TRACK,NULL, FALSE)));
				if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
					db_set_b(NULL, MODNAME, "ShutdownMode", 2);
				else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
					db_set_b(NULL, MODNAME, "ShutdownMode", 0);
				else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
					db_set_b(NULL, MODNAME, "ShutdownMode", 1);

				if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
					if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
						db_set_b(NULL, MODNAME, "StartupMode", 1);
					else
						db_set_b(NULL, MODNAME, "StartupMode", 3);
				}
				else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
					db_set_b(NULL, MODNAME, "StartupMode", 2);
				else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
					db_set_b(NULL, MODNAME, "StartupMode", 0);

				db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
				db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
				db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
				db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
			}
			return 1;

		case CLN_CHECKCHANGED:
			if (((LPNMHDR)lparam)->idFrom  == IDC_EMCLIST)
			{
				int iSelection = (int)((NMCLISTCONTROL *)lparam)->hItem;
				HANDLE hContact = db_find_first();
				for ( ; hContact; hContact = db_find_next(hContact))
					if (SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection)
						break;
				if (hContact)
					EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				else
					EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
			}
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wparam)) {
		case IDC_LIST:
			switch(HIWORD(wparam)) {
			case CBN_EDITCHANGE:
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				bSesssionNameChanged=TRUE;
				break;

			case CBN_SELCHANGE:
				{
					HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
					int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
					if (index != CB_ERR) {
						opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
						SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
						if (IsMarkedUserDefSession(opses_count)) {
							hIcon=hMarked;
							bChecked=TRUE;
							RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
						}
						else {
							hIcon=hNotMarked;
							bChecked=FALSE;
							RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
						}
						OpLoadSessionContacts(0,opses_count);
						if (!hOpClistControl)
							EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
						else {
							for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
								SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,0);

							for (int i=0 ; session_list_t[i] > 0; i++) {
								HANDLE hContact = (HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
								SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact, 1);
							}
							EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
						}
					}
				}break;
			}break;

		case IDC_EDIT:
			if (!hOpClistControl) {
				ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_HIDE);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
				//EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("View"));
				hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE, _T(CLISTCONTROL_CLASS), _T(""),
					WS_TABSTOP |WS_VISIBLE | WS_CHILD , 
					14,198,161,163,hdlg, (HMENU)IDC_EMCLIST, hinstance, 0);

				SetWindowLongPtr(hOpClistControl, GWL_STYLE,
					GetWindowLongPtr(hOpClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
				SendMessage(hOpClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);

				SendMessage(hOpClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0);

				for (int i=0 ; session_list_t[i] > 0; i++) {
					HANDLE hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
					SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1);
				}
			}
			else {
				ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_SHOWNA);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
				SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("Edit"));
				DestroyWindow(hOpClistControl);
				hOpClistControl=NULL;
			}
			break;

		case IDC_SAVE:
			{
				int i=0;
				for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
					BYTE res =(BYTE)SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_GETCHECKMARK,
						SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
					if (res) {
						SetSessionMark(hContact,1,'1',opses_count);
						SetInSessionOrder(hContact,1,opses_count,i);
						i++;
					}
					else {
						SetSessionMark(hContact,1,'0',opses_count);
						SetInSessionOrder(hContact,1,opses_count,0);
					}
				}
				if (bSesssionNameChanged) {
					if (GetWindowTextLength(hComboBoxEdit)) {
						TCHAR szUserSessionName[MAX_PATH]={'\0'};
						GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName));
						RenameUserDefSession(opses_count,szUserSessionName);
						SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT ,0,0);
						LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
					}
					bSesssionNameChanged=FALSE;
				}
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
			}
			break;

		case IDC_DEL:
			DelUserDefSession(opses_count);

			SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
			SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);

			LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);

			opses_count=0;

			if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
				SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
				if (!OpLoadSessionContacts(0,opses_count))
					EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}
			else {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}
			break;

		case IDC_STARTDIALOG:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_RLOADLAST:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_RNOTHING:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXSAVE:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXDSAVE:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXASK:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;
		}

		if (HIWORD(wparam) == CBN_DROPDOWN&&!hOpClistControl) {
			SendMessage(hComboBoxEdit,EM_SETSEL ,0,0);
			SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
			SendMessage(hComboBoxEdit,WM_KILLFOCUS ,0,0);
			HideCaret(hComboBoxEdit);
		}

		if ((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam) == IDC_LIST)&&!hOpClistControl) {
			SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
			HideCaret(hComboBoxEdit);
		}

		if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam)!=EN_CHANGE || (HWND)lparam != GetFocus()))
			return 0;

		if (lparam&&!bOptionsInit&&(HIWORD(wparam) == BN_CLICKED)&& (GetFocus() == (HWND)lparam)
			&&((LOWORD(wparam) == IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY))))
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);

		return 0;

	case WM_CLOSE:
		EndDialog(hdlg,0);
		return 0;
	}
	return 0;
}
コード例 #28
0
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL);
		Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu"));

		SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0);
		dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData));
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
		dat->hContact = lParam;
		dat->hAckEvent = NULL;
		dat->hSendId = NULL;
		dat->sendBuffer = NULL;

		WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact);
		{
			TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0);
			SetDlgItemText(hwndDlg, IDC_NAME, str);
		}

		GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS));
		SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0);
		if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0);
		EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE);
		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send");
		mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc);
		mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc);

		// From message dlg
		if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0))
			ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);

		SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0);
		// From message dlg end
		return TRUE;

	case WM_DDE_DATA:
	case WM_DDE_ACK:
		return DdeMessage(hwndDlg, msg, wParam, lParam);

	case WM_TIMER:
		if (wParam == 0) {
			//ICQ sendurl timed out
			KillTimer(hwndDlg, 0);
			MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK);
			EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
			EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE);
			SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0);
		}
		break;

	case WM_MEASUREITEM:
		return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
			if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) {
				char *szProto = GetContactProto(dat->hContact);
				if (szProto) {
					HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
					if (hIcon) {
						DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
						DestroyIcon(hIcon);
					}
				}
			}
		}
		return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);

	case DM_UPDATETITLE:
		sttUpdateTitle(hwndDlg, dat->hContact);
		break;

	case WM_COMMAND:
		if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
			break;

		switch (LOWORD(wParam)) {
		case IDOK:
			{
				char *body, *url;
				int bodySize, urlSize;

				urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1;
				url = (char*)mir_alloc(urlSize);
				GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize);
				if (url[0] == 0) {
					mir_free(url);
					break;
				}
				bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1;
				body = (char*)mir_alloc(bodySize);
				GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize);

				dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, mir_strlen(url)+mir_strlen(body)+2);
				mir_strcpy(dat->sendBuffer, url);
				mir_strcpy(dat->sendBuffer+mir_strlen(url)+1, body);
				dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT);
				dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer);
				mir_free(url);
				mir_free(body);

				//create a timeout timer
				SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL);
				EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE);
				SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0);

				return TRUE;
			}

		case IDCANCEL:
			DestroyWindow(hwndDlg);
			return TRUE;

		case IDC_URLS:
			if (HIWORD(wParam) == CBN_SELCHANGE) {
				int i, urlSize;
				char *title;
				i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0);
				title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0);
				SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title);
				urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0);
				EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
			}
			else if (HIWORD(wParam) == CBN_EDITCHANGE) {
				int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS));
				EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
			}
			break;
		case IDC_USERMENU:
			{
				RECT rc;
				HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
				GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
				TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
				DestroyMenu(hMenu);
			}
			break;

		case IDC_HISTORY:
			CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0);
			break;

		case IDC_DETAILS:
			CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0);
			break;

		case IDC_ADD:
			ADDCONTACTSTRUCT acs = {0};
			acs.hContact = dat->hContact;
			acs.handleType = HANDLE_CONTACT;
			acs.szProto = 0;
			CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);

			if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0))
				ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
		}
		break;

	case HM_EVENTSENT:
		{
			ACKDATA *ack = (ACKDATA*)lParam;
			if (ack->hProcess != dat->hSendId) break;
			if (ack->hContact != dat->hContact) break;
			if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break;

			DBEVENTINFO dbei = { 0 };
			dbei.cbSize = sizeof(dbei);
			dbei.eventType = EVENTTYPE_URL;
			dbei.flags = DBEF_SENT;
			dbei.szModule = GetContactProto(dat->hContact);
			dbei.timestamp = time(NULL);
			dbei.cbBlob = (DWORD)(mir_strlen(dat->sendBuffer)+mir_strlen(dat->sendBuffer+mir_strlen(dat->sendBuffer)+1)+2);
			dbei.pBlob = (PBYTE)dat->sendBuffer;
			db_event_add(dat->hContact, &dbei);
			KillTimer(hwndDlg, 0);
			DestroyWindow(hwndDlg);
		}
		break;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU);

		WindowList_Remove(hUrlWindowList, hwndDlg);
		if (dat->hAckEvent) UnhookEvent(dat->hAckEvent);
		if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer);
		mir_free(dat);
		Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send");

		for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--)
			mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0));
		break;
	}

	return FALSE;
}
コード例 #29
0
ファイル: modern_clcutils.cpp プロジェクト: kxepal/miranda-ng
void cliBeginRenameSelection(HWND hwnd, ClcData *dat)
{
	ClcContact *contact;
	ClcGroup *group;
	int indent, x, y, subident, h, w;
	RECT clRect;
	RECT r;


	KillTimer(hwnd, TIMERID_RENAME);
	ReleaseCapture();
	dat->iHotTrack = -1;
	dat->selection = cliGetRowByIndex(dat, dat->selection, &contact, &group);
	if (dat->selection == -1) return;
	if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP) return;

	if (contact->type == CLCIT_CONTACT && contact->isSubcontact)
		subident = dat->subIndent;
	else
		subident = 0;

	for (indent = 0; group->parent; indent++, group = group->parent);
	GetClientRect(hwnd, &clRect);
	x = indent*dat->groupIndent + dat->iconXSpace - 2 + subident;
	w = clRect.right - x;
	y = cliGetRowTopY(dat, dat->selection) - dat->yScroll;
	h = dat->row_heights[dat->selection];
	{
		int i;
		for (i = 0; i <= FONTID_MODERN_MAX; i++)
			if (h < dat->fontModernInfo[i].fontHeight + 4) h = dat->fontModernInfo[i].fontHeight + 4;
	}
	//TODO contact->pos_label


	{

		RECT rectW;
		int h2;
		GetWindowRect(hwnd, &rectW);
		//       w = contact->pos_full_first_row.right-contact->pos_full_first_row.left;
		//       h = contact->pos_full_first_row.bottom-contact->pos_full_first_row.top;
		//w = clRect.right-x;
		//w = clRect.right-x;
		//x += rectW.left;//+contact->pos_full_first_row.left;
		//y += rectW.top;//+contact->pos_full_first_row.top;
		x = contact->pos_rename_rect.left + rectW.left;
		y = contact->pos_label.top + rectW.top;
		w = contact->pos_rename_rect.right - contact->pos_rename_rect.left;
		h2 = contact->pos_label.bottom - contact->pos_label.top + 4;
		h = h2;//max(h,h2);

	}

	{
		int a = 0;
		if (contact->type == CLCIT_GROUP)
		{
			if (dat->row_align_group_mode == 1) a |= ES_CENTER;
			else if (dat->row_align_group_mode == 2) a |= ES_RIGHT;
		}
		if (dat->text_rtl) a |= EN_ALIGN_RTL_EC;
		if (contact->type == CLCIT_GROUP)
			dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL);
		else
			dat->hwndRenameEdit = CreateWindow(_T("EDIT"), pcli->pfnGetContactDisplayName(contact->hContact, 0), WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL);
	}
	SetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE, GetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE)&(~WS_CAPTION) | WS_BORDER);
	SetWindowLongPtr(dat->hwndRenameEdit, GWLP_USERDATA, (LONG_PTR)dat);
	mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc);
	SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM)(contact->type == CLCIT_GROUP ? dat->fontModernInfo[FONTID_OPENGROUPS].hFont : dat->fontModernInfo[FONTID_CONTACTS].hFont), 0);
	SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0);
	SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, -1);

	r.top = 1;
	r.bottom = h - 1;
	r.left = 0;
	r.right = w;

	//ES_MULTILINE

	SendMessage(dat->hwndRenameEdit, EM_SETRECT, 0, (LPARAM)&r);

	CLUI_ShowWindowMod(dat->hwndRenameEdit, SW_SHOW);
	SetWindowPos(dat->hwndRenameEdit, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	SetFocus(dat->hwndRenameEdit);
}
コード例 #30
0
ファイル: tlen_opt.cpp プロジェクト: Ganster41/miranda-ng
INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	char text[256];

	TlenProtocol *proto = (TlenProtocol *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	switch (msg) {
	case WM_INITDIALOG:
		{
			DBVARIANT dbv;
			proto = (TlenProtocol *)lParam;
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)proto);
			TranslateDialogDefault(hwndDlg);
			if (!db_get_ts(NULL, proto->m_szModuleName, "LoginName", &dbv)) {
				SetDlgItemText(hwndDlg, IDC_EDIT_USERNAME, dbv.ptszVal);
				db_free(&dbv);
			}
			if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
				SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
				db_free(&dbv);
			}
			CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, db_get_b(NULL, proto->m_szModuleName, "SavePassword", TRUE));

			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), TlenValidateUsernameWndProc);
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_EDIT_USERNAME:
		case IDC_EDIT_PASSWORD:
			if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		case IDC_SAVEPASSWORD:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		case IDC_REGISTERACCOUNT:
			CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) TLEN_REGISTER);
			break;
		}
		break;
	case WM_NOTIFY:
		switch (((LPNMHDR) lParam)->code) {
		case PSN_APPLY:
			{
				BOOL reconnectRequired = FALSE;
				DBVARIANT dbv;

				GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, sizeof(text));
				if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv) || strcmp(text, dbv.pszVal))
					reconnectRequired = TRUE;
				if (dbv.pszVal != NULL)	db_free(&dbv);
				db_set_s(NULL, proto->m_szModuleName, "LoginName", strlwr(text));

				if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
					GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
					if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
						reconnectRequired = TRUE;
					if (dbv.pszVal != NULL)	db_free(&dbv);
					db_set_s(NULL, proto->m_szModuleName, "Password", text);
				}
				else
					db_unset(NULL, proto->m_szModuleName, "Password");

				db_set_b(NULL, proto->m_szModuleName, "SavePassword", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD));
				if (reconnectRequired && proto->isConnected)
					MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
				TlenLoadOptions(proto);
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}