<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lập trình ứng dụng - HaiNH</title>
	<atom:link href="https://hainh.dev/tag/lap-trinh-ung-dung/feed/" rel="self" type="application/rss+xml" />
	<link>https://hainh.dev</link>
	<description></description>
	<lastBuildDate>Thu, 16 Oct 2025 17:24:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://hainh.dev/wp-content/uploads/2025/10/cropped-logomyblog-32x32.png</url>
	<title>lập trình ứng dụng - HaiNH</title>
	<link>https://hainh.dev</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">249252746</site>	<item>
		<title>DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</title>
		<link>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform</link>
					<comments>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Thu, 27 Oct 2022 06:01:41 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[Winform]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=4194</guid>

					<description><![CDATA[<p>Nếu các bạn sử dụng DataGridView mà khi cuộn các dòng dữ liệu gặp tình trạng giật lag, nhấp nháy (flickering) thì hãy sử dụng giải pháp set DoubleBuffered = True, gần như tất cả control đều có thuộc tính này nhưng DataGridView thì lại bị ẩn đi. Chúng ta chỉ cẩn sử dụng đoạn...</p>
<p>The post <a href="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/">DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Nếu các bạn sử dụng DataGridView mà khi cuộn các dòng dữ liệu gặp tình trạng giật lag, nhấp nháy (flickering) thì hãy sử dụng giải pháp  set DoubleBuffered = True, gần như tất cả control đều có thuộc tính này nhưng DataGridView thì lại bị ẩn đi. Chúng ta chỉ cẩn sử dụng đoạn code dưới đây để bật thuộc tính này cho các control cần thiết.</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static void SetDoubleBuffered(Control control)
{
  // set instance non-public property with name "DoubleBuffered" to true
  typeof(Control).InvokeMember("DoubleBuffered",
      BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
      null, control, new object[] { true });
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">SetDoubleBuffered</span><span style="color: #000000">(</span><span style="color: #267F99">Control</span><span style="color: #000000"> </span><span style="color: #001080">control</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #008000">  // set instance non-public property with name &quot;DoubleBuffered&quot; to true</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #0000FF">typeof</span><span style="color: #000000">(</span><span style="color: #267F99">Control</span><span style="color: #000000">).</span><span style="color: #795E26">InvokeMember</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;DoubleBuffered&quot;</span><span style="color: #000000">,</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">SetProperty</span><span style="color: #000000"> | </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">Instance</span><span style="color: #000000"> | </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">NonPublic</span><span style="color: #000000">,</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #0000FF">null</span><span style="color: #000000">, </span><span style="color: #001080">control</span><span style="color: #000000">, </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #0000FF">object</span><span style="color: #000000">[] { </span><span style="color: #0000FF">true</span><span style="color: #000000"> });</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Khi sử dụng chỉ cần gọi vd: gdv.SetDoubleBuffered() ở form_load chẳng hạn, vd kết quả sẽ như dưới đây</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="537" height="301" data-attachment-id="4195" data-permalink="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/setdoublebuffered-true/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" data-orig-size="537,301" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SetDoubleBuffered-true" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1-300x168.gif" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" src="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" alt="" class="wp-image-4195"/></figure><p>The post <a href="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/">DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4194</post-id>	</item>
		<item>
		<title>Vấn đề khi upload hình ảnh từ điện thoại lên server bị xoay hình</title>
		<link>https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh</link>
					<comments>https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Wed, 08 May 2019 09:40:22 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[điện thoại]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[xử lý ảnh]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=2636</guid>

					<description><![CDATA[<p>Chẳng là gần đây mình có một module thực hiện việc upload hình ảnh từ mobile lên server, tuy nhiên khi hình ảnh được đẩy lên server rồi thì xem lại có hình thì bị xoay, hình thì không như dưới đây Sau khi loay hoay tìm các vấn đề không biết tại sao thì...</p>
<p>The post <a href="https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/">Vấn đề khi upload hình ảnh từ điện thoại lên server bị xoay hình</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Chẳng là gần đây mình có một module thực hiện việc upload hình ảnh từ mobile lên server, tuy nhiên khi hình ảnh được đẩy lên server rồi thì xem lại có hình thì bị xoay, hình thì không như dưới đây</p>
<p><img decoding="async" data-attachment-id="2637" data-permalink="https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/mobile-upload-hinh-anh-bi-xoay/" data-orig-file="https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay.jpg" data-orig-size="1115,662" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="mobile upload hinh anh bi xoay" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay-300x178.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay-1024x608.jpg" class="aligncenter size-full wp-image-2637" src="https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay.jpg" alt="Hình ảnh bị xoay khi upload lên server được chụp bằng điện thoại" width="1115" height="662" srcset="https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay.jpg 1115w, https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay-300x178.jpg 300w, https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay-1024x608.jpg 1024w, https://hainh.dev/wp-content/uploads/2019/05/mobile-upload-hinh-anh-bi-xoay-768x456.jpg 768w" sizes="(max-width: 1115px) 100vw, 1115px" /></p>
<p>Sau khi loay hoay tìm các vấn đề không biết tại sao thì cuối cùng mình cũng tìm ra từ khóa &#8220;mobile image exif orientation&#8221;. Và cuối cùng vấn đề của mình cũng đã được giải quyết. Lý do là vì bất kỳ hình ảnh nào được chụp từ thiết bị di động sẽ đều được lưu hướng gia tốc ( xoay ) hiện tại của điện thoại vào thẻ Exif, gọi là metadata image. Các bạn có thể tìm hiểu thêm thông tin về Exif <a href="https://en.wikipedia.org/wiki/Exif" target="_blank" rel="noopener noreferrer">tại đây</a>  . Dựa vào thông tin được lưu trong ảnh đó thì các trình xem ảnh sẽ tự động xoay hướng ảnh sao cho phù hợp. Vấn đề là khi chúng ta upload lên server và chương trình xem ảnh của chúng ta lại không quan tâm đến thông tin đó, bởi vậy ảnh bị hiển thi sai hướng. Giải quyết vấn đề này chúng ta có 2 hướng:</p>
<ol>
<li>Đọc thông tin đó và xoay lại hướng phù hợp trước khi ra view người xem.</li>
<li>Xoay lại hướng trước khi lưu vào server.</li>
</ol>
<h3><span style="color: #339966;">Giá trị được lưu vào EXIF orientation sẽ là kiểu số từ 1 đến 8:</span></h3>
<ol>
<li>0 độ, không cần điều chỉnh</li>
<li>0 độ, hình ảnh được lật về bên phải</li>
<li>180 độ, ảnh lật xuống phía dưới</li>
<li>180 độ, ảnh lật về phía phải</li>
<li>90 độ, ảnh lật về phía phải</li>
<li>90 độ, quay phải</li>
<li>270 độ, ảnh lật về phía phải</li>
<li>270 độ, quay phải</li>
</ol>
<p><img decoding="async" data-attachment-id="2638" data-permalink="https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/exif_orientations-1/" data-orig-file="https://hainh.dev/wp-content/uploads/2019/05/EXIF_Orientations-1.gif" data-orig-size="512,252" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="EXIF_Orientations (1)" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2019/05/EXIF_Orientations-1-300x148.gif" data-large-file="https://hainh.dev/wp-content/uploads/2019/05/EXIF_Orientations-1.gif" class="size-full wp-image-2638 alignnone" src="https://hainh.dev/wp-content/uploads/2019/05/EXIF_Orientations-1.gif" alt="" width="512" height="252" /></p>
<p>Về vấn để xử lý trên code C# với đối tượng Image hoặc Bitmap thì đầu tiên mình lấy giá trị Exif Orientation của nó, sau đó giựa vào giá trị từ 1 &#8211; 8 đó để biết được hướng ảnh cần xoay, cuối cùng gọi phương thức RotateFlip của ảnh đó là xong.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="rowhammer">// Biến img là biến Image hình ảnh
// 0x0112 là tag Orientation được lưu trong Exif
var _exifOrientation = img.GetPropertyItem(0x0112); // return 1 -&gt; 8
// Để chắc ăn là hình ảnh có tag đó thì ta có thể dùng lệnh kiểm tra
if (img.PropertyIdList.Contains(0x0112)){ .... }</pre>
<p>Đoạn code lấy hướng cần xoay của ảnh giựa vào giá trị Exif Orientation</p>
<pre class="EnlighterJSRAW" data-enlighter-theme="rowhammer" data-enlighter-language="csharp">private RotateFlipType GetOrientationToFlipType(int orientationValue)
{
  RotateFlipType rotateFlipType = RotateFlipType.RotateNoneFlipNone;
  switch (orientationValue)
  {
    case 1:
      rotateFlipType = RotateFlipType.RotateNoneFlipNone;
      break;
    case 2:
      rotateFlipType = RotateFlipType.RotateNoneFlipX;
      break;
    case 3:
      rotateFlipType = RotateFlipType.Rotate180FlipNone;
      break;
    case 4:
      rotateFlipType = RotateFlipType.Rotate180FlipX;
      break;
    case 5:
      rotateFlipType = RotateFlipType.Rotate90FlipX;
      break;
    case 6:
      rotateFlipType = RotateFlipType.Rotate90FlipNone;
      break;
    case 7:
      rotateFlipType = RotateFlipType.Rotate270FlipX;
      break;
    case 8:
      rotateFlipType = RotateFlipType.Rotate270FlipNone;
      break;
    default:
      rotateFlipType = RotateFlipType.RotateNoneFlipNone;
      break;
  }
  return rotateFlipType;
}</pre>
<p>Xoay lại hình ảnh theo hướng cần thiết</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="rowhammer">img.RotateFlip(GetOrientationToFlipType(_exifOrientation));</pre><p>The post <a href="https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/">Vấn đề khi upload hình ảnh từ điện thoại lên server bị xoay hình</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/van-de-khi-upload-hinh-anh-tu-dien-thoai-len-server-bi-xoay-hinh/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2636</post-id>	</item>
		<item>
		<title>C# lấy địa chỉ IP internet của máy tính</title>
		<link>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=c-lay-dia-chi-ip-internet-cua-may-tinh</link>
					<comments>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Thu, 28 Feb 2019 02:52:15 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=2523</guid>

					<description><![CDATA[<p>Lấy kết quả trả về khi chạy Command Prompt: Lấy địa chỉ IP thông qua cách sử dụng CMD:Chú ý: using System.Text.RegularExpressions; Một cách khác lấy địa chỉ IP thông qua trang http://ipinfo.io/ip</p>
<p>The post <a href="https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/">C# lấy địa chỉ IP internet của máy tính</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Lấy kết quả trả về khi chạy Command Prompt:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string RunCMD(string cmd)
{
  Process cmdProcess;
  cmdProcess = new Process();
  cmdProcess.StartInfo.FileName = "cmd.exe";
  cmdProcess.StartInfo.Arguments = "/c " + cmd;
  cmdProcess.StartInfo.RedirectStandardOutput = true;
  cmdProcess.StartInfo.UseShellExecute = false;
  cmdProcess.StartInfo.CreateNoWindow = true;
  cmdProcess.Start();
  string output = cmdProcess.StandardOutput.ReadToEnd();
  cmdProcess.WaitForExit();
  if (String.IsNullOrEmpty(output))
    return "";
  return output;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">RunCMD</span><span style="color: #000000">(</span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">cmd</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #267F99">Process</span><span style="color: #000000"> </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">Process</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">FileName</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;cmd.exe&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">Arguments</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;/c &quot;</span><span style="color: #000000"> + </span><span style="color: #001080">cmd</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">RedirectStandardOutput</span><span style="color: #000000"> = </span><span style="color: #0000FF">true</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">UseShellExecute</span><span style="color: #000000"> = </span><span style="color: #0000FF">false</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">CreateNoWindow</span><span style="color: #000000"> = </span><span style="color: #0000FF">true</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #795E26">Start</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000"> = </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StandardOutput</span><span style="color: #000000">.</span><span style="color: #795E26">ReadToEnd</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #795E26">WaitForExit</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">if</span><span style="color: #000000"> (</span><span style="color: #001080">String</span><span style="color: #000000">.</span><span style="color: #795E26">IsNullOrEmpty</span><span style="color: #000000">(</span><span style="color: #001080">output</span><span style="color: #000000">))</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Lấy địa chỉ IP thông qua cách sử dụng CMD:<br>Chú ý: using System.Text.RegularExpressions;</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string GetIP()
{
  try
  {
    string output = RunCMD("nslookup myip.opendns.com. resolver1.opendns.com");
    var ip = Regex.Matches(output, @"\b(?:(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\.){3}(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\b");
    return ip&#91;1&#93;.Value;
  }
  catch
  {
    return "127.0.0.1";
  }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">GetIP</span><span style="color: #000000">()</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">try</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000"> = </span><span style="color: #795E26">RunCMD</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;nslookup myip.opendns.com. resolver1.opendns.com&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">Regex</span><span style="color: #000000">.</span><span style="color: #795E26">Matches</span><span style="color: #000000">(</span><span style="color: #001080">output</span><span style="color: #000000">, </span><span style="color: #A31515">@&quot;\b(?:(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\.){3}(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\b&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000">&#91;</span><span style="color: #098658">1</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Value</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">catch</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;127.0.0.1&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Một cách khác lấy địa chỉ IP thông qua trang http://ipinfo.io/ip</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string getIpInternet()
{
  try
  {
    using (System.Net.WebClient client = new System.Net.WebClient())
    {
      string ip = client.DownloadString("http://ipinfo.io/ip");
      ip = ip.Replace("\r", "").Replace("\n", "");
      return ip;
    }
  }
  catch
  {
    return "127.0.0.1";
  }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">getIpInternet</span><span style="color: #000000">()</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">try</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> (</span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Net</span><span style="color: #000000">.</span><span style="color: #267F99">WebClient</span><span style="color: #000000"> </span><span style="color: #001080">client</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Net</span><span style="color: #000000">.</span><span style="color: #267F99">WebClient</span><span style="color: #000000">())</span></span>
<span class="line"><span style="color: #000000">    {</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">client</span><span style="color: #000000">.</span><span style="color: #795E26">DownloadString</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;http://ipinfo.io/ip&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">ip</span><span style="color: #000000">.</span><span style="color: #795E26">Replace</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\r</span><span style="color: #A31515">&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">).</span><span style="color: #795E26">Replace</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">catch</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;127.0.0.1&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p></p><p>The post <a href="https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/">C# lấy địa chỉ IP internet của máy tính</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2523</post-id>	</item>
		<item>
		<title>Tạo trình soạn thảo html editor trong winform</title>
		<link>https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tao-trinh-soan-thao-html-editor-trong-winform</link>
					<comments>https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Wed, 05 Dec 2018 09:10:32 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[webbrowser]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=1206</guid>

					<description><![CDATA[<p>Nếu ứng dụng của bạn cần soạn thảo và hiển thị nội dung html thì mình có giải pháp sử dụng webbrowser control để soạn thảo nội dung. Chỉ cần nhúng nó vào form và sử dụng phương thức  .Document.ExecCommand để tiến hành việc định dạng cho nó. Để có thể soạn thảo nội dung...</p>
<p>The post <a href="https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/">Tạo trình soạn thảo html editor trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Nếu ứng dụng của bạn cần soạn thảo và hiển thị nội dung html thì mình có giải pháp sử dụng webbrowser control để soạn thảo nội dung. Chỉ cần nhúng nó vào form và sử dụng phương thức  .Document.ExecCommand để tiến hành việc định dạng cho nó.</p>
<p><img loading="lazy" decoding="async" data-attachment-id="1207" data-permalink="https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/html-editor/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor.jpg" data-orig-size="970,500" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="html editor" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor-300x155.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor.jpg" class="aligncenter size-full wp-image-1207" src="https://hainh.dev/wp-content/uploads/2018/12/html-editor.jpg" alt="" width="970" height="500" srcset="https://hainh.dev/wp-content/uploads/2018/12/html-editor.jpg 970w, https://hainh.dev/wp-content/uploads/2018/12/html-editor-300x155.jpg 300w, https://hainh.dev/wp-content/uploads/2018/12/html-editor-768x396.jpg 768w" sizes="(max-width: 970px) 100vw, 970px" /></p>
<p>Để có thể soạn thảo nội dung trực tiếp trên webbrowser control thì bạn cần khai báo thuộc tính như sau:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp">txtEditor.Navigate("about:blank");
txtEditor.Document.DomDocument.DesignMode = "On";</pre>
<p>Sử dụng <span style="color: #800080;"><strong>document.execCommand(<em>command</em>, <em>showUI</em>, <em>value</em>)</strong></span> để tiến hành việc định dạng.<br />
[su_table]</p>
<table style="height: 44px; width: 132px;">
<tbody>
<tr style="height: 22px;">
<td style="height: 22px; width: 44px;"><strong>Value</strong></td>
<td style="height: 22px; width: 88px;"><strong>Mô tả</strong></td>
</tr>
<tr style="height: 22px;">
<td style="height: 22px; width: 44px;">command</td>
<td style="height: 22px; width: 88px; text-align: left;">&#8220;backColor&#8221;<br />
&#8220;bold&#8221;<br />
&#8220;createLink&#8221;<br />
&#8220;copy&#8221;<br />
&#8220;cut&#8221;<br />
&#8220;defaultParagraphSeparator&#8221;<br />
&#8220;delete&#8221;<br />
&#8220;fontName&#8221;<br />
&#8220;fontSize&#8221;<br />
&#8220;foreColor&#8221;<br />
&#8220;formatBlock&#8221;<br />
&#8220;forwardDelete&#8221;<br />
&#8220;insertHorizontalRule&#8221;<br />
&#8220;insertHTML&#8221;<br />
&#8220;insertImage&#8221;<br />
&#8220;insertLineBreak&#8221;<br />
&#8220;insertOrderedList&#8221;<br />
&#8220;insertParagraph&#8221;<br />
&#8220;insertText&#8221;<br />
&#8220;insertUnorderedList&#8221;<br />
&#8220;justifyCenter&#8221;<br />
&#8220;justifyFull&#8221;<br />
&#8220;justifyLeft&#8221;<br />
&#8220;justifyRight&#8221;<br />
&#8220;outdent&#8221;<br />
&#8220;paste&#8221;<br />
&#8220;redo&#8221;<br />
&#8220;selectAll&#8221;<br />
&#8220;strikethrough&#8221;<br />
&#8220;styleWithCss&#8221;<br />
&#8220;superscript&#8221;<br />
&#8220;undo&#8221;<br />
&#8220;unlink&#8221;<br />
&#8220;useCSS&#8221;</td>
</tr>
<tr>
<td style="width: 44px;"><em>showUI</em></td>
<td style="width: 88px; text-align: left;">True nếu hiển cần thị GUI của command, vd sử dụng chèn hình ảnh, link vv ..</td>
</tr>
<tr>
<td style="width: 44px;"><em>value</em></td>
<td style="width: 88px; text-align: left;">Giá trị của command, vd: màu sắc, liên kết vv&#8230;</td>
</tr>
</tbody>
</table>
<p>[/su_table]</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp">txtEditor.Document.ExecCommand("FontSize", False, 16) //Set khối đã chọn font size = 16px
txtEditor.Document.ExecCommand("insertImage", True, Nothing) //Show popup hiển thị chèn hình ảnh
txtEditor.Document.ExecCommand("foreColor", False, "#ff0000") //Set khối đã chọn có màu chữ thành đỏ</pre>
<p>Để lấy nội dung đoạn html đã nhập ta sử dụng thuộc tính: <span style="color: #800080;"><strong>txtEditor.DocumentText</strong></span></p>
<p>Để gắn giá trị html cho webbrowser ta sử dụng phương thức <span style="color: #800080;"><strong>txtEditor.Document.Write(&#8220;Nội dung html&#8221;)</strong></span></p>
<p>Demo form html editor mình xây dựng cho mục tạo chữ ký khi gửi email</p>
<p><img loading="lazy" decoding="async" data-attachment-id="1208" data-permalink="https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/html-editor-2/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor.gif" data-orig-size="972,497" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="html editor" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor-300x153.gif" data-large-file="https://hainh.dev/wp-content/uploads/2018/12/html-editor.gif" class="aligncenter size-full wp-image-1208" src="https://hainh.dev/wp-content/uploads/2018/12/html-editor.gif" alt="" width="972" height="497" /></p><p>The post <a href="https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/">Tạo trình soạn thảo html editor trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/tao-trinh-soan-thao-html-editor-trong-winform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1206</post-id>	</item>
		<item>
		<title>Sử dụng GeckoFx để tìm kiếm vị trí từ khóa trên google</title>
		<link>https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google</link>
					<comments>https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Tue, 06 Nov 2018 11:22:17 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[geckofx]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[SEO]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=1019</guid>

					<description><![CDATA[<p>Mình sẽ làm 1 ví dụ về việc sử dụng GeckoFx để tìm kiếm vị trí từ khóa trên google giống như ứng dụng  Phần mềm kiểm tra vị trí từ khóa trên google nhé. Về việc cài đặt thư viện thì các bạn có thể tham khảo tại đây: Sử dụng GeckoFx thay thế cho...</p>
<p>The post <a href="https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/">Sử dụng GeckoFx để tìm kiếm vị trí từ khóa trên google</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Mình sẽ làm 1 ví dụ về việc sử dụng GeckoFx để tìm kiếm vị trí từ khóa trên google giống như ứng dụng  <a href="https://hainh.dev/phan-mem-kiem-tra-vi-tri-tu-khoa-tren-google/" target="_blank" rel="noopener">Phần mềm kiểm tra vị trí từ khóa trên google</a> nhé.</p>
<p>Về việc cài đặt thư viện thì các bạn có thể tham khảo tại đây: <a href="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/" target="_blank" rel="noopener">Sử dụng GeckoFx thay thế cho webbrowser control</a></p>
<p><img loading="lazy" decoding="async" data-attachment-id="1020" data-permalink="https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/gecko-google-1/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1.jpg" data-orig-size="907,631" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="gecko google 1" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1-300x209.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1.jpg" class="aligncenter size-full wp-image-1020" src="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1.jpg" alt="" width="907" height="631" srcset="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1.jpg 907w, https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1-300x209.jpg 300w, https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1-768x534.jpg 768w" sizes="(max-width: 907px) 100vw, 907px" /></p>
<p style="text-align: center;">Chương trình có giao diện giống như hình trên</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp">public partial class Form1 : Form
{
  public Form1()
  {
    InitializeComponent();
    Gecko.Xpcom.Initialize(Application.StartupPath + "\\firefox");
  }

  private void Form1_Load(object sender, EventArgs e)
  {

  }

  private void btnTimKiem_Click(object sender, EventArgs e)
  {
    //Chuyển hướng đến trang google
    geckoWebBrowser1.Navigate("http://google.com.vn");
    //Thêm sự kiện để đợi trang google load xong mới nhập từ khóa
    geckoWebBrowser1.DocumentCompleted += new EventHandler&lt;Gecko.Events.GeckoDocumentCompletedEventArgs&gt;(geckoWebBrowser1_NhapTuKhoa);
  }

  //Sự kiện trang google load xong và nhập từ khóa
  void geckoWebBrowser1_NhapTuKhoa(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e)
  {

    //Xóa luôn sự kiện này tránh tình trạng loop
    geckoWebBrowser1.DocumentCompleted -= geckoWebBrowser1_NhapTuKhoa;

    //Tìm đối tượng text input có name là q đầu tiên
    Gecko.DOM.GeckoInputElement _input = (Gecko.DOM.GeckoInputElement)geckoWebBrowser1.Document.GetElementsByName("q")[0];
    //Gắn giá trị cho text input vừa tìm thấy với giá trị ô txtTuKhoa.text
    _input.Value = txtTuKhoa.Text;


    //Đợi trước khi bấm nút search theo số giây đã nhập trên ô txtThoiGianNgungTruocKhiSearch
    Application.DoEvents();
    System.Threading.Thread.Sleep((int)txtThoiGianNgungTruocKhiSearch.Value * 1000);

    //Submit form
    _input.Form.submit();

    //Add sự kiện chuyển trang tìm kiếm
    geckoWebBrowser1.DocumentCompleted += new EventHandler&lt;Gecko.Events.GeckoDocumentCompletedEventArgs&gt;(geckoWebBrowser1_TimViTri);

    //Reset lại vị trí và số trang
    TrangHienTai = 1;
    ViTriHienTai = 1;

  }

  private int TrangHienTai = 1;
  private int ViTriHienTai = 1;

  void geckoWebBrowser1_TimViTri(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e)
  {

    //Lấy danh sách thẻ div class g để duyệt và phân tích
    Gecko.GeckoNodeCollection arrNode = geckoWebBrowser1.Document.GetElementsByClassName("g");
    foreach (Gecko.GeckoHtmlElement item in arrNode)
    {
      //Lấy link của kết quả tìm kiếm, thẻ a nằm trong thẻ h3
      Gecko.DOM.GeckoAnchorElement _link = (Gecko.DOM.GeckoAnchorElement)item.GetElementsByTagName("h3")[0].GetElementsByTagName("a")[0];
      //So sánh với tên trang web trên kia nếu có thì đã tìm thấy vị trí
      if (_link.GetAttribute("href").ToLower().IndexOf(txtTrangWeb.Text.ToLower()) &gt;= 0)
      {

        //Cuộn đến vị trí cần xem và tạo border xung quanh nó
        item.ScrollIntoView(true);
        item.Style.CssText = "border:3px solid red;margin-top:20px;padding:15px;";
        item.InnerHtml = "&lt;h3 style='font-weight:bold;color:red;font-size:18px;'&gt;Vị trí: " + ViTriHienTai + "&lt;/h3&gt;&lt;br/&gt;" + item.InnerHtml;

        //Hiển thị vi trí kết quả và hủy sự kiện này tránh loop
        MessageBox.Show("Đã tìm thấy vị trí thứ " + ViTriHienTai + " !");
        geckoWebBrowser1.DocumentCompleted -= geckoWebBrowser1_TimViTri;
        return;
      }
      //Tăng vị trí hiện tại lên 1 nếu chưa
      ViTriHienTai += 1;
    }

    //Nếu số trang đã tới giới hạn thì thông báo không tìm thấy kết quả
    if (TrangHienTai == txtGioiHanSoTrang.Value)
    {
      MessageBox.Show("Không tìm thấy vị trí !");
      geckoWebBrowser1.DocumentCompleted -= geckoWebBrowser1_TimViTri;
      return;
    }

    //Kiểm tra có tồn tại nút Tiếp hay không
    Gecko.GeckoNodeCollection arrNodePage = geckoWebBrowser1.Document.GetElementsByClassName("fl");
    int num;
    bool isNum = Int32.TryParse(arrNodePage[arrNodePage.Length-1].TextContent, out num);
    if (isNum)
    {
      MessageBox.Show("Đã hết kết quả Search, Không tìm thấy vị trí !");
      geckoWebBrowser1.DocumentCompleted -= geckoWebBrowser1_TimViTri;
      return;
    }
    else
    {
      TrangHienTai += 1;
      ((Gecko.DOM.GeckoAnchorElement)arrNodePage[arrNodePage.Length - 1]).Click();
    }

  }
}</pre>
<p>Cùng xem kết quả nào:</p>
<p><img loading="lazy" decoding="async" data-attachment-id="1021" data-permalink="https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/gecko-google/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google.gif" data-orig-size="1905,1015" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="gecko google" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-300x160.gif" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/gecko-google-1024x546.gif" class="aligncenter size-full wp-image-1021" src="https://hainh.dev/wp-content/uploads/2018/11/gecko-google.gif" alt="" width="1905" height="1015" /></p>
<p>Link mã nguồn chương trình: <a href="https://drive.google.com/open?id=0B68_ejhDXR0wUjlPWTVTRVNXNDA">https://drive.google.com/open?id=0B68_ejhDXR0wUjlPWTVTRVNXNDA</a></p><p>The post <a href="https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/">Sử dụng GeckoFx để tìm kiếm vị trí từ khóa trên google</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/su-dung-geckofx-de-tim-kiem-vi-tri-tu-khoa-tren-google/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1019</post-id>	</item>
		<item>
		<title>Sử dụng GeckoFx thay thế cho webbrowser control</title>
		<link>https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=su-dung-geckofx-thay-the-cho-webbrowser-control</link>
					<comments>https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Sun, 04 Nov 2018 11:01:33 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[geckofx]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[web auto]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=992</guid>

					<description><![CDATA[<p>Hi all, Trong winform thì control Webbrowser sẽ sử dụng trình duyệt IE mặc định của máy tính để hiển thị, tuy nhiên nếu máy tính sử dụng chương trình của chúng ta là XP hay win 7 thì có thể nó đang sử dụng IE 7 hoặc 8, dẫn đến việc hiển thị CSS,...</p>
<p>The post <a href="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/">Sử dụng GeckoFx thay thế cho webbrowser control</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Hi all,</p>
<p>Trong winform thì control Webbrowser sẽ sử dụng trình duyệt IE mặc định của máy tính để hiển thị, tuy nhiên nếu máy tính sử dụng chương trình của chúng ta là XP hay win 7 thì có thể nó đang sử dụng IE 7 hoặc 8, dẫn đến việc hiển thị CSS, html5 không tốt hoặc bị trang web thông báo đang sử dụng trình duyệt cũ. Ngoài ra thì cái webbrowser control mặc định của nó quá cùi bắp, cách đây tầm 3 &#8211; 4 năm mình phải thực hiện một số công việc automation trên web nên đã tìm ra cách thay thế nó bằng firefox thông qua thư viện GeckoFx.</p>
<p>Đây là một thư viện mã nguồn mở, các bạn có thể tìm thêm thông tin tại đây:  <a href="https://bitbucket.org/geckofx/geckofx/wiki/Home">https://bitbucket.org/geckofx/geckofx/wiki/Home</a></p>
<p>Để cài đặt vào project các bạn có thể thông qua nuget như hình dưới đây:</p>
<p><img loading="lazy" decoding="async" data-attachment-id="993" data-permalink="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/geckofx-1/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1.png" data-orig-size="1341,875" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="GeckoFx 1" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1-300x196.png" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1-1024x668.png" class="aligncenter size-full wp-image-993" src="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1.png" alt="" width="1341" height="875" srcset="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1.png 1341w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1-300x196.png 300w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1-1024x668.png 1024w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-1-768x501.png 768w" sizes="(max-width: 1341px) 100vw, 1341px" /></p>
<p style="text-align: center;">Tìm từ khóa geckofx và install vào project.</p>
<p>Sau khi cài đặt xong các bạn vào thư mục đường dẫn project của các bạn và vào tiếp &#8220;packages\GeckoFX&#8230;..&#8221;, copy thư mục Output (Đây là thư mục chứa các thư viện xulrunner xử lý và hiển thị nội dung trang web) vào thư mục bin project của bạn và đổi tên, vd của mình là &#8220;firefox&#8221; như hình dưới đây:</p>
<p><img loading="lazy" decoding="async" data-attachment-id="994" data-permalink="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/geckofx-2/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2.jpg" data-orig-size="471,274" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="GeckoFx 2" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2-300x175.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2.jpg" class="aligncenter size-full wp-image-994" src="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2.jpg" alt="" width="471" height="274" srcset="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2.jpg 471w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-2-300x175.jpg 300w" sizes="(max-width: 471px) 100vw, 471px" /></p>
<p>Tiếp đến Add Reference file Geckofx-Winforms.dll trong thư mục &#8220;\packages\GeckoFX.1.0.5\lib&#8221; vào toolbox sau đó kéo vào form vị trí bạn cần thiết kế.</p>
<p><img loading="lazy" decoding="async" data-attachment-id="995" data-permalink="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/geckofx-3/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3.jpg" data-orig-size="1341,875" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="GeckoFx 3" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3-300x196.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3-1024x668.jpg" class="aligncenter size-full wp-image-995" src="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3.jpg" alt="" width="1341" height="875" srcset="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3.jpg 1341w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3-300x196.jpg 300w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3-1024x668.jpg 1024w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-3-768x501.jpg 768w" sizes="(max-width: 1341px) 100vw, 1341px" /></p>
<p>Giờ mình sẽ viết code để GeckoWebBrowser mở trang web tại sự kiện form load như sau:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-title="Ví dụ điều hướng trang web">public Form1()
  {
    InitializeComponent();
    //Khai báo đường dẫn thư mục xulrunner.
    Gecko.Xpcom.Initialize(Application.StartupPath + "\\firefox");
  }

  private void Form1_Load(object sender, EventArgs e)
  {
    //Chuyển hướng đến trang google.
    geckoWebBrowser1.Navigate("https://google.com.vn");
  }
}</pre>
<p><img loading="lazy" decoding="async" data-attachment-id="997" data-permalink="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/geckofx-0/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0.jpg" data-orig-size="757,490" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="GeckoFx 0" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0-300x194.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0.jpg" class="aligncenter size-full wp-image-997" src="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0.jpg" alt="" width="757" height="490" srcset="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0.jpg 757w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-0-300x194.jpg 300w" sizes="(max-width: 757px) 100vw, 757px" /></p>
<p><span style="color: #ff0000;"><strong>Chú ý:</strong></span> Nếu bạn dùng visual studio 2017 có thể sẽ xảy ra lỗi khi build liên quan đến &#8220;CodeTaskFactory&#8221; và &#8220;Microsoft.Build.Tasks.v15.0.dll&#8221;. Nguyên nhân là do thư viện này họ sử dụng visual studio 2013 để build thì phải. Giải pháp khắc phục việc này là chuyển sang dùng thư viện geckofx45 cho phiên bản .NET 4.5 trở lên, hoặc khi cài xong nuget, các bạn copy toàn bộ folder ouput và lib của nó ra ngoài, uninstall nó ra và add các thư viện Geckofx-Core.dll, Geckofx-Winforms.dll lại.</p>
<p>Trong quá trình chạy debug nếu xuất hiện lỗi thì bạn nên chuyển project platform target về x64 hoặc x86 phù hợp nhé.</p>
<p><img loading="lazy" decoding="async" data-attachment-id="996" data-permalink="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/geckofx-4/" data-orig-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4.jpg" data-orig-size="730,450" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="GeckoFx 4" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4-300x185.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4.jpg" class="aligncenter size-full wp-image-996" src="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4.jpg" alt="" width="730" height="450" srcset="https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4.jpg 730w, https://hainh.dev/wp-content/uploads/2018/11/GeckoFx-4-300x185.jpg 300w" sizes="(max-width: 730px) 100vw, 730px" /></p>
<p>Mình có làm 1 video từ hồi 2016, các bạn có thể tham khảo hình dung cho dễ nhé:</p>
<p style="text-align: center;">[su_youtube url=&#8221;https://youtu.be/_6O5zW5qa-Q&#8221;]</p>
<p>Về cơ bản thì các sự kiện, thao tác với DOM document của nó khá giống với webbrower control. Mình sẽ có bài hướng dẫn về việc thao tác với DOM để auto 1 số trang web nhé, vd: như tự động đăng nhập, điền biểu mẫu, tìm kiếm nội dung trong trang web vv &#8230;</p>
<p>Đây là 1 cái <a href="https://hainh.dev/chuong-trinh-ket-xuat-tin-nhan-facebook-messenger/">tool</a> mình làm có sử dụng geckofx để đăng nhập facebook sau đó kết xuất nội dung ra ngoài, mã nguồn của nó mình sẽ tìm lại nếu các bạn cần nhé.</p>
<p>&nbsp;</p><p>The post <a href="https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/">Sử dụng GeckoFx thay thế cho webbrowser control</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/su-dung-geckofx-thay-the-cho-webbrowser-control/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">992</post-id>	</item>
	</channel>
</rss>
