الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تحويل كود من السي بلاس إلى الفيجول

بدأه booknet في 25 أكتوبر 2008 · 1 رد · 514 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

هل من الممكن تحويل الكود التالي الى فيجول بيسك، علما بأن الكود ماخوذ من "msdn" و يتعلق بتحويل عناوين الليست فيو من اليمين الى اليسار حيث أن الأكواد المتوفرة تحول النص فقط. للإطلاع على الموضوع أكثر من هذا العنوان:

http://forums.microsoft.com/MSDN/ShowPost....69&SiteID=1

public class MirroredListView : System.Windows.Forms.ListView

{

	const int WS_EX_LAYOUTRTL = 0x400000;

	const int WS_EX_NOINHERITLAYOUT = 0x100000;

	const int LVM_GETHEADER = 0x1000 + 31;

	const int GWL_EXSTYLE = -20;



	private bool _mirrored = false;



	[Description("Change to the right-to-left layout."), DefaultValue(false),

	Localizable(true), Category("Appearance"), Browsable(true)]

	public bool Mirrored

	{

		get { return this._mirrored; }

		set

		{

			if (this._mirrored != value)

			{

				this._mirrored = value;

				base.OnRightToLeftChanged(EventArgs.Empty);

			}

		}

	}



	protected override CreateParams CreateParams

	{

		get

		{

			CreateParams cp;

			cp = base.CreateParams;

			if (_mirrored)

				cp.ExStyle = cp.ExStyle | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT;

			return cp;

		}

	}



	protected override void OnHandleCreated(EventArgs e)

	{

		base.OnHandleCreated(e);



		if (this._mirrored)

		{

			IntPtr headerPtr = SendMessage(new HandleRef(this, this.Handle), (IntPtr)LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

			int headerExStyle = (int)GetWindowLong(new HandleRef(this, headerPtr), GWL_EXSTYLE) | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT;

			SetWindowLong(new HandleRef(this, headerPtr), GWL_EXSTYLE, new HandleRef(this, (IntPtr)headerExStyle));

		}

	}



	[DllImport("user32.dll", CharSet = CharSet.Auto)]

	public static extern IntPtr SendMessage(HandleRef hWnd, IntPtr msg, IntPtr wParam, IntPtr lParam);



	[DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]

	public static extern IntPtr SetWindowLongPtr32(HandleRef hWnd, int nIndex, HandleRef dwNewLong);

	[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", CharSet = CharSet.Auto)]

	public static extern IntPtr SetWindowLongPtr64(HandleRef hWnd, int nIndex, HandleRef dwNewLong);

	[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]

	public static extern IntPtr GetWindowLong32(HandleRef hWnd, int nIndex);

	[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)]

	public static extern IntPtr GetWindowLongPtr64(HandleRef hWnd, int nIndex);



	public static IntPtr GetWindowLong(HandleRef hWnd, int nIndex)

	{

		if (IntPtr.Size == 4)

		{

			return GetWindowLong32(hWnd, nIndex);

		}

		return GetWindowLongPtr64(hWnd, nIndex);

	}



	public static IntPtr SetWindowLong(HandleRef hWnd, int nIndex, HandleRef dwNewLong)

	{

		if (IntPtr.Size == 4)

		{

			return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);

		}

		return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);

	}

}

مواضيع مشابهة