コード例 #1
0
/*!
	オーナードロー・サイズ計測
	@param[in]	hWnd			親ウインドウハンドル
	@param[in]	pstMeasureItem	サイズ情報
	@return		HRESULT			終了状態コード
*/
VOID AaItemsMeasureItem( HWND hWnd, LPMEASUREITEMSTRUCT pstMeasureItem )
{
	HDC		hDC;
	INT		rdLength, rdHeight;
	LPSTR	pcConts;
	RECT	stRect;

	//	項目の文字列取得
	pcConts = AacAsciiArtGet( pstMeasureItem->itemID );
	if( !pcConts )	return;

	rdLength = strlen( pcConts );

	ListBox_GetItemRect( ghItemsWnd, pstMeasureItem->itemID, &stRect );

	hDC = GetDC( ghItemsWnd );
	DrawTextExA( hDC, pcConts, rdLength, &stRect, DT_LEFT | DT_EDITCONTROL | DT_NOPREFIX | DT_CALCRECT );
	ReleaseDC( ghItemsWnd, hDC );

	pstMeasureItem->itemHeight = (stRect.bottom - stRect.top);
	if( 256 <= pstMeasureItem->itemHeight )	pstMeasureItem->itemHeight = 255;

	free( pcConts );

	return;
}
コード例 #2
0
/**
 *	@brief	Draws separators on listbox.
 *	@param[in]	hDC	device context.
 */
void WinComboListSeparators::ListBox::DrawSeparators(HDC hDC)
{
	std::vector<SInt32>::const_iterator it;
	for (it = container->separatorIndexes.begin(); it != container->separatorIndexes.end(); it++)
	{
		SInt32 ix = *it;

		RECT rc;
		ListBox_GetItemRect(m_hWnd, ix, &rc);
		rc.top = rc.bottom - 1;
		
		COLORREF oldColor = SetBkColor(hDC, RGB(0,0,0));
		ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
		SetBkColor(hDC, oldColor);
	}
}
コード例 #3
0
ファイル: listbox.cpp プロジェクト: Zombiebest/Dolphin
bool wxListBox::GetItemRect(size_t n, wxRect& rect) const
{
    wxCHECK_MSG( IsValid(n), false,
                 wxT("invalid index in wxListBox::GetItemRect") );

    RECT rc;

    if ( ListBox_GetItemRect(GetHwnd(), n, &rc) != LB_ERR )
    {
        rect = wxRectFromRECT(rc);
        return true;
    }
    else
    {
        // couldn't retrieve rect: for example, item isn't visible
        return false;
    }
}
コード例 #4
0
ファイル: outbask.c プロジェクト: cixonline/ameol
/* This function updates the specified item in the out-basket
 * window. If fStatus is TRUE, only the item status (ie. the three
 * bitmaps to the left of the description) is updated.
 */
void FASTCALL UpdateOutbasketItem( LPOB lpob, BOOL fStatus )
{
   if( NULL != hwndOutBasket )
      {
      HWND hwndList;
      int cTotal;
      int c;

      hwndList = GetDlgItem( hwndOutBasket, IDD_LIST );
      cTotal = ListBox_GetCount( hwndList );
      for( c = 0; c < cTotal; ++c )
         if( (LPOB)ListBox_GetItemData( hwndList, c ) == lpob )
            {
            RECT rc;

            ListBox_GetItemRect( hwndList, c, &rc );
            if( fStatus )
               rc.right = 48;
            InvalidateRect( hwndList, &rc, TRUE );
            UpdateWindow( hwndList );
            break;
            }
      }
}
コード例 #5
0
INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg,UINT message, WPARAM wParam, LPARAM lParam)
{
	struct TAccMgrData *dat = (struct TAccMgrData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch(message) {
	case WM_INITDIALOG:
		{
			TAccMgrData *dat = (TAccMgrData *)mir_alloc(sizeof(TAccMgrData));
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);

			TranslateDialogDefault(hwndDlg);
			Window_SetIcon_IcoLib( hwndDlg, SKINICON_OTHER_ACCMGR );

			Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("New account"));
			Button_SetIcon_IcoLib(hwndDlg, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit"));
			Button_SetIcon_IcoLib(hwndDlg, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove account"));
			Button_SetIcon_IcoLib(hwndDlg, IDC_OPTIONS, SKINICON_OTHER_OPTIONS, LPGEN( "Configure..."));
			Button_SetIcon_IcoLib(hwndDlg, IDC_UPGRADE, SKINICON_OTHER_ACCMGR, LPGEN("Upgrade account"));

			EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT), FALSE);
			EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE), FALSE);
			EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS), FALSE);
			EnableWindow(GetDlgItem(hwndDlg, IDC_UPGRADE), FALSE);

			{
				LOGFONT lf;
				HDC hdc;
				HFONT hfnt;
				TEXTMETRIC tm;

				GetObject((HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0), sizeof(lf), &lf);
				dat->hfntText = CreateFontIndirect(&lf);

				GetObject((HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0), sizeof(lf), &lf);
				lf.lfWeight = FW_BOLD;
				dat->hfntTitle = CreateFontIndirect(&lf);

				hdc = GetDC(hwndDlg);
				hfnt = ( HFONT )SelectObject(hdc, dat->hfntTitle);
				GetTextMetrics(hdc, &tm);
				dat->titleHeight = tm.tmHeight;
				SelectObject(hdc, dat->hfntText);
				GetTextMetrics(hdc, &tm);
				dat->textHeight = tm.tmHeight;
				SelectObject(hdc, hfnt);
				ReleaseDC(hwndDlg, hdc);

				dat->normalHeight = 4 + max(dat->titleHeight, GetSystemMetrics(SM_CYSMICON));
				dat->selectedHeight = dat->normalHeight + 4 + 2 * dat->textHeight;

				SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hfntTitle, 0);
				SendDlgItemMessage(hwndDlg, IDC_TXT_ACCOUNT, WM_SETFONT, (WPARAM)dat->hfntTitle, 0);
				SendDlgItemMessage(hwndDlg, IDC_TXT_ADDITIONAL, WM_SETFONT, (WPARAM)dat->hfntTitle, 0);
			}

			dat->iSelected = -1;
			sttSubclassAccList(GetDlgItem(hwndDlg, IDC_ACCLIST), TRUE);
			SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 );

			Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AccMgr", "");
		}
		return TRUE;

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

	case WM_MEASUREITEM:
		{
			LPMEASUREITEMSTRUCT lps = (LPMEASUREITEMSTRUCT)lParam;
			PROTOACCOUNT *acc = (PROTOACCOUNT *)lps->itemData;

			if ((lps->CtlID != IDC_ACCLIST) || !acc)
				break;

			lps->itemWidth = 10;
			lps->itemHeight = dat->normalHeight;
		}
		return TRUE;

	case WM_DRAWITEM:
		{
			int tmp, size, length;
			TCHAR *text;
			HICON hIcon;
			HBRUSH hbrBack;
			SIZE sz;

			int cxIcon = GetSystemMetrics(SM_CXSMICON);
			int cyIcon = GetSystemMetrics(SM_CYSMICON);

			LPDRAWITEMSTRUCT lps = (LPDRAWITEMSTRUCT)lParam;
			PROTOACCOUNT *acc = (PROTOACCOUNT *)lps->itemData;

			if ((lps->CtlID != IDC_ACCLIST) || (lps->itemID == -1) || !acc)
				break;

			SetBkMode(lps->hDC, TRANSPARENT);
			if (lps->itemState & ODS_SELECTED) {
				hbrBack = GetSysColorBrush(COLOR_HIGHLIGHT);
				SetTextColor(lps->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
			}
			else {
				hbrBack = GetSysColorBrush(COLOR_WINDOW);
				SetTextColor(lps->hDC, GetSysColor(COLOR_WINDOWTEXT));
			}
			FillRect(lps->hDC, &lps->rcItem, hbrBack);

			lps->rcItem.left += 2;
			lps->rcItem.top += 2;
			lps->rcItem.bottom -= 2;

			if ( acc->bOldProto )
				tmp = SKINICON_OTHER_ON;
			else if ( acc->bDynDisabled )
				tmp = SKINICON_OTHER_OFF;
			else
				tmp = acc->bIsEnabled ? SKINICON_OTHER_TICK : SKINICON_OTHER_NOTICK;

			hIcon = LoadSkinnedIcon(tmp);
			DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL);
			IconLib_ReleaseIcon(hIcon, 0);

			lps->rcItem.left += cxIcon + 2;

			if (acc->ppro) {
				hIcon = acc->ppro->GetIcon( PLI_PROTOCOL | PLIF_SMALL );
				DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL);
				DestroyIcon(hIcon);
			}
			lps->rcItem.left += cxIcon + 2;

			length = SendDlgItemMessage(hwndDlg, IDC_ACCLIST, LB_GETTEXTLEN, lps->itemID, 0);
			size = max(length+1, 256);
			text = (TCHAR *)_alloca(sizeof(TCHAR) * size);
			SendDlgItemMessage(hwndDlg, IDC_ACCLIST, LB_GETTEXT, lps->itemID, (LPARAM)text);

			SelectObject(lps->hDC, dat->hfntTitle);
			tmp = lps->rcItem.bottom;
			lps->rcItem.bottom = lps->rcItem.top + max(cyIcon, dat->titleHeight);
			DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_VCENTER);
			lps->rcItem.bottom = tmp;
			GetTextExtentPoint32(lps->hDC, text, length, &sz);
			lps->rcItem.top += max(cxIcon, sz.cy) + 2;

			if (lps->itemID == (unsigned)dat->iSelected) {
				SelectObject(lps->hDC, dat->hfntText);
				mir_sntprintf(text, size, _T("%s: ") _T(TCHAR_STR_PARAM), TranslateT("Protocol"), acc->szProtoName);
				length = lstrlen(text);
				DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS);
				GetTextExtentPoint32(lps->hDC, text, length, &sz);
				lps->rcItem.top += sz.cy + 2;

				if (acc->ppro && Proto_IsProtocolLoaded(acc->szProtoName)) {
					char *szIdName;
					TCHAR *tszIdName;
					CONTACTINFO ci = { 0 };

					szIdName = (char *)acc->ppro->GetCaps( PFLAG_UNIQUEIDTEXT, 0 );
 					tszIdName = szIdName ? mir_a2t(szIdName) : mir_tstrdup(TranslateT("Account ID"));
					
					ci.cbSize = sizeof(ci);
					ci.hContact = NULL;
					ci.szProto = acc->szModuleName;
					ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
					if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
						switch (ci.type) {
						case CNFT_ASCIIZ:
							mir_sntprintf( text, size, _T("%s: %s"), tszIdName, ci.pszVal );
							mir_free(ci.pszVal);
							break;
						case CNFT_DWORD:
							mir_sntprintf( text, size, _T("%s: %d"), tszIdName, ci.dVal );
							break;
						}
					}
					else mir_sntprintf(text, size, _T("%s: %s"), tszIdName, TranslateT("<unknown>"));
					mir_free(tszIdName);
				}
				else mir_sntprintf(text, size, TranslateT("Protocol is not loaded."));

				length = lstrlen(text);
				DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS);
				GetTextExtentPoint32(lps->hDC, text, length, &sz);
				lps->rcItem.top += sz.cy + 2;
		}	}
		return TRUE;

	case WM_MY_REFRESH:
		{
			HWND hList = GetDlgItem(hwndDlg, IDC_ACCLIST);
			int i = ListBox_GetCurSel(hList);
			PROTOACCOUNT *acc = (i == LB_ERR) ? NULL : (PROTOACCOUNT *)ListBox_GetItemData(hList, i);

			dat->iSelected = -1;
			SendMessage( hList, LB_RESETCONTENT, 0, 0 );
			for (i = 0; i < accounts.getCount(); ++i) {
				int iItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)accounts[i]->tszAccountName);
				SendMessage(hList, LB_SETITEMDATA, iItem, (LPARAM)accounts[i]);

				if (accounts[i] == acc)
					ListBox_SetCurSel(hList, iItem);
			}

			dat->iSelected = ListBox_GetCurSel(hList); // -1 if error => nothing selected in our case
			if (dat->iSelected >= 0)
				sttSelectItem(dat, hList, dat->iSelected);
			else if (acc && acc->hwndAccMgrUI)
				ShowWindow(acc->hwndAccMgrUI, SW_HIDE);

			sttUpdateAccountInfo(hwndDlg, dat);
		}
		break;

	case WM_CONTEXTMENU:
		if ( GetWindowLongPtr(( HWND )wParam, GWL_ID ) == IDC_ACCLIST ) {
			HWND hwndList = GetDlgItem( hwndDlg, IDC_ACCLIST );
			POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) };
			int iItem = ListBox_GetCurSel( hwndList );

			if (( pt.x == -1 ) && ( pt.y == -1 )) {
				if (iItem != LB_ERR) {
					RECT rc;
					ListBox_GetItemRect( hwndList, iItem, &rc );
					pt.x = rc.left + GetSystemMetrics(SM_CXSMICON) + 4;
					pt.y = rc.top + 4 + max(GetSystemMetrics(SM_CXSMICON), dat->titleHeight);
					ClientToScreen( hwndList, &pt );
				}
			}
			else {
				// menu was activated with mouse => find item under cursor & set focus to our control.
				POINT ptItem = pt;
				ScreenToClient( hwndList, &ptItem );
				iItem = (short)LOWORD(SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELPARAM(ptItem.x, ptItem.y)));
				if (iItem != LB_ERR) 
                {
				    ListBox_SetCurSel(hwndList, iItem);
                    sttUpdateAccountInfo(hwndDlg, dat);
				    sttSelectItem(dat, hwndList, iItem);
				    SetFocus(hwndList);
                }
			}

			if ( iItem != LB_ERR ) {
				PROTOACCOUNT* pa = (PROTOACCOUNT*)ListBox_GetItemData(hwndList, iItem);
				HMENU hMenu = CreatePopupMenu();
				if ( !pa->bOldProto && !pa->bDynDisabled )
					AppendMenu(hMenu, MF_STRING, 1, TranslateT("Rename"));

				AppendMenu(hMenu, MF_STRING, 3, TranslateT("Delete"));

				if ( Proto_IsAccountEnabled( pa ))
					AppendMenu(hMenu, MF_STRING, 4, TranslateT("Configure"));

				if ( pa->bOldProto || pa->bDynDisabled )
					AppendMenu(hMenu, MF_STRING, 5, TranslateT("Upgrade"));

				AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
				AppendMenu(hMenu, MF_STRING, 0, TranslateT("Cancel"));
				switch (TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL )) {
				case 1:
					PostMessage(hwndList, WM_MY_RENAME, 0, 0);
					break;

				case 2:
					sttClickButton(hwndDlg, IDC_EDIT);
					break;

				case 3:
					sttClickButton(hwndDlg, IDC_REMOVE);
					break;

				case 4:
					sttClickButton(hwndDlg, IDC_OPTIONS);
					break;

				case 5:
					sttClickButton(hwndDlg, IDC_UPGRADE);
					break;
				}
				DestroyMenu( hMenu );
			}	
		}
		break;

	case WM_COMMAND:
		switch( LOWORD(wParam)) {
		case IDC_ACCLIST:
			{
				HWND hwndList = GetDlgItem(hwndDlg, IDC_ACCLIST);
				switch (HIWORD(wParam)) {
				case LBN_SELCHANGE:
					sttUpdateAccountInfo(hwndDlg, dat);
					sttSelectItem(dat, hwndList, ListBox_GetCurSel(hwndList));
					SetFocus(hwndList);
					break;

				case LBN_DBLCLK:
					PostMessage(hwndList, WM_MY_RENAME, 0, 0);
					break;

				case LBN_MY_CHECK:
					{
						PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, lParam);
						if ( pa ) {
							if ( pa->bOldProto || pa->bDynDisabled)
								break;

							pa->bIsEnabled = !pa->bIsEnabled;
							if ( pa->bIsEnabled ) {
								if ( ActivateAccount( pa )) {
									pa->ppro->OnEvent( EV_PROTO_ONLOAD, 0, 0 );
									if (!DBGetContactSettingByte(NULL, "CList", "MoveProtoMenus", FALSE))
										pa->ppro->OnEvent( EV_PROTO_ONMENU, 0, 0 );
								}
								else pa->type = PROTOTYPE_DISPROTO;
							}
							else {
								DWORD dwStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
								if (dwStatus >= ID_STATUS_ONLINE) {
									if (IDCANCEL == ::MessageBox(hwndDlg,
										                  TranslateT("Account is online. Disable account?"),
															   TranslateT("Accounts"), MB_OKCANCEL)) {
										pa->bIsEnabled = 1;	//stay enabled
									}
								}

								if ( !pa->bIsEnabled )
									DeactivateAccount( pa, true, false );
							}

							WriteDbAccounts();
							NotifyEventHooks( hAccListChanged, PRAC_CHECKED, ( LPARAM )pa );
							sttUpdateAccountInfo(hwndDlg, dat);
							RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE);
					}	}
					break;

				case LBN_MY_RENAME:
					{
						int iItem = ListBox_GetCurSel(hwndList);
						PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, iItem);
						if ( pa ) {
							mir_free(pa->tszAccountName);
							pa->tszAccountName = (TCHAR*)lParam;
							WriteDbAccounts();
							NotifyEventHooks(hAccListChanged, PRAC_CHANGED, (LPARAM)pa);

							ListBox_DeleteString(hwndList, iItem);
							iItem = ListBox_AddString(hwndList, pa->tszAccountName);
							ListBox_SetItemData(hwndList, iItem, (LPARAM)pa);
							ListBox_SetCurSel(hwndList, iItem);

							sttSelectItem(dat, hwndList, iItem);

							RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE);
						}
						else mir_free((TCHAR*)lParam);
					}
					break;
			}	}
			break;

		case IDC_ADD:
			{
				AccFormDlgParam param = { PRAC_ADDED, NULL };
				if ( IDOK == DialogBoxParam( hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param ))
					SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 );
			}
			break;

		case IDC_EDIT:
			{
				HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST );
				int idx = ListBox_GetCurSel( hList );
				if ( idx != -1 )
					PostMessage(hList, WM_MY_RENAME, 0, 0);
			}
			break;

		case IDC_REMOVE:
			{
				HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST );
				int idx = ListBox_GetCurSel( hList );
				if ( idx != -1 ) {
					PROTOACCOUNT* pa = ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx );
					TCHAR buf[ 200 ];
					mir_sntprintf( buf, SIZEOF(buf), TranslateT( "Account %s is being deleted" ), pa->tszAccountName );
					if (pa->bOldProto) {
						MessageBox( NULL, TranslateT( "You need to disable plugin to delete this account" ), buf,
							MB_ICONERROR | MB_OK );
						break;
					}
					if ( IDYES == MessageBox( NULL, TranslateT( errMsg ), buf, MB_ICONSTOP | MB_DEFBUTTON2 | MB_YESNO )) {
						// lock controls to avoid changes during remove process
						ListBox_SetCurSel( hList, -1 );
						sttUpdateAccountInfo( hwndDlg, dat );
						EnableWindow( hList, FALSE );
						EnableWindow( GetDlgItem(hwndDlg, IDC_ADD), FALSE );

						ListBox_SetItemData( hList, idx, 0 );

						accounts.remove( pa );

						CheckProtocolOrder();

						WriteDbAccounts();
						NotifyEventHooks( hAccListChanged, PRAC_REMOVED, ( LPARAM )pa );

						UnloadAccount( pa, true, true );
						SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 );

						EnableWindow( hList, TRUE );
						EnableWindow( GetDlgItem(hwndDlg, IDC_ADD), TRUE );
			}	}	}
			break;

		case IDC_OPTIONS:
			{
				HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST );
				int idx = ListBox_GetCurSel( hList );
				if ( idx != -1 ) {
					PROTOACCOUNT* pa = ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx );
					if ( pa->bOldProto ) {
						OPENOPTIONSDIALOG ood;
						ood.cbSize = sizeof(ood);
						ood.pszGroup = "Network";
						ood.pszPage = pa->szModuleName;
						ood.pszTab = NULL;
						CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood );
					}
					else OpenAccountOptions( pa );
			}	}
			break;

		case IDC_UPGRADE:
			{
				HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST );
				int idx = ListBox_GetCurSel( hList );
				if ( idx != -1 ) {
					AccFormDlgParam param = { PRAC_UPGRADED, ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx ) };
					DialogBoxParam( hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param );
			}	}
			break;

		case IDC_LNK_NETWORK:
			{
				PSHNOTIFY pshn = {0};
				pshn.hdr.code = PSN_APPLY;
				pshn.hdr.hwndFrom = hwndDlg;
				SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn);

				OPENOPTIONSDIALOG ood = {0};
				ood.cbSize = sizeof(ood);
				ood.pszPage = "Network";
				CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood );
				break;
			}

		case IDC_LNK_ADDONS:
			CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)"http://addons.miranda-im.org/");
			break;

		case IDOK:
			{
				PSHNOTIFY pshn = {0};
				pshn.hdr.code = PSN_APPLY;
				pshn.hdr.hwndFrom = hwndDlg;
				SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn);
				DestroyWindow(hwndDlg);
				break;
			}

		case IDCANCEL:
			{
				PSHNOTIFY pshn = {0};
				pshn.hdr.code = PSN_RESET;
				pshn.hdr.hwndFrom = hwndDlg;
				SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn);
				DestroyWindow(hwndDlg);
				break;
			}
		}
	case PSM_CHANGED:
		{
			HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST );
			int idx = ListBox_GetCurSel( hList );
			if ( idx != -1 ) {
				PROTOACCOUNT *acc = (PROTOACCOUNT *)ListBox_GetItemData(hList, idx);
				if (acc)
				{
					acc->bAccMgrUIChanged = TRUE;
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
			}
			break;
		}
	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
				case PSN_APPLY:
				{	
					int i;
					PSHNOTIFY pshn = {0};
					pshn.hdr.code = PSN_APPLY;
					for (i = 0; i < accounts.getCount(); ++i) {
						if ( accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged ) {
							pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI;
							SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn);
							accounts[i]->bAccMgrUIChanged = FALSE;
					}	}
					return TRUE;
				}
				case PSN_RESET:
				{	
					int i;
					PSHNOTIFY pshn = {0};
					pshn.hdr.code = PSN_RESET;
					for (i = 0; i < accounts.getCount(); ++i) {
						if ( accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged ) {
							pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI;
							SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn);
							accounts[i]->bAccMgrUIChanged = FALSE;
					}	}
					return TRUE;
				}
			}
			break;
		}
		break;
	case WM_DESTROY:
		{
			for (int i = 0; i < accounts.getCount(); ++i) {
				accounts[i]->bAccMgrUIChanged = FALSE;
				if (accounts[i]->hwndAccMgrUI) {
					DestroyWindow(accounts[i]->hwndAccMgrUI);
					accounts[i]->hwndAccMgrUI = NULL;
		}	}	}

		Window_FreeIcon_IcoLib( hwndDlg );
		Button_FreeIcon_IcoLib( hwndDlg, IDC_ADD );
		Button_FreeIcon_IcoLib( hwndDlg, IDC_EDIT );
		Button_FreeIcon_IcoLib( hwndDlg, IDC_REMOVE );
		Button_FreeIcon_IcoLib( hwndDlg, IDC_OPTIONS );
		Button_FreeIcon_IcoLib( hwndDlg, IDC_UPGRADE );
		Utils_SaveWindowPosition( hwndDlg, NULL, "AccMgr", "");
		sttSubclassAccList(GetDlgItem(hwndDlg, IDC_ACCLIST), FALSE);
		DeleteObject(dat->hfntTitle);
		DeleteObject(dat->hfntText);
		mir_free(dat);
		hAccMgr = NULL;
		break;
	}

	return FALSE;
}
コード例 #6
0
static LRESULT CALLBACK AccListWndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TAccListData *dat = (struct TAccListData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	if ( !dat )
		return DefWindowProc(hwnd, msg, wParam, lParam);

	switch (msg) {
	case WM_LBUTTONDOWN:
		{
			POINT pt = {LOWORD(lParam), HIWORD(lParam)};
			int iItem = LOWORD(SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam));
			ListBox_GetItemRect(hwnd, iItem, &dat->rcCheck);

			dat->rcCheck.right = dat->rcCheck.left + GetSystemMetrics(SM_CXSMICON) + 4;
			dat->rcCheck.bottom = dat->rcCheck.top + GetSystemMetrics(SM_CYSMICON) + 4;
			if (PtInRect(&dat->rcCheck, pt))
				dat->iItem = iItem;
			else
				dat->iItem = -1;
		}
		break;

	case WM_LBUTTONUP:
		{
			POINT pt = {LOWORD(lParam), HIWORD(lParam)};
			if ((dat->iItem >= 0) && PtInRect(&dat->rcCheck, pt))
				PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetWindowLongPtr(hwnd, GWL_ID), LBN_MY_CHECK), (LPARAM)dat->iItem);
			dat->iItem = -1;
		}
		break;

	case WM_CHAR:
		if (wParam == ' ') {
			int iItem = ListBox_GetCurSel(hwnd);
			if (iItem >= 0)
				PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetWindowLongPtr(hwnd, GWL_ID), LBN_MY_CHECK), (LPARAM)iItem);
			return 0;
		}

		if (wParam == 10 /* enter */)
			return 0;

		break;

	case WM_GETDLGCODE:
		if (wParam == VK_RETURN)
			return DLGC_WANTMESSAGE;
		break;

	case WM_MY_RENAME:
		{
			RECT rc;
			struct TAccMgrData *parentDat = (struct TAccMgrData *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
			PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwnd, ListBox_GetCurSel(hwnd));
			if (!pa || pa->bOldProto || pa->bDynDisabled)
				return 0;

			ListBox_GetItemRect(hwnd, ListBox_GetCurSel(hwnd), &rc);
			rc.left += 2*GetSystemMetrics(SM_CXSMICON) + 4;
			rc.bottom = rc.top + max(GetSystemMetrics(SM_CXSMICON), parentDat->titleHeight) + 4 - 1;
			++rc.top; --rc.right;

			dat->hwndEdit = CreateWindow(_T("EDIT"), pa->tszAccountName, WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hwnd, NULL, hMirandaInst, NULL);
			SetWindowLongPtr(dat->hwndEdit, GWLP_USERDATA, SetWindowLongPtr(dat->hwndEdit, GWLP_WNDPROC, (LONG_PTR)sttEditSubclassProc));
			SendMessage(dat->hwndEdit, WM_SETFONT, (WPARAM)parentDat->hfntTitle, 0);
			SendMessage(dat->hwndEdit, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN|EC_USEFONTINFO, 0);
			SendMessage(dat->hwndEdit, EM_SETSEL, 0, (LPARAM) (-1));
			ShowWindow(dat->hwndEdit, SW_SHOW);
		}
		SetFocus(dat->hwndEdit);
		break;

	case WM_KEYDOWN:
		switch (wParam) {
		case VK_F2:
			PostMessage(hwnd, WM_MY_RENAME, 0, 0);
			return 0;

		case VK_INSERT:
			sttClickButton(GetParent(hwnd), IDC_ADD);
			return 0;

		case VK_DELETE:
			sttClickButton(GetParent(hwnd), IDC_REMOVE);
			return 0;

		case VK_RETURN:
			if (GetAsyncKeyState(VK_CONTROL))
				sttClickButton(GetParent(hwnd), IDC_EDIT);
			else
				sttClickButton(GetParent(hwnd), IDOK);
			return 0;
		}
		break;
	}

	return CallWindowProc(dat->oldWndProc, hwnd, msg, wParam, lParam);
}
コード例 #7
0
ファイル: outbask.c プロジェクト: cixonline/ameol
/* This function processes the WM_COMMAND message.
 */
void FASTCALL OutBasket_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify )
{
   switch( id )
      {
      case IDM_QUICKPRINT:
      case IDM_PRINT:
         CmdPrintOutbasket( hwnd );
         break;

      case IDD_HELP:
         HtmlHelp( hwnd, szHelpFile, HH_HELP_CONTEXT, idsOUTBASKET );
         break;

      case IDCANCEL:
         SendMessage( hwnd, WM_CLOSE, 0, 0L );
         break;

      case IDD_DELETE: {
         HWND hwndList;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         if( IsWindowEnabled( GetDlgItem( hwnd, id ) ) )
            if( fMessageBox( hwnd, 0, GS(IDS_STR253), MB_YESNO|MB_ICONINFORMATION ) == IDYES )
               {
               int cDeleted;
               int nCount;
               int nSel;
               int c;

               /* Set fIgnoreDeleteEvent because we could be
                * deleting lots of items, and we don't want each
                * deletion from the out-basket to be individual.
                */
               nCount = ListBox_GetCount( hwndList );
               SetWindowRedraw( hwndList, FALSE );
               cDeleted = c = 0;
               nSel = -1;
               fIgnoreDeleteEvent = TRUE;
               while( c < nCount )
                  {
                  if( ListBox_GetSel( hwndList, c ) > 0 )
                     {
                     OBINFO obinfo;
                     LPOB lpob;
         
                     lpob = (LPOB)ListBox_GetItemData( hwndList, c );
                     Amob_GetObInfo( lpob, &obinfo );
                     if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                        {
                        ListBox_DeleteString( hwndList, c );
                        nSel = c;
                        Amob_RemoveObject( lpob, FALSE );
                        ++cDeleted;
                        --nCount;
                        }
                     else
                        ++c;
                     }
                  else
                      ++c;
                  }
               if( nSel >= nCount )
                  nSel = nCount - 1;
               SetWindowRedraw( hwndList, TRUE );
               if( cDeleted )
                  {
                  InvalidateRect( hwndList, NULL, TRUE );
                  UpdateWindow( hwndList );
                  if( nSel > -1 )
                     ListBox_SetSel( hwndList, TRUE, nSel );
                  Amob_SaveOutBasket( FALSE );
                  UpdateOutBasketStatus();
                  ShowOutBasketTotal( hwndOutBasket );
                  }
               fIgnoreDeleteEvent = FALSE;
               OutBasket_OnSetFocus( hwnd, NULL );
               }
         SetFocus( hwndList );
         break;
         }

      case IDD_HOLD: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fHold;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;                        
         fHold = FALSE;
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  {
                  if( fFirst )
                     {
                     if( obinfo.obHdr.wFlags & OBF_HOLD )
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR281) );
                        fHold = FALSE;
                        }
                     else
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR282) );
                        fHold = TRUE;
                        }
                     fFirst = FALSE;
                     }
                  obinfo.obHdr.wFlags &= ~OBF_ERROR;
                  if( fHold )
                     obinfo.obHdr.wFlags |= OBF_HOLD;
                  else
                     obinfo.obHdr.wFlags &= ~OBF_HOLD;
                  Amob_SetObInfo( lpob, &obinfo );
                  ListBox_GetItemRect( hwndList, c, &rc );
                  if( !IsRectEmpty( &rc ) )
                     InvalidateRect( hwndList, &rc, FALSE );
                  }
               }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_KEEP: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fKeep;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;
         fKeep = FALSE;
         for( c = 0; c < nCount; ++c )
            {
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( fFirst )
                  {
                  if( obinfo.obHdr.wFlags & OBF_KEEP )
                     {
                     fKeep = FALSE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR319) );
                     }
                  else
                     {
                     fKeep = TRUE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR318) );
                     }
                  fFirst = FALSE;
                  }
               obinfo.obHdr.wFlags &= ~OBF_ERROR;
               if( fKeep )
                  obinfo.obHdr.wFlags |= OBF_KEEP;
               else
                  obinfo.obHdr.wFlags &= ~OBF_KEEP;
               Amob_SetObInfo( lpob, &obinfo );
               ListBox_GetItemRect( hwndList, c, &rc );
               if( !IsRectEmpty( &rc ) )
                  InvalidateRect( hwndList, &rc, FALSE );
               }
            }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_LIST:
         if( codeNotify == LBN_SELCHANGE )
            {
            UpdateOutBasketStatus();
            break;
            }
         else if( codeNotify != LBN_DBLCLK )
            break;
         if( !IsWindowEnabled( GetDlgItem( hwnd, IDOK ) ) )
            break;

      case IDOK: {
         HWND hwndList;
         int nCount;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) > 0 )
               {
               OBINFO obinfo;
               LPOB lpob;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( Amob_IsEditable( obinfo.obHdr.clsid ) && !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  Amob_Edit( lpob );
               }
         break;
         }
      }
}