<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-36592004</id><updated>2011-11-28T08:10:16.505+08:00</updated><category term='data type'/><category term='debug'/><category term='problem solving'/><category term='audio'/><category term='mouse'/><category term='basic'/><category term='function'/><category term='property'/><category term='structure'/><category term='vfw'/><category term='event'/><category term='image'/><category term='Win32 GDI'/><category term='error'/><category term='bitmap'/><category term='TCanvas'/><title type='text'>Lee's C++ Builder Programming Notes</title><subtitle type='html'>YKLee's Programming Notes on C++ Builder</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-36592004.post-5422694372703774950</id><published>2011-11-09T21:19:00.008+08:00</published><updated>2011-11-09T21:49:09.866+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><title type='text'>動態宣告三維陣列</title><content type='html'>之前曾經介紹過如何 &lt;a target="blank" href="http://leebcb.blogspot.com/2006/09/blog-post.html"&gt;動態宣告二維陣列&lt;/a&gt;, 可是彩色影像是由 RGB 三個色彩所組成, 如果想用一個三維陣列來儲存一張彩色影像的 RGB 色彩值, 那又要該如何修改程式呢?&lt;br /&gt;&lt;br /&gt;// 標頭檔&lt;br /&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;&lt;br /&gt;// 宣告&lt;br /&gt;int ***iComponent;&lt;br /&gt;&lt;br /&gt;// 程式&lt;br /&gt;&lt;br /&gt;　try&lt;br /&gt;　　{&lt;br /&gt;　　iComponent = new int **[3];&lt;br /&gt;　　for (i=0;i&amp;lt;3;i++)&lt;br /&gt;　　　{&lt;br /&gt;　　　iComponent[i] = new int *[20];&lt;br /&gt;　　　for (j=0;j&amp;lt;20;j++)&lt;br /&gt;　　　　iComponent[i][j] = new int [40];&lt;br /&gt;　　　}&lt;br /&gt;　　}&lt;br /&gt;　catch (std::bad_alloc)&lt;br /&gt;　　{&lt;br /&gt;　　ShowMessage("Could not allocate memory...Bye");&lt;br /&gt;　　exit(-1);&lt;br /&gt;　　}&lt;br /&gt;&lt;br /&gt;// 使用測試 　&lt;br /&gt;　iComponent[2][19][39]= 10;&lt;br /&gt;　ShowMessage(AnsiString(iComponent[2][19][39]));&lt;br /&gt;&lt;br /&gt;　&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt; 注意:&lt;/span&gt; 上述程式為了程式的可讀性, 用了全型的空白"　"來控制部落格文章的內縮顯示。因此, 如果你要直接複製上述程式到 C++ Builder 執行, 請務必將全型空白"　"改成半型空白" ", 否則, 編譯時發出現以下的錯誤訊息。:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt; [C++ Error] Unit1.cpp(40): E2206 Illegal character '　' (0xa140)&lt;/span&gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-5422694372703774950?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/5422694372703774950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2011/11/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5422694372703774950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5422694372703774950'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2011/11/blog-post.html' title='動態宣告三維陣列'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-6160893056871104327</id><published>2011-09-09T22:56:00.002+08:00</published><updated>2011-09-09T22:58:02.345+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='event'/><category scheme='http://www.blogger.com/atom/ns#' term='image'/><title type='text'>Image Events</title><content type='html'>　&lt;br /&gt;　&lt;a href="http://www.csie.mcu.edu.tw/~yklee/Blog/IPC/ImageEvents.jpg"&gt;&lt;img src="http://www.csie.mcu.edu.tw/~yklee/Blog/IPC/ImageEvents.jpg" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-6160893056871104327?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/6160893056871104327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2011/09/image-events.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6160893056871104327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6160893056871104327'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2011/09/image-events.html' title='Image Events'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-3583219194199867903</id><published>2011-09-09T22:50:00.003+08:00</published><updated>2011-09-23T10:04:46.858+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='property'/><title type='text'>Image Properties</title><content type='html'>　&lt;br /&gt;　&lt;a href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/IPC/ImageProperties.jpg"&gt;&lt;img src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/IPC/ImageProperties.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1. AutoSize&lt;br /&gt;&lt;br /&gt;   true or false: 是否讓影像元件的寬、高隨著 Load 進來的影像大小自動調整。&lt;br /&gt;&lt;br /&gt;2. Stretch&lt;br /&gt;&lt;br /&gt;true or false: 是否讓 Load 進來的影像大小自動隨著影像元件的寬、高顯示出來。&lt;br /&gt;&lt;br /&gt;3.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-3583219194199867903?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/3583219194199867903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2011/09/image-properties.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/3583219194199867903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/3583219194199867903'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2011/09/image-properties.html' title='Image Properties'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-59463098170097611</id><published>2011-09-07T11:20:00.002+08:00</published><updated>2011-09-07T11:58:36.530+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='TCanvas'/><title type='text'>TCanvas::FillRect Method</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 17px; background-color: rgb(255, 255, 255); "&gt;Image1-&amp;gt;Canvas-&amp;gt;Brush-&amp;gt;Color =(TColor)RGB(130,67,33);&lt;br /&gt;&lt;span&gt;Image1-&amp;gt;Canvas-&amp;gt;FillRect(Rect(&lt;/span&gt;&lt;wbr&gt;&lt;span class="word_break" style="display: block; float: left; margin-left: -10px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/span&gt;50,100,80,200));&lt;br /&gt;&lt;br /&gt;這兩行指令就是&lt;br /&gt;1. 設定Image1畫布上筆刷的顏色為 (130,67,33)&lt;br /&gt;2. 把矩形 Rect(50,100,80,200) 用筆刷填滿&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-59463098170097611?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/59463098170097611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2011/09/tcanvas-fillrect-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/59463098170097611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/59463098170097611'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2011/09/tcanvas-fillrect-method.html' title='TCanvas::FillRect Method'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-871345925053742661</id><published>2009-12-01T22:41:00.019+08:00</published><updated>2011-03-01T09:42:47.888+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debug'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='problem solving'/><title type='text'>Stream Read Error</title><content type='html'>這兩個星期, 由於撰寫 &lt;a target="blank" href="http://ipc-yklee.blogspot.com/"&gt;IPC&lt;/a&gt; 與 &lt;a target="blank" href="http://dmc-yklee.blogspot.com/"&gt;DMC&lt;/a&gt; 的 &lt;a target="blank" href="http://ipc-yklee.blogspot.com/search/label/sample%20program"&gt;範例程式&lt;/a&gt; 的緣故, 遭遇一個以前未曾發生過的問題: 我用 Photoshop CS 所儲存的 bmp 檔案, 用 C++ Builder 6 開啟, 會發生 Stream read error, 如下圖:&lt;br /&gt;&lt;br /&gt;&lt;a target="blank" href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/CBuilder/DebuggerExceptionNotification-StreamReadError.jpg"&gt;&lt;img src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/CBuilder/DebuggerExceptionNotification-StreamReadError.jpg" border="0" width="400" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;我的第一個反應也是問 &lt;a target="blank" href="http://www.google.com.tw/search?hl=zh-TW&amp;amp;rlz=1B2GGFB_enTW241&amp;amp;q=Stream+read+error&amp;amp;btnG=%E6%90%9C%E5%B0%8B&amp;amp;meta=lr%3Dlang_zh-TW&amp;amp;aq=f&amp;amp;oq="&gt;Google&lt;/a&gt; 大神, 順利找到了一些相關討論[&lt;a target="blank" href="http://www.programmer-club.com.tw/ShowSameTitleN/cb/6857.html"&gt;1&lt;/a&gt;, &lt;a target="blank" href="http://delphi.ktop.com.tw/board.php?cid=168&amp;amp;fid=1499&amp;amp;tid=91147"&gt;2&lt;/a&gt;, &lt;a target="blank" href="http://delphi.ktop.com.tw/board.php?cid=168&amp;amp;fid=921&amp;amp;tid=59958"&gt;3&lt;/a&gt;], 但始終沒有人可以指出確切的問題點。&lt;br /&gt;&lt;br /&gt;昨天晚上, 由於 &lt;a target="blank" href="http://ipc-yklee.blogspot.com/2009/12/contrast-stretching.html"&gt;對比度擴展(Contrast Stretching)範例程式&lt;/a&gt; 的實驗需要造一張低對比度的影像, 而我的電腦又只有灌 Photoshop CS, 因此逼得我一定要面對這個問題。&lt;br /&gt;&lt;br /&gt;&lt;a target="blank" href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/IPC/CH3/CarnivoreLowContrast.bmp"&gt;&lt;img src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/IPC/CH3/CarnivoreLowContrast.bmp" border="0" width="256" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;由於錯誤訊息是 Stream read error, 因此, 我直接排除是程式撰寫上的問題, 直接從有問題的 bmp 影像開始研究。為了比較, 我將可以順利用 C++ Builder 6 開啟的檔案 Carnivore.bmp 用 Photoshop CS 另存新檔 CarnivorePSCS.bmp, 然後再分別用 &lt;a target="blank" href="http://www.pspad.com/en/"&gt;PSPad&lt;/a&gt; 用 Hex editor 開啟, 比較兩個檔案的異同。&lt;br /&gt;&lt;br /&gt;&lt;a target="blank" href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/CBuilder/BCB6-PS-bmp-StreamReadError.txt"&gt;BCB6-PS-bmp-StreamReadError.txt&lt;/a&gt; 在這個檔案中, 我列出了兩個 &lt;a target="blank" href="http://zh.wikipedia.org/zh-tw/BMP"&gt;bmp 檔頭資料&lt;/a&gt;以供比對, 我發現兩個檔頭資料中, 只有第 34-37 位元組的影像原始大小有差異, 可以順利開啟的 Carnivore.bmp 並沒有儲存影像大小到檔頭之中, 而 CarnivorePSCS.bmp 則是存放了 0200 0C00 的資料, 我當下用 PSPas 將第 34-37 位元組修改成 0000 0000, 果然 CarnivorePSCS.bmp 就可以用 C++ Builder 6 順利開啟了。&lt;br /&gt;&lt;br /&gt;接下來, 我當然先去完成  &lt;a target="blank" href="http://ipc-yklee.blogspot.com/2009/12/contrast-stretching.html"&gt;對比度擴展(Contrast Stretching)範例程式&lt;/a&gt; 的實驗, 把低對比度的彩色影像自動處理成高對比度的影像, 並完成 &lt;a href="http://ipc-yklee.blogspot.com/search/label/sample%20program"&gt;部落格範例程式的文章&lt;/a&gt;。&lt;br /&gt;&lt;br /&gt;今天, 在往學校的路上, 我一直在思考為何 Photoshop CS 會多此一舉把影像大小的值放進去, 而且還造成  C++ Builder 6 無法讀取? 難道 Photoshop CS 會把影像大小 Width * Height * BitCount / 8 這麼簡單的數學計算錯誤嗎?&lt;br /&gt;&lt;br /&gt;晚上回到家後, 把  0200 0C00 換算, 得到 786434, 然而影像大小&lt;br /&gt;&lt;br /&gt;　Width * Height * BitCount / 8&lt;br /&gt;= 512 * 512 * 24 / 8&lt;br /&gt;= 786432&lt;br /&gt;&lt;br /&gt;果然就如同自己所推測的一樣, 影像大小差了 2 個 bytes。&lt;br /&gt;&lt;br /&gt;我最後的一個實驗是將 CarnivorePSCS.bmp 的第 34-37 位元組 (影像大小) 修改成 0000 0C00, 果然 也可以用 C++ Builder 6 順利開啟。&lt;br /&gt;&lt;br /&gt;真相大白了 !&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-871345925053742661?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/871345925053742661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/12/stream-read-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/871345925053742661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/871345925053742661'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/12/stream-read-error.html' title='Stream Read Error'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-5707250281685651731</id><published>2009-11-25T23:08:00.002+08:00</published><updated>2009-11-25T23:16:17.575+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='function'/><title type='text'>CreatePalette function</title><content type='html'>The CreatePalette function creates a logical color palette.&lt;br /&gt;&lt;br /&gt;HPALETTE CreatePalette(&lt;br /&gt;　&lt;span style="font-weight: bold;"&gt;CONST&lt;/span&gt; LOGPALETTE *lplgpl  　　// pointer to logical color palette&lt;br /&gt;　); &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;lplgpl&lt;/span&gt;　Points to a &lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/logpalette-structure.html"&gt;LOGPALETTE structure&lt;/a&gt; that contains information about the colors in the logical palette.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the function succeeds, the return value is a &lt;span style="color: rgb(255, 0, 0);"&gt;handle&lt;/span&gt; that identifies a logical palette.&lt;br /&gt;&lt;br /&gt;If the function fails, the return value is &lt;span style="color: rgb(255, 0, 0);"&gt;NULL&lt;/span&gt;. To get extended error information, call GetLastError.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An application can determine whether a device supports palette operations by calling the GetDeviceCaps function and specifying the RASTERCAPS constant. Once an application creates a logical palette, it can select that palette into a device context by calling the SelectPalette function. A palette selected into a device context can be realized by calling the RealizePalette function.&lt;br /&gt;When you no longer need the palette, call the DeleteObject function to delete it.&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-5707250281685651731?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/5707250281685651731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/11/createpalette-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5707250281685651731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5707250281685651731'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/11/createpalette-function.html' title='CreatePalette function'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-5953957684692618691</id><published>2009-11-25T22:50:00.003+08:00</published><updated>2009-11-25T22:56:04.210+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='structure'/><title type='text'>PALETTEENTRY structure</title><content type='html'>The PALETTEENTRY structure specifies the color and usage of an entry in a logical color palette. A logical palette is defined by a &lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/logpalette-structure.html"&gt;LOGPALETTE structure&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;typedef struct&lt;/span&gt; tagPALETTEENTRY { // pe &lt;br /&gt;　&lt;span style="font-weight: bold;"&gt;BYTE&lt;/span&gt; peRed;&lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;　BYTE&lt;/span&gt; peGreen;&lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;　BYTE&lt;/span&gt; peBlue;&lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;　BYTE&lt;/span&gt; peFlags;&lt;br /&gt;} PALETTEENTRY;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Members&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;　peRed&lt;/span&gt;　Specifies a red intensity value for the palette entry.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;　peGreen&lt;/span&gt;　Specifies a green intensity value for the palette entry.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;　peBlue&lt;/span&gt;　Specifies a blue intensity value for the palette entry.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;　peFlags&lt;/span&gt;　Specifies how the palette entry is to be used.&lt;br /&gt;&lt;br /&gt;The &lt;span style="color: rgb(51, 51, 255);"&gt;peFlags&lt;/span&gt; member may be set to &lt;span style="color: rgb(255, 0, 0);"&gt;NULL&lt;/span&gt; or one of the following values:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Value Meaning&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;PC_EXPLICIT&lt;/span&gt; Specifies that the low-order word of the logical palette entry designates a hardware palette index. This flag allows the application to show the contents of the display device palette.&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;PC_NOCOLLAPSE&lt;/span&gt; Specifies that the color be placed in an unused entry in the system palette instead of being matched to an existing color in the system palette. If there are no unused entries in the system palette, the color is matched normally. Once this color is in the system palette, colors in other logical palettes can be matched to this color.&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;PC_RESERVED&lt;/span&gt; Specifies that the logical palette entry be used for palette animation. This flag prevents other windows from matching colors to the palette entry since the color frequently changes. If an unused system-palette entry is available, the color is placed in that entry. Otherwise, the color is not available for animation.&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-5953957684692618691?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/5953957684692618691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/11/paletteentry-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5953957684692618691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5953957684692618691'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/11/paletteentry-structure.html' title='PALETTEENTRY structure'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-1904407947437906496</id><published>2009-11-25T22:30:00.003+08:00</published><updated>2009-11-25T22:58:22.839+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='structure'/><title type='text'>LOGPALETTE structure</title><content type='html'>The LOGPALETTE structure defines a logical color palette.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;typedef struct&lt;/span&gt; tagLOGPALETTE { 　// lgpl&lt;br /&gt;  　&lt;span style="font-weight: bold;"&gt;WORD&lt;/span&gt;         palVersion;&lt;br /&gt;  　&lt;span style="font-weight: bold;"&gt;WORD&lt;/span&gt;         palNumEntries;&lt;br /&gt;  　&lt;span style="font-weight: bold;"&gt;PALETTEENTRY&lt;/span&gt; palPalEntry[1];&lt;br /&gt;} LOGPALETTE;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Members&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;palVersion&lt;/span&gt;　Specifies the Windows version number for the structure (currently 0x300).&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;palNumEntries&lt;/span&gt;　Specifies the number of entries in the logical color palette.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;palPalEntry&lt;/span&gt;　Specifies an array of &lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/paletteentry-structure.html"&gt;PALETTEENTRY structures&lt;/a&gt; that define the color and usage of each entry in the logical palette.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;　&lt;br /&gt;The colors in the palette-entry table should appear in order of importance because entries earlier in the logical palette are most likely to be placed in the system palette.&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-1904407947437906496?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/1904407947437906496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/11/logpalette-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1904407947437906496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1904407947437906496'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/11/logpalette-structure.html' title='LOGPALETTE structure'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-6521674311324653009</id><published>2009-11-18T00:32:00.005+08:00</published><updated>2011-09-07T11:23:23.499+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><category scheme='http://www.blogger.com/atom/ns#' term='TCanvas'/><title type='text'>TBrush</title><content type='html'>&lt;blockquote&gt;Determines the color and pattern for filling graphical shapes and backgrounds.&lt;br /&gt;&lt;br /&gt;__property TBrush* Brush = {read=FBrush, write=SetBrush};&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Description&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Set the Brush property to specify the color and pattern to use when drawing the background or filling in graphical shapes. The value of Brush is a TBrush object. Set the properties of the TBrush object to specify the color and pattern or bitmap to use when filling in spaces on the canvas.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Note:&lt;/span&gt; Setting the Brush property assigns the specified TBrush object, rather than replacing the current TBrush object.&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Note: &lt;/span&gt;Brush must have a Style of bsSolid before you can paint.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Example: &lt;br /&gt;Image1-&gt;Canvas-&gt;Brush-&gt;Color =(TColor)RGB(130,67,33);&lt;br /&gt;設定 Image1 畫布上筆刷的顏色為 (130,67,33)。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-6521674311324653009?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/6521674311324653009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/11/tbrush.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6521674311324653009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6521674311324653009'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/11/tbrush.html' title='TBrush'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-739191144092475277</id><published>2009-11-17T23:53:00.002+08:00</published><updated>2009-11-18T00:36:26.513+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='property'/><category scheme='http://www.blogger.com/atom/ns#' term='TCanvas'/><title type='text'>TCanvas::Pixels</title><content type='html'>&lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/tcanvaspixels.html"&gt;TCanvas&lt;/a&gt; 有一個 property , 一般表示成 TCanvas::Pixels, 是我們常會用到的, Pixels 這個 property 可以讀出, 也可以寫入某個特定位置的色彩值, 因此這個 property 的類別為 &lt;a href="http://leebcb.blogspot.com/2006/10/tcolor-type.html" target="blank"&gt;TColor&lt;/a&gt;。在 BCB Help 中的說明如下:&lt;br /&gt;&lt;blockquote&gt;TCanvas::Pixels&lt;br /&gt;Specifies the color of the pixels within the current ClipRect.&lt;br /&gt;&lt;br /&gt;__property &lt;a href="http://leebcb.blogspot.com/2006/10/tcolor-type.html" target="blank"&gt;TColor&lt;/a&gt; Pixels[int X][int Y] = {read=GetPixel, write=SetPixel};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;Read Pixels to learn the color on the drawing surface at a specific pixel position within the current clipping region. If the position is outside the clipping rectangle, reading the value of Pixels returns -1.&lt;br /&gt;&lt;br /&gt;Write Pixels to change the color of individual pixels on the drawing surface. Use Pixels for detailed effects on an image. Pixels may also be used to determine the color that should be used for the FillRect method.&lt;br /&gt;&lt;br /&gt;Not every device context supports the Pixels property. Reading the Pixels property for such a device context will return a value of -1. Setting the Pixels property for such a device context does nothing. &lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-739191144092475277?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/739191144092475277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/11/tcanvaspixels.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/739191144092475277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/739191144092475277'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/11/tcanvaspixels.html' title='TCanvas::Pixels'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-1977909362498573814</id><published>2009-10-22T14:36:00.003+08:00</published><updated>2009-11-14T12:17:24.583+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><title type='text'>如何將 AnsiString 轉成 char 資料型態?</title><content type='html'>.c_str(); // for 舊版 C++ Builder&lt;br /&gt;.t_str(); // for 新版 C++ Builder 2009&lt;br /&gt;&lt;br /&gt;Example: &lt;br /&gt;fopen(OpenDialog1-&gt;FileName.t_str(),"r");&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-1977909362498573814?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/1977909362498573814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/10/ansistring-char.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1977909362498573814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1977909362498573814'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/10/ansistring-char.html' title='如何將 AnsiString 轉成 char 資料型態?'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-2486817884998500472</id><published>2009-10-15T01:21:00.002+08:00</published><updated>2009-11-25T20:35:37.959+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><title type='text'>TBitmap::PixelFormat</title><content type='html'>Indicates the bit format of the bitmap image, specifying how the image is displayed and how the pixels of the bitmap image are stored in memory.&lt;br /&gt;&lt;br /&gt;enum TPixelFormat {pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom};&lt;br /&gt;__property TPixelFormat PixelFormat = {read=GetPixelFormat, write=SetPixelFormat, nodefault};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use PixelFormat to change a TBitmap's internal image to a particular memory format and color depth, or to find out what memory format and color depth a TBitmap is using.&lt;br /&gt;&lt;br /&gt;For example, PixelFormat can be used to set the pixel format of the bitmap image to 8-bit for video drivers that cannot display the native format of a bitmap image.&lt;br /&gt;&lt;br /&gt;Changing the pixel format is most commonly used with &lt;a target="blank" href="http://leebcb.blogspot.com/2009/03/tbitmapscanline.html"&gt;ScanLine&lt;/a&gt;, because your code must decode the pixel data accessed by ScanLine. Image-editing tools usually use one pixel for all internal image operations and copy the results to the screen (in whatever format) as the last step.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-2486817884998500472?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/2486817884998500472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/10/tbitmappixelformat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/2486817884998500472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/2486817884998500472'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/10/tbitmappixelformat.html' title='TBitmap::PixelFormat'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-8666870835688095966</id><published>2009-09-25T11:56:00.000+08:00</published><updated>2009-09-25T11:57:52.128+08:00</updated><title type='text'>如何取得影像某個像素的色彩值: GetRValue();</title><content type='html'>ucMR[i][j] =GetRValue(Image1-&gt;Canvas-&gt;Pixels[j][i]);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-8666870835688095966?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/8666870835688095966/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/09/getrvalue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/8666870835688095966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/8666870835688095966'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/09/getrvalue.html' title='如何取得影像某個像素的色彩值: GetRValue();'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-5849373226784440725</id><published>2009-03-24T21:44:00.003+08:00</published><updated>2009-11-14T17:01:07.481+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>使用者自定之副程式如何存取物件之相關資料</title><content type='html'>在 C++ Builder 中撰寫副程式, 如果要存取物件中的相關資料, 必須從 Form1 開始描述起, 不可以直接寫物件之名稱, 否則會有 Undefined symbol 的錯誤訊息。&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;Form1-&gt;StatusBar1-&gt;Panels-&gt;Items[0]-&gt;Text = AnsiString(iFrameCount);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-5849373226784440725?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/5849373226784440725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/03/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5849373226784440725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/5849373226784440725'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/03/blog-post.html' title='使用者自定之副程式如何存取物件之相關資料'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-4506494146036154997</id><published>2009-03-23T23:15:00.005+08:00</published><updated>2010-10-09T12:56:36.258+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='property'/><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><title type='text'>TBitmap::ScanLine</title><content type='html'>Provides indexed access to each line of pixels.&lt;br /&gt;&lt;br /&gt;__property void * ScanLine[int Row] = {read=GetScanline};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ScanLine is used only with DIBs (Device Independent Bitmaps) for image editing tools that do low-level pixel work.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;基本上, ScanLine 是 TBitmap 元件中的一個 Property, 存放著 Bitmap 某一橫列的色彩值在記憶體中存放的起始指標, 有了這個指標, 我們就可以直接在記憶體中直接存取, 修改影像內容。&lt;br /&gt;　&lt;br /&gt;更新記憶體後的影像元件的外觀顯示, 有可能和記憶體中不相符, 我們可以用 Refresh() 這個 method 來將影像的外觀重新顯示。&lt;br /&gt;&lt;br /&gt;　　Image1-&gt;Refresh();&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-4506494146036154997?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/4506494146036154997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/03/tbitmapscanline.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4506494146036154997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4506494146036154997'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/03/tbitmapscanline.html' title='TBitmap::ScanLine'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-8813012055339840038</id><published>2009-03-10T16:39:00.002+08:00</published><updated>2010-03-22T09:21:05.196+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 GDI'/><title type='text'>Win32 GDI: 取得裝置內容代碼 GetDC</title><content type='html'>圖形裝置介面 (GDI: Graphics Device Interface) 是 Windows 的子系統, 負責在螢幕或印表機上顯示圖形。Windows GDI 由幾百個函式呼叫組成, 也定義了相關的資料形態, 結構與巨集。&lt;br /&gt;&lt;br /&gt;當我們想要在一個圖形輸出設備上繪圖, 或是做一些基本操作時, 首先我們必須要先獲得一個裝置內容(device context)的代碼。&lt;br /&gt;&lt;br /&gt;取得顯示裝置代碼(display device context)的方式之一就是使用 GetDC 指令。&lt;br /&gt;&lt;br /&gt;當 Windows 將顯示裝置代碼傳回給程式的同時, 也給了我們使用該顯示裝置的許可權限, 之後程式便是透過這個代碼告訴 Windows 要在這個裝置上進行繪圖, 因此, 這個代碼也將成為 GDI 函式中的一個輸入參數。&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The GetDC function retrieves a handle of a display device context (DC) for the client area of the specified window. The display device context can be used in subsequent GDI functions to draw in the client area of the window.&lt;br /&gt;&lt;br /&gt;This function retrieves a common, class, or private device context depending on the class style specified for the specified window. For common device contexts, GetDC assigns default attributes to the device context each time it is retrieved. For class and private device contexts, GetDC leaves the previously assigned attributes unchanged.&lt;br /&gt;&lt;br /&gt;HDC GetDC(&lt;br /&gt;HWND hWnd                   // handle of window &lt;br /&gt;  ); &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;hWnd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Identifies the window whose device context is to be retrieved.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the function succeeds, the return value identifies the device context for the given window's client area. If the function fails, the return value is NULL.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After painting with a common device context, the ReleaseDC function must be called to release the device context. Class and private device contexts do not have to be released. The number of device contexts is limited only by available memory.&lt;/blockquote&gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-8813012055339840038?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/8813012055339840038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2009/03/win32-gdi-getdc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/8813012055339840038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/8813012055339840038'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2009/03/win32-gdi-getdc.html' title='Win32 GDI: 取得裝置內容代碼 GetDC'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-4382079194570305954</id><published>2008-12-25T02:31:00.004+08:00</published><updated>2008-12-25T13:57:47.350+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mouse'/><title type='text'>Drag-and-Drop</title><content type='html'>1. 要被拖曳的影像之屬性設定:&lt;br /&gt;&lt;br /&gt;DragKind 設定成 dkDrag&lt;br /&gt;DragMode 設定成 dmAutomatic&lt;br /&gt;&lt;br /&gt;2. 在 Form 的兩個事件 onDragDrop 與 onDragOver 上的撰寫程式:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;onDragDrop 事件:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;TImage *buf = (TImage *) Source;&lt;br /&gt;&lt;br /&gt;buf-&gt;Left = X;&lt;br /&gt;buf-&gt;Top = Y;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;onDragOver 事件:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Accept = true;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-4382079194570305954?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/4382079194570305954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2008/12/drag-and-drop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4382079194570305954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4382079194570305954'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2008/12/drag-and-drop.html' title='Drag-and-Drop'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-769157322811210908</id><published>2008-05-29T23:13:00.006+08:00</published><updated>2008-05-30T03:16:47.476+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 視訊資料表頭結構</title><content type='html'>在 vfw.h 中第 3148 行起, 定義了視訊資料表頭結構(video data block header), 如下:&lt;br /&gt;&lt;br /&gt;/* video data block header */&lt;br /&gt;typedef struct &lt;span style="color: rgb(51, 51, 255);"&gt;videohdr_tag&lt;/span&gt; {&lt;br /&gt;LPBYTE      &lt;span style="color: rgb(0, 153, 0);"&gt;lpData&lt;/span&gt;;                  /* pointer to locked data buffer */&lt;br /&gt;DWORD       &lt;span style="color: rgb(0, 153, 0);"&gt;dwBufferLength&lt;/span&gt;;          /* Length of data buffer */&lt;br /&gt;DWORD       &lt;span style="color: rgb(0, 153, 0);"&gt;dwBytesUsed&lt;/span&gt;;             /* Bytes actually used */&lt;br /&gt;DWORD       &lt;span style="color: rgb(0, 153, 0);"&gt;dwTimeCaptured;&lt;/span&gt;          /* Milliseconds from start of stream */&lt;br /&gt;DWORD_PTR   &lt;span style="color: rgb(0, 153, 0);"&gt;dwUser&lt;/span&gt;;                  /* for client's use */&lt;br /&gt;DWORD       &lt;span style="color: rgb(0, 153, 0);"&gt;dwFlags&lt;/span&gt;;                 /* assorted flags (see defines) */&lt;br /&gt;DWORD_PTR   &lt;span style="color: rgb(0, 153, 0);"&gt;dwReserved[4]&lt;/span&gt;;           /* reserved for driver */&lt;br /&gt;} &lt;span style="color: rgb(51, 51, 255);"&gt;VIDEOHDR, NEAR *PVIDEOHDR, FAR *LPVIDEOHDR&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;使用 typedef 的宣告方式, 將 videohdr_tag 這個新的資料形態取了三個別名, 分別是 VIDEOHDR, NEAR *PVIDEOHDR 與 FAR *LPVIDEOHDR。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;lpData&lt;/span&gt; 紀錄視訊資料緩衝區的位址, 透過此資料成員便可以直接存取視訊影像資料。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;dwBufferLength&lt;/span&gt; 紀錄 lpData 所指向的視訊資料緩衝區的容量大小。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;dwByteUsed&lt;/span&gt; 紀錄視訊資料緩衝區已經被使用了多少位元組。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;dwTimeCaptured&lt;/span&gt; 紀錄影音串流擷取已使用的時間(毫秒 ms)。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;dwUser&lt;/span&gt; 紀錄視訊擷取視窗關聯的使用者自訂資料。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;dwFlags&lt;/span&gt; 紀錄視訊資料表頭旗標, 其定義就是在 vfw.h 中, 第 3158 行後所定義的, 如下:&lt;br /&gt;&lt;br /&gt;/* dwFlags field of VIDEOHDR */&lt;br /&gt;#define VHDR_DONE       0x00000001  /* Done bit */&lt;br /&gt;#define VHDR_PREPARED     0x00000002 &lt;br /&gt;/* Set if this header has been prepared */&lt;br /&gt;#define VHDR_INQUEUE      0x00000004  /* Reserved for driver */&lt;br /&gt;#define VHDR_KEYFRAME     0x00000008  /* Key Frame */&lt;br /&gt;#define VHDR_VALID      0x0000000F  /* valid flags */  /* ;Internal */&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-769157322811210908?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/769157322811210908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2008/05/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/769157322811210908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/769157322811210908'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2008/05/blog-post.html' title='VFW: 視訊資料表頭結構'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-1441608182106135204</id><published>2007-12-20T14:59:00.000+08:00</published><updated>2007-12-20T15:02:08.062+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>如何取得系統時間</title><content type='html'>#include time.h&lt;br /&gt;&lt;br /&gt;A = clock();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-1441608182106135204?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/1441608182106135204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2007/12/blog-post_20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1441608182106135204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/1441608182106135204'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2007/12/blog-post_20.html' title='如何取得系統時間'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-2917044977905443354</id><published>2007-12-20T14:18:00.007+08:00</published><updated>2009-11-14T16:59:39.525+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><title type='text'>如何動態新增一個影像元件?</title><content type='html'>TImage *imNew;&lt;br /&gt;&lt;br /&gt;imNew = new TImage(this);&lt;br /&gt;imNew-&gt;Parent = RScrollBox;&lt;br /&gt;imNew-&gt;Left = 2;&lt;br /&gt;imNew-&gt;Top = 2;&lt;br /&gt;imNew-&gt;Height = IH;&lt;br /&gt;imNew-&gt;Width = IW;&lt;br /&gt;&lt;br /&gt;上述這段程式, 如果執行時出現下面的&lt;span style="color: rgb(255, 0, 0);"&gt;錯誤訊息&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;[Linker Error] Unresolved external '__fastcall Extctrls::TImage::TImage(Classes::TComponent *)' referenced from...&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;解決辦法:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;'Project | Options | (tab) Packages | (Groupbox) Runtime Packages',&lt;br /&gt;&lt;br /&gt;將 Build with Runtime Packages 的勾勾去掉...&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-2917044977905443354?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/2917044977905443354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2007/12/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/2917044977905443354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/2917044977905443354'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2007/12/blog-post.html' title='如何動態新增一個影像元件?'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-6826157080920678559</id><published>2007-11-21T18:30:00.000+08:00</published><updated>2007-12-20T13:41:15.484+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debug'/><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>% operator</title><content type='html'>我們知道 % operator 就是除法取其餘數的運算子。&lt;br /&gt;例如:&lt;br /&gt;&lt;br /&gt;Q = A % 2;&lt;br /&gt;&lt;br /&gt;一般來說, Q 值不是 0 就是 1。&lt;br /&gt;&lt;br /&gt;不過, 我一直沒有想過如果被除數 A 是負數的時候, 會發生什麼情形? 今天下午我在寫程式時, 就發生了這樣的例子, 害我 debug 很久, 把程式一堆變數的值一一顯示出來看, 才發現這個有趣的問題。原來, 如果被除數 A 是負數的時候, 餘數也會是負數的!&lt;br /&gt;例如:&lt;br /&gt;　&lt;br /&gt;-3 % 2 = -1&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-6826157080920678559?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/6826157080920678559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2007/11/operator.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6826157080920678559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6826157080920678559'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2007/11/operator.html' title='% operator'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-6190686000757773857</id><published>2007-10-09T01:34:00.000+08:00</published><updated>2007-10-09T01:41:19.100+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='audio'/><title type='text'>Audio: 如何播放一段 WAV 檔</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;&lt;br /&gt;PlaySound("camera.wav",NULL,SND_APPLICATION);&lt;br /&gt;&lt;br /&gt;The PlaySound function plays a sound specified by the given filename, resource, or system event.&lt;br /&gt;(A system event may be associated with a sound in the registry or in the WIN.INI file.)&lt;br /&gt;&lt;br /&gt;BOOL PlaySound(&lt;br /&gt;    LPCSTR pszSound,   &lt;br /&gt;    HMODULE hmod,   &lt;br /&gt;    DWORD fdwSound   &lt;br /&gt;   );   &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;pszSound    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A string that specifies the sound to play. If this parameter is NULL, any currently playing waveform sound is stopped. To stop a non-waveform sound, specify SND_PURGE in the fdwSound parameter.&lt;br /&gt;&lt;br /&gt;Three flags in fdwSound (SND_ALIAS, SND_FILENAME, and SND_RESOURCE) determine whether the name is interpreted as an alias for a system event, a filename, or a resource identifier. If none of these flags are specified, PlaySound searches the registry or the WIN.INI file for an association with the specified sound name. If an association is found, the sound event is played. If no association is found in the registry, the name is interpreted as a filename.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;hmod&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Handle of the executable file that contains the resource to be loaded. This parameter must be NULL unless SND_RESOURCE is specified in&lt;br /&gt;fdwSound.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;fdwSound&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flags for playing the sound. The following values are defined:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_APPLICATION&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The sound is played using an application-specific association.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_ALIAS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_ALIAS_ID&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The pszSound parameter is a predefined sound identifier.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_ASYNC&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_FILENAME&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The pszSound parameter is a filename.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_LOOP&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_MEMORY&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A sound event's file is loaded in RAM. The parameter specified by pszSound must point to an image of a sound in memory.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_NODEFAULT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_NOSTOP&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.&lt;br /&gt;If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_NOWAIT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the driver is busy, return immediately without playing the sound.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_PURGE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sounds are to be stopped for the calling task. If pszSound is not NULL, all instances of the specified sound are stopped. If pszSound is NULL, all sounds that are playing on behalf of the calling task are stopped.&lt;br /&gt;You must also specify the instance handle to stop SND_RESOURCE events.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_RESOURCE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The pszSound parameter is a resource identifier; hmod must identify the instance that contains the resource.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SND_SYNC&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Synchronous playback of a sound event. PlaySound returns after the sound event completes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The sound specified by pszSound must fit into available physical memory and be playable by an installed waveform-audio device driver. PlaySound searches the following directories for sound files: the current directory; the Windows directory; the Windows system directory; directories listed in the PATH environment variable; and the list of directories mapped in a network. For more information about the directory search order, see the documentation for the OpenFile function.&lt;br /&gt;&lt;br /&gt;If it cannot find the specified sound, PlaySound uses the default system event sound entry instead. If the function can find neither the system default entry nor the default sound, it makes no sound and returns FALSE.&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-6190686000757773857?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/6190686000757773857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2007/10/audio-wav.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6190686000757773857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/6190686000757773857'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2007/10/audio-wav.html' title='Audio: 如何播放一段 WAV 檔'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116416751789308059</id><published>2006-11-22T11:32:00.000+08:00</published><updated>2007-04-20T10:58:45.110+08:00</updated><title type='text'>文章總覽</title><content type='html'>VFW:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/vfwh.html" target="blank"&gt;VFW.H&lt;/a&gt; ( 28 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/vfw.html" target="blank"&gt;取得視訊裝置驅動程式的資訊&lt;/a&gt; ( 29 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw_116179517330030752.html" target="blank"&gt;如何建立一個視訊擷取視窗&lt;/a&gt; ( 13 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw_13.html" target="blank"&gt;連結視訊擷取視窗與視訊裝置&lt;/a&gt; ( 13 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw_116179084560205019.html" target="blank"&gt;取得視訊裝置驅動程式的效能&lt;/a&gt; ( 15 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw_116179063565042925.html" target="blank"&gt;設定顯示模式&lt;/a&gt;  ( 15 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw_15.html" target="blank"&gt;設定視訊畫面顯示速率&lt;/a&gt; ( 15 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/vfw.html" target="blank"&gt;調整視訊畫面大小&lt;/a&gt;  ( 15 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/11/vfw.html" target="blank"&gt;靜態影像擷取&lt;/a&gt; ( 1 Nov, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/11/vfw_04.html" target="blank"&gt;錄影參數設定&lt;/a&gt; ( 4 Nov, 2006 )&lt;br /&gt;&lt;br /&gt;Bitmap:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/rgb-macro.html" target="blank"&gt;RGB macro&lt;/a&gt; ( 12 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/11/bitmap-bitblt.html" target="blank"&gt;位元塊傳輸 BitBlt&lt;/a&gt; ( 18 Nov, 2006 )&lt;br /&gt;&lt;br /&gt;Data Tpyes &amp; Classes:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/tcolor-type.html" target="blank"&gt;TColor type&lt;/a&gt; ( 6 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/tcanvas.html" target="blank"&gt;TCanvas&lt;/a&gt;  ( 6 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/trect-type.html" target="blank"&gt;TRect type&lt;/a&gt;  ( 21 Oct, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/05/tagpoint.html"&gt;tagPOINT type&lt;/a&gt; ( 28, May, 2006 )&lt;br /&gt;&lt;br /&gt;Objects &amp;amp; Methods:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/timage.html" target="blank"&gt;TImage&lt;/a&gt; ( 25 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/tpicture.html" target="blank"&gt;TPicture&lt;/a&gt; ( 25 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/objects.html" target="blank"&gt;Objects&lt;/a&gt; ( 26 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/tcanvascopyrect-method.html" target="blank"&gt;TCanvas::CopyRect method&lt;/a&gt;  ( 21 Oct, 2006 )&lt;br /&gt;&lt;br /&gt;Basic:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/bmp.html" target="blank"&gt;開啟 BMP 影像&lt;/a&gt; ( 11 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/jpeg.html" target="blank"&gt;開啟 JPEG 影像&lt;/a&gt; ( 11 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/blog-post.html" target="blank"&gt;動態宣告二維陣列&lt;/a&gt; ( 13 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/visual-component-library-vcl.html" target="blank"&gt;Visual Component Library (VCL)&lt;/a&gt; ( 24 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/09/component-palette.html" target="blank"&gt;Component Palette&lt;/a&gt; ( 25 Sep, 2006 )&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/11/label.html" target="blank"&gt;如何讓 Label 顯示實數值&lt;/a&gt;  ( 13 Nov, 2006)&lt;br /&gt;&lt;a href="http://leebcb.blogspot.com/2006/11/booltostr.html" target="blank"&gt;將布林值轉成字串 BoolToStr&lt;/a&gt;  ( 4 Nov, 2006 )&lt;br /&gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116416751789308059?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116416751789308059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116416751789308059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116416751789308059'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/blog-post.html' title='文章總覽'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116383171232677407</id><published>2006-11-18T14:10:00.000+08:00</published><updated>2007-02-08T23:53:20.929+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bitmap'/><title type='text'>Bitmap: 位元塊傳輸 BitBlt</title><content type='html'>當我們想將圖像從視訊顯示的某個區域複製到另外一個區域時, 可以考慮使用 Windows 圖形裝置介面 (Graphics Device Interface, GDI) 所提供的位元塊傳輸 ( bit-block transfer )  函式 BitBlt。BitBlt 讀作 bit blit, 有關 &lt;a href="http://en.wikipedia.org/wiki/Bit_blit" target="blank"&gt;Bit Blit&lt;/a&gt; 這個指令的來源, 在 &lt;a href="http://www.wikipedia.org/" target="blank"&gt;維基百科&lt;/a&gt;有相當詳細的描述; 除此, 維基百科還用小精靈為例子, 介紹關於背景圖片與 BitBlt 的使用方法, 值得一看...&lt;br /&gt;&lt;blockquote&gt;The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.&lt;br /&gt;&lt;br /&gt;BOOL BitBlt(&lt;br /&gt;　HDC hdcDest,&lt;br /&gt;　　// handle to destination device context&lt;br /&gt;　int nXDest,&lt;br /&gt;　　// x-coordinate of destination rectangle's upper-left corner&lt;br /&gt;　int nYDest,&lt;br /&gt;　　// y-coordinate of destination rectangle's upper-left corner&lt;br /&gt;　int nWidth,&lt;br /&gt;　　// width of destination rectangle&lt;br /&gt;　int nHeight,&lt;br /&gt;　　// height of destination rectangle&lt;br /&gt;　HDC hdcSrc,&lt;br /&gt;　　// handle to source device context&lt;br /&gt;　int nXSrc,&lt;br /&gt;　　// x-coordinate of source rectangle's upper-left corner&lt;br /&gt;　int nYSrc,&lt;br /&gt;　　// y-coordinate of source rectangle's upper-left corner&lt;br /&gt;　DWORD dwRop&lt;br /&gt;　　// raster operation code&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;hdcDest&lt;/span&gt;　Identifies the destination device context.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nXDest&lt;/span&gt;　Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nYDest&lt;/span&gt;　Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nWidth&lt;/span&gt;　Specifies the logical width of the source and destination rectangles.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nHeight&lt;/span&gt;　Specifies the logical height of the source and the destination rectangles.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;hdcSrc&lt;/span&gt;　Identifies the source device context.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nXSrc&lt;/span&gt;　Specifies the logical x-coordinate of the upper-left corner of the source rectangle.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;nYSrc&lt;/span&gt;　Specifies the logical y-coordinate of the upper-left corner of the source rectangle.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;dwRop&lt;/span&gt;　Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color.&lt;br /&gt;&lt;br /&gt;The following list shows some common &lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;raster operation codes&lt;/span&gt;:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Value    Description&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;BLACKNESS  &lt;/span&gt; 　Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;DSTINVERT&lt;/span&gt;   　Inverts the destination rectangle.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;MERGECOPY&lt;/span&gt;　Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;MERGEPAINT&lt;/span&gt;   　Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;NOTSRCCOPY&lt;/span&gt;　Copies the inverted source rectangle to the destination.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;NOTSRCERASE　&lt;/span&gt;Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;PATCOPY&lt;/span&gt;   　Copies the specified pattern into the destination bitmap.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;PATINVERT&lt;/span&gt;   　Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;PATPAINT&lt;/span&gt;　Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;SRCAND&lt;/span&gt;   　Combines the colors of the source and destination rectangles by using the Boolean AND operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SRCCOPY&lt;/span&gt;   　Copies the source rectangle directly to the destination rectangle.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SRCERASE&lt;/span&gt;   　Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SRCINVERT&lt;/span&gt;   　Combines the colors of the source and destination rectangles by using the Boolean XOR operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;SRCPAINT&lt;/span&gt;   　Combines the colors of the source and destination rectangles by using the Boolean OR operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;WHITENESS&lt;/span&gt;　Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;If the function succeeds, the return value is nonzero.&lt;br /&gt;If the function fails, the return value is zero. To get extended error information, call GetLastError.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;If a rotation or shear transformation is in effect in the source device context, BitBlt returns an error. If other transformations exist in the source device context (and a matching transformation is not in effect in the destination device context), the rectangle in the destination device context is stretched, compressed, or rotated as necessary.&lt;br /&gt;&lt;br /&gt;If the color formats of the source and destination device contexts do not match, the BitBlt function converts the source color format to match the destination format.&lt;br /&gt;&lt;br /&gt;When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context.&lt;br /&gt;&lt;br /&gt;Not all devices support the BitBlt function. For more information, see the RC_BITBLT raster capability entry in GetDeviceCaps.&lt;br /&gt;&lt;br /&gt;BitBlt returns an error if the source and destination device contexts represent different devices. &lt;/blockquote&gt;&lt;br /&gt;針對 BitBlt 這個指令, 我做了一項有趣的實驗, 利用 WebCam 攝影機拍攝了連續兩張影像, 這兩張影像人眼看起來雖然相同, 但是, 由於光影的影響, 還是存在一些像素的色彩值有些許的差異。&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/BitBlit-Background.jpg" alt="" border="0" height="240" hspace="5" vspace="5" width="320" /&gt;&lt;br /&gt;&lt;br /&gt;我使用 BitBlt 這個指令, 並設定運算模式為 SRCINVERT, 將一張影像從 Device Context (DC), 傳送到另外一張影像的 DC 中, 得到下列這張影像...&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/BitBlit-SRCINVERT.jpg" alt="" border="0" height="240" hspace="5" vspace="5" width="320" /&gt;&lt;br /&gt;&lt;br /&gt;很有趣的實驗, 你知道為什麼這張影像會出現紅、綠、藍這些顏色嗎?&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116383171232677407?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116383171232677407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/bitmap-bitblt.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116383171232677407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116383171232677407'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/bitmap-bitblt.html' title='Bitmap: 位元塊傳輸 BitBlt'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116343237390944304</id><published>2006-11-13T23:22:00.000+08:00</published><updated>2007-12-20T13:54:01.673+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>如何讓 Label 顯示實數值</title><content type='html'>在程式中, 我們常會遭遇到要顯示實數(real number)的問題, 早期我會直接寫一個小程式把實數中每一個 digit 都算出來, 然後轉換成 AnsiString, 再把字串接起來, 再顯示到 Label 上。&lt;br /&gt;&lt;br /&gt;後來, 我的作法就簡單多了, 直接用 sprintf 的方式, 將實數輸出到某一個字串中, 然後再顯示到某個 Label 上。例如:&lt;br /&gt;&lt;br /&gt;//宣告部份&lt;br /&gt;char Message[10];&lt;br /&gt;&lt;br /&gt;//程式部份&lt;br /&gt;RMS = sqrt(SquareErrorSum/(MH*MW*3));&lt;br /&gt;sprintf(Message,"%6.3f",RMS);&lt;br /&gt;lblRMS-&gt;Caption = "RMS="+AnsiString(Message);&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116343237390944304?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116343237390944304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/label.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116343237390944304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116343237390944304'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/label.html' title='如何讓 Label 顯示實數值'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116265402066724782</id><published>2006-11-04T23:19:00.000+08:00</published><updated>2006-11-24T01:11:45.837+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 錄影參數設定</title><content type='html'>攝影機錄影期間, 必須針對需求設定相關攝影參數, 這些參數在 vfw.h 之中, 宣告一個資料型態來儲存這些參數。&lt;br /&gt;&lt;blockquote&gt;typedef struct tagCaptureParms {&lt;br /&gt;　DWORD       dwRequestMicroSecPerFrame;&lt;br /&gt;　　　　　　　　　　 // Requested capture rate&lt;br /&gt;　BOOL        fMakeUserHitOKToCapture;    // Show "Hit OK to cap" dlg?&lt;br /&gt;　UINT        wPercentDropForError;       // Give error msg if &gt; (10%)&lt;br /&gt;　BOOL        fYield;                     // Capture via background task?&lt;br /&gt;　DWORD       dwIndexSize;                // Max index size in frames (32K)&lt;br /&gt;　UINT        wChunkGranularity;          // Junk chunk granularity (2K)&lt;br /&gt;　BOOL        fUsingDOSMemory;            // Use DOS buffers?&lt;br /&gt;　UINT        wNumVideoRequested;         // # video buffers, If 0, autocalc&lt;br /&gt;　BOOL        fCaptureAudio;              // Capture audio?&lt;br /&gt;　UINT        wNumAudioRequested;         // # audio buffers, If 0, autocalc&lt;br /&gt;　UINT        vKeyAbort;                  // Virtual key causing abort&lt;br /&gt;　BOOL        fAbortLeftMouse;            // Abort on left mouse?&lt;br /&gt;　BOOL        fAbortRightMouse;           // Abort on right mouse?&lt;br /&gt;　BOOL        fLimitEnabled;              // Use wTimeLimit?&lt;br /&gt;　UINT        wTimeLimit;                 // Seconds to capture&lt;br /&gt;　BOOL        fMCIControl;                // Use MCI video source?&lt;br /&gt;　BOOL        fStepMCIDevice;             // Step MCI device?&lt;br /&gt;　DWORD       dwMCIStartTime;             // Time to start in MS&lt;br /&gt;　DWORD       dwMCIStopTime;              // Time to stop in MS&lt;br /&gt;　BOOL        fStepCaptureAt2x;           // Perform spatial averaging 2x&lt;br /&gt;　UINT        wStepCaptureAverageFrames;&lt;br /&gt;　　　　　　　　　　// Temporal average n Frames&lt;br /&gt;　DWORD       dwAudioBufferSize;          // Size of audio bufs (0 = default)&lt;br /&gt;　BOOL        fDisableWriteCache;         // Attempt to disable write cache&lt;br /&gt;　UINT        AVStreamMaster;             // Which stream controls length?&lt;br /&gt;} CAPTUREPARMS, *PCAPTUREPARMS, FAR *LPCAPTUREPARMS;&lt;/blockquote&gt;&lt;br /&gt;因此, 我們在程式中可以如下宣告一個變數 s,&lt;br /&gt;&lt;blockquote&gt;tagCaptureParms s;&lt;/blockquote&gt;然後, 我們就可以透過 &amp;s 當作為呼叫 VFW SDK 相關函數的參數, 了解目前視訊系統的攝影參數設定為何? 一般來說, 一些我們比較常用到的攝影參數為:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;指定視訊畫面的擷取速率&lt;/li&gt;&lt;li&gt;指定分派影像緩衝區數目&lt;/li&gt;&lt;li&gt;選擇是否'擷取聲音&lt;/li&gt;&lt;li&gt;指定視訊串流擷取時間長短&lt;/li&gt;&lt;li&gt;指定擷取時間是否使用 &lt;a href="http://en.wikipedia.org/wiki/Media_Control_Interface" target="blank"&gt;MCI&lt;/a&gt; 裝置&lt;/li&gt;&lt;li&gt;指定鍵盤或滑鼠控制來終止擷取&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;在 VFW SDK 中, 透過 capCaptureGetSetup 可以知道目前的錄影參數的設定為何?&lt;br /&gt;&lt;blockquote&gt;The capCaptureGetSetup macro retrieves the current settings of the streaming capture parameters.&lt;br /&gt;&lt;br /&gt;BOOL capCaptureGetSetup(&lt;br /&gt;　hwnd,&lt;br /&gt;　s,&lt;br /&gt;　wSize&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;hwnd&lt;/span&gt;　Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;s&lt;/span&gt;　Address of a CAPTUREPARMS structure.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;wSize&lt;/span&gt;　Size, in bytes, of the structure referenced by s.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;For information about the parameters used to control streaming capture, see the CAPTUREPARMS structure.&lt;/blockquote&gt;知道了錄影參數的設定情形後, 我們也可以透過 capCaptureSetSetup 來改變錄影參數的設定:&lt;br /&gt;&lt;blockquote&gt;The capCaptureGetSetup macro retrieves the current settings of the streaming capture parameters.&lt;br /&gt;&lt;br /&gt;BOOL capCaptureGetSetup(&lt;br /&gt;　hwnd,&lt;br /&gt; 　s,&lt;br /&gt; 　wSize&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;hwnd&lt;/span&gt;　Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;s&lt;/span&gt;　Address of a CAPTUREPARMS structure.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;wSize&lt;/span&gt;　Size, in bytes, of the structure referenced by s.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;For information about the parameters used to control streaming capture, see the CAPTUREPARMS structure.&lt;/blockquote&gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116265402066724782?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116265402066724782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/vfw_04.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116265402066724782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116265402066724782'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/vfw_04.html' title='VFW: 錄影參數設定'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116262441185993846</id><published>2006-11-04T12:00:00.000+08:00</published><updated>2007-12-20T13:54:33.096+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>將布林值轉成字串 BoolToStr</title><content type='html'>運用在邏輯運算的 Boolean 型態值有&lt;span style="font-weight: bold;"&gt; true&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; 兩個。因此, 這兩個字在 C++ 屬於 specific keywords。換句話說, 你不可以用這兩個字當變數名稱, 它們是有特定意義的。&lt;br /&gt;&lt;br /&gt;我們再深入一點探討, 電腦是怎麼儲存這個形態的變數呢? 我們看看 BCB 中的 Help 是怎麼說的:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;bool&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Category&lt;/span&gt;&lt;br /&gt;C++-Specific Keywords&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Syntax&lt;/span&gt;&lt;br /&gt;bool &lt;identifier&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;Use bool and the literals false and true to perform Boolean logic tests.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;bool&lt;/span&gt; keyword represents a type that can take only the value &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;. The keywords &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; are Boolean literals with predefined values. &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; is numericallly zero and &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; is numerically one. These Boolean literals are rvalues; you cannot make an assignment to them.&lt;br /&gt;&lt;br /&gt;You can convert an rvalue that is of type bool to an rvalue that is &lt;span style="font-weight: bold;"&gt;int&lt;/span&gt; type. The numerical conversion sets &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; to zero and &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; becomes one.&lt;br /&gt;&lt;br /&gt;You can convert arithmetic, enumeration, pointer, or pointer to member rvalue types to an rvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt;. Any other value is converted to &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;.&lt;/identifier&gt;&lt;/blockquote&gt;&lt;br /&gt;很顯然地, 這些 Boolean 值在電腦中, 也是用電腦基本的 0, 1 數值來儲存。"The keywords &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; are Boolean literals with predefined values. &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; is numericallly zero and &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; is numerically one." 此外, 我們也可以把一些其他型態的值轉換成布林值, 像 0, null pointer value, null member pointer value 會被轉換成 &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt;, 其餘則是通通轉換成 &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;。&lt;br /&gt;&lt;br /&gt;在 BCB 中, 還提供了一個 BoolToStr 將布林值轉換成字串。&lt;br /&gt;&lt;blockquote&gt;BoolToStr(bool B, bool UseBoolStrs)&lt;br /&gt;Converts a Boolean value to an AnsiString.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;SysUtils&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Category&lt;/span&gt;&lt;br /&gt;type conversion routines&lt;br /&gt;&lt;br /&gt;extern PACKAGE AnsiString __fastcall BoolToStr(bool B, bool UseBoolStrs = false);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;BoolToStr converts the given Boolean value to a string as follows:&lt;br /&gt;&lt;br /&gt;B　UseBoolStrs    　Returned string&lt;br /&gt;true    　false    　　　"-1"&lt;br /&gt;true    　true    　　　The first string in TrueBoolStrs (default, "TRUE");&lt;br /&gt;false    　false    　　　"0"&lt;br /&gt;false    　true    　　　The first string in FalseBoolStrs (default, "FALSE"); &lt;/blockquote&gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116262441185993846?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116262441185993846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/booltostr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116262441185993846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116262441185993846'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/booltostr.html' title='將布林值轉成字串 BoolToStr'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116231645988029977</id><published>2006-11-01T00:38:00.000+08:00</published><updated>2006-11-24T01:12:50.517+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 靜態影像擷取</title><content type='html'>VFW SDK 所提供的擷取靜態影像方式是先抓取單一視訊畫面 ( frame ), 將其存入記憶體緩衝區中, 接下來你可以選擇要將存到剪貼簿中, 或是直接存成一張點陣圖檔 ( .BMP )。&lt;br /&gt;&lt;br /&gt;抓取單一視訊畫面時, 依照不同需求, 可以使用 capGrabFrame 選擇讓原先動態的視訊畫面靜止, 或是用 capGrabFrameNoStop 不讓畫面靜止。靜止的影像可以讓我們清楚地看清抓取的視訊畫面為何, 如果要讓原先的擷取視窗恢復動態顯示, 則是必須重新 &lt;a href="http://leebcb.blogspot.com/2006/10/vfw_116179063565042925.html" target="blank"&gt;設定顯示模式&lt;/a&gt; 才行。&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The capGrabFrame macro retrieves and displays a single frame from the capture driver. After capture, overlay and preview are disabled.&lt;br /&gt;&lt;br /&gt;BOOL capGrabFrame(&lt;br /&gt;　hwnd&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;hwnd  Handle of a capture window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.&lt;/blockquote&gt;因為必須告知要抓取哪一個視訊視窗, 所以函數的傳入值 ( parameter ) 就是該視窗的代碼 ( handle)。而傳回值 ( return value ) 就是告知我們是否成功捉取畫面。至於抓取畫面後的後續動作, 還可以使用回呼函數 ( callback function ) 來執行。&lt;br /&gt;&lt;blockquote&gt;The capGrabFrameNoStop macro fills the frame buffer with a single uncompressed frame from the capture device and displays it. Unlike with the capGrabFrame macro, the state of overlay or preview is not altered by this message.&lt;br /&gt;&lt;br /&gt;BOOL capGrabFrameNoStop(&lt;br /&gt;　hwnd&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;hwnd  Handle of a capture window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.&lt;/blockquote&gt;以點陣圖格式 ( &lt;a href="http://en.wikipedia.org/wiki/DIB"&gt;device independent bitmap, DIB&lt;/a&gt; ) 放入緩衝區的視訊畫面, 可以透過放到剪貼簿的方式 (capEditCopy) 讓別的應用程式使用。&lt;br /&gt;&lt;blockquote&gt;The capEditCopy macro copies the contents of the video frame buffer and associated palette to the clipboard.&lt;br /&gt;&lt;br /&gt;BOOL capEditCopy(&lt;br /&gt;  　hwnd &lt;br /&gt; 　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;hwnd Handle of a capture window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;/blockquote&gt;我們也可以使用 capFileSaveDIB 直接將緩衝區中畫面存成點陣圖檔 ( .BMP )。&lt;br /&gt;&lt;blockquote&gt;The capFileSaveDIB macro copies the current frame to a DIB file.&lt;br /&gt;&lt;br /&gt;BOOL capFileSaveDIB(&lt;br /&gt;　hwnd,  &lt;br /&gt;   　szName  &lt;br /&gt;  );  &lt;br /&gt;&lt;br /&gt;Parameters&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;hwnd&lt;/span&gt;    Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;szName&lt;/span&gt;    Address of the null-terminated string that contains the name of the destination DIB file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise. If an error occurs and an error callback function is set using the capSetCallbackOnError macro, the error callback function is called.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;If the capture driver supplies frames in a compressed format, this call attempts to decompress the frame before writing the file.&lt;/blockquote&gt;注意: 輸入參數 szName 變數名稱前置的 sz 告訴我們這是一個 null-terminated string。而要傳入的正是該 string 的記憶體位址 ( address )。因此, 若是我們在 BCB 中, 要用一個 TSavePictureDialog 類別的物件要讓使用者輸入檔名, 我們在程式中則是要將該物件的檔名屬性 ( TSavePictureDialog::FileName ) 中的檔名位址指定給 capFileSaveDIB 函數。假設該物件的名稱為 SavePictureDialog1, 而檔名的位址為: &amp;SavePictureDialog1-&gt;FileName[1]。&lt;br /&gt;&lt;br /&gt;範例程式:&lt;br /&gt;　if ( SavePictureDialog1-&gt;Execute() )&lt;br /&gt;　　{&lt;br /&gt;　　capFileSaveDIB(hwndVideo,&amp;amp;(SavePictureDialog1-&gt;FileName[1]));&lt;br /&gt;　　}&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116231645988029977?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116231645988029977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/11/vfw.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116231645988029977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116231645988029977'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/11/vfw.html' title='VFW: 靜態影像擷取'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116178730646119017</id><published>2006-10-21T11:14:00.000+08:00</published><updated>2006-10-27T10:58:54.686+08:00</updated><title type='text'>TRect type</title><content type='html'>TRect defines a rectangle.&lt;br /&gt;&lt;blockquote&gt; &lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;Types&lt;br /&gt;&lt;br /&gt;struct TRect&lt;br /&gt;　{&lt;br /&gt;　TRect() {}&lt;br /&gt;　TRect(const TPoint&amp; TL, const TPoint&amp;amp;amp;amp; BR)&lt;br /&gt;　　{ left=TL.x; top=TL.y; right=BR.x; bottom=BR.y; }&lt;br /&gt;　TRect(int l, int t, int r, int b)&lt;br /&gt;　　{ left=l; top=t; right=r; bottom=b; }&lt;br /&gt;　TRect(RECT&amp; r)&lt;br /&gt;　　{&lt;br /&gt;　　left    = r.left;&lt;br /&gt;　　top     = r.top;&lt;br /&gt;　　right   = r.right;&lt;br /&gt;　　bottom  = r.bottom;&lt;br /&gt;　　}&lt;br /&gt;&lt;br /&gt;int Width() const { return right  - left; }&lt;br /&gt;int Height() const { return bottom - top ; }&lt;br /&gt;bool operator ==(const TRect&amp; rc) const&lt;br /&gt;　{&lt;br /&gt;　return left ==  rc.left  &amp;amp;amp;amp;&amp; top==rc.top &amp;amp;&amp;  &lt;br /&gt;　right == rc.right &amp;amp;&amp; bottom==rc.bottom;&lt;br /&gt;　}&lt;br /&gt;bool operator !=(const TRect&amp; rc) const&lt;br /&gt;　{  return !(rc==*this); }&lt;br /&gt;　__property LONG Left    = { read=left,   write=left   };&lt;br /&gt;　__property LONG Top    = { read=top,    write=top };&lt;br /&gt;　__property LONG Right   = { read=right,  write=right  };&lt;br /&gt;　__property LONG Bottom  = { read=bottom, write=bottom };&lt;br /&gt;　};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;TRect represents the dimensions of a rectangle. The coordinates are specified as either four separate integers representing the left, top, right, and bottom sides, or as two points representing the locations of the top left and bottom right corners.&lt;br /&gt;&lt;br /&gt;Typically, TRect values represent pixel locations, where the origin of the pixel coordinate system is in the top left corner of the screen (screen coordinates) or the top left corner of a control client area (client coordinates). When a TRect value represents a rectangle on the screen, by convention the top and left edges are considered inside the rectangle and &lt;span style="color: rgb(255, 0, 0);"&gt;the bottom and right edges are considered outside the rectangle. This convention allows the width of the rectangle to be Right - Left and the height to be Bottom - Top. &lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt; 要特別注意的一點是 TRect 這個長方塊中所指明的區域並不包含 the bottom and right edges, 這是為了讓 rectangle 的長寬值剛好符合座標相減的緣故。&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116178730646119017?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116178730646119017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/trect-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116178730646119017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116178730646119017'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/trect-type.html' title='TRect type'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116178890695495008</id><published>2006-10-21T10:59:00.001+08:00</published><updated>2011-09-07T11:58:07.208+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='TCanvas'/><title type='text'>TCanvas::CopyRect method</title><content type='html'>Copies part of an image from another canvas into the canvas.&lt;br /&gt;&lt;blockquote&gt; void __fastcall CopyRect(const &lt;a href="http://leebcb.blogspot.com/2006/10/trect-type.html"&gt;TRect &lt;/a&gt;&amp;Dest, TCanvas* Canvas, const &lt;a href="http://leebcb.blogspot.com/2006/10/trect-type.html"&gt;TRect&lt;/a&gt; &amp;amp;Source);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;Use CopyRect to transfer part of the image on another canvas to the image of the &lt;a href="http://leebcb.blogspot.com/2006/10/tcanvas.html" target="blank"&gt;TCanvas&lt;/a&gt; object. Dest specifies the rectangle on the canvas where the source image will be copied. The Canvas parameter specifies the canvas with the source image. Source specifies a rectangle bounding the portion of the source canvas that will be copied.&lt;br /&gt;&lt;br /&gt;The portion of the source canvas is copied using the mode specified by CopyMode. &lt;/blockquote&gt;&lt;a href="http://leebcb.blogspot.com/2006/10/tcanvas.html" target="blank"&gt;TCanvas&lt;/a&gt;::CopyRect method 可以將另外一個 Canvas ( 第二個輸入參數 ) 中的特定長方塊 (rectangle) ( 第三個輸入參數 ) 中的影像 copy 到自己這個 Canvas 的特定長方塊( 第一個輸入參數 ) 中。&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116178890695495008?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116178890695495008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcanvascopyrect-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116178890695495008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116178890695495008'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcanvascopyrect-method.html' title='TCanvas::CopyRect method'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179016303885123</id><published>2006-10-15T21:52:00.001+08:00</published><updated>2008-03-25T13:06:12.853+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 調整視訊畫面大小</title><content type='html'>調整視訊畫面大小主要有兩個步驟:&lt;br /&gt;1. 使用VFW SDK 所提供的 capPreviewScale 函數設定畫面大小是否隨著視窗大小變化。&lt;br /&gt;2. 使用 Win32 API 的 MoveWindow 函數來調整視訊擷取視窗的大小。&lt;br /&gt;&lt;br /&gt;在 Preview 的顯示模式下, VFW SDK 提供 capPreviewScale 函數來允許視訊畫面大小隨著視窗大小變化而調整。 &lt;blockquote&gt; The capPreviewScale macro enables or disables scaling of the preview video images. If scaling is enabled, the captured video frame is stretched to the dimensions of the capture window.&lt;br /&gt;&lt;br /&gt;BOOL capPreviewScale(&lt;br /&gt;　hwnd, &lt;br /&gt;　f &lt;br /&gt;　); &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;hwnd&lt;/span&gt;     Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;f    &lt;/span&gt;   Preview scaling flag.&lt;br /&gt;        Specify TRUE for this parameter to stretch preview frames to the size of the&lt;br /&gt;   capture window or FALSE to display them at their natural size.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;Scaling preview images controls the immediate presentation of captured frames within the capture window. It has no effect on the size of the frames saved to file. Scaling has no effect when using overlay to display video in the frame buffer.&lt;br /&gt;&lt;/blockquote&gt;設定擷取畫面隨著擷取視窗的位置, 大小而調整後, 我們就可以使用 Win32 API 所提供的 MoveWindow 函數來調整視窗, 達到調整視訊擷取畫面的目的&lt;br /&gt;&lt;blockquote&gt; The &lt;span style="color: rgb(0, 0, 255);"&gt;MoveWindow&lt;/span&gt; function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.&lt;br /&gt;&lt;br /&gt;BOOL MoveWindow(&lt;br /&gt;　HWND hWnd,       　// handle of window&lt;br /&gt;  　int X,　　　　　// horizontal position&lt;br /&gt;  　int Y,　　　　　// vertical position&lt;br /&gt;  　int nWidth,　　// width&lt;br /&gt;  　int nHeight,             　　// height&lt;br /&gt;  　BOOL bRepaint     // repaint flag&lt;br /&gt; 　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;hWnd&lt;/span&gt;   Identifies the window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;X&lt;/span&gt;   Specifies the new position of the left side of the window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Y &lt;/span&gt;  Specifies the new position of the top of the window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;nWidth&lt;/span&gt;    Specifies the new width of the window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;nHeight &lt;/span&gt;  Specifies the new height of the window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;bRepaint&lt;/span&gt;   Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a WM_PAINT message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window. If this parameter is FALSE, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;If the function succeeds, the return value is nonzero.&lt;br /&gt;If the function fails, the return value is zero.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;If the bRepaint parameter is TRUE, Windows sends the WM_PAINT message to the window procedure immediately after moving the window (that is, the MoveWindow function calls the UpdateWindow function). If bRepaint is FALSE, Windows places the WM_PAINT message in the message queue associated with the window. The message loop dispatches the WM_PAINT message only after dispatching all other messages in the queue.&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179016303885123?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179016303885123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179016303885123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179016303885123'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw.html' title='VFW: 調整視訊畫面大小'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179029931171738</id><published>2006-10-15T21:30:00.001+08:00</published><updated>2008-03-25T13:05:51.187+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 設定視訊畫面顯示速率</title><content type='html'>在Preview 顯示模式下, VFW SKD 提供 capPreviewRate 函數來設定視訊畫面的顯示速率。&lt;br /&gt;&lt;blockquote&gt; The capPreviewRate macro sets the frame display rate in preview mode.&lt;br /&gt;&lt;br /&gt;BOOL capPreviewRate(&lt;br /&gt;　hwnd,  &lt;br /&gt;　wMS  &lt;br /&gt;　);  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; hwnd&lt;/span&gt;      Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; wMS&lt;/span&gt;      Rate, in milliseconds, at which new frames are captured and displayed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE if the capture window is not connected to a capture driver.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; Remarks&lt;/span&gt;&lt;br /&gt;The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another application has the focus. During streaming video capture, the previewing task is lower priority than writing frames to disk, and preview frames are displayed only if no other buffers are available for writing.&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;注意:&lt;/span&gt; 這邊的 wMS 指的就是一個畫面 ( frame ) 要顯示多少毫秒 ( msec ), 單位是 msec/frame, 若要轉換成我們一般習慣的每秒顯示多少個畫面, 單位是 frame/sec, 則是 1sec. = 1000 msec. 例如: 每個畫面顯示 20 毫秒, 代表每秒種可以顯示 1000/20 = 50 個畫面。&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179029931171738?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179029931171738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_15.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179029931171738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179029931171738'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_15.html' title='VFW: 設定視訊畫面顯示速率'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179063565042925</id><published>2006-10-15T16:24:00.001+08:00</published><updated>2008-03-25T13:05:26.756+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 設定顯示模式</title><content type='html'>視訊顯示模式分成兩種:&lt;br /&gt;一、Preview 顯示模式:&lt;br /&gt;從視訊裝置取得的影像資料會先放在系統記憶體中, 然後再顯示於螢幕上。這些處理過程全都要仰賴 CPU 處理, 因此效率較差。在 Preview 模式下, 可以透過 &lt;a href="http://leebcb.blogspot.com/2006/10/vfw_15.html" target="blank"&gt;capPreviewRate&lt;/a&gt; 函數設定視訊畫面的顯示速率與透過 &lt;a href="http://leebcb.blogspot.com/2006/10/vfw.html" target="blank"&gt;capPreviewScale&lt;/a&gt; 調整顯示畫面尺寸。VFW SDK 提供了 capPreview 函數來啟動 Preview 顯示模式。  &lt;blockquote&gt; The &lt;span style="color: rgb(0, 0, 255);"&gt;capPreview&lt;/span&gt; macro enables or disables preview mode. In preview mode, frames are transferred from the capture hardware to system memory and then displayed in the capture window using GDI functions.&lt;br /&gt;&lt;br /&gt;BOOL capPreview(&lt;br /&gt;　hwnd,&lt;br /&gt;　f&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;hwnd&lt;/span&gt;  Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;f   &lt;/span&gt;        Preview flag. Specify TRUE for this parameter to enable preview mode or FALSE to disable it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another application has the focus. The fLiveWindow member of the CAPSTATUS structure indicates if preview mode is currently enabled. Enabling preview mode automatically disables overlay mode.&lt;br /&gt;&lt;/blockquote&gt;二、Overlay 顯示模式:&lt;br /&gt;視訊裝置會直接將影像資料覆疊到螢幕上, 因此, 並不會佔用系統的 CPU 與記憶體資源, 所以顯示效率較好。不過, 並不是所有的視訊裝置都支援 Overlay 模式, 像 USB 攝影機就不支援 Overlay 顯示模式。 VFW SDK 提供 capOverlay 函數來啟動 Overlay 顯示模式。&lt;blockquote&gt; The &lt;span style="color: rgb(0, 0, 255);"&gt;capOverlay&lt;/span&gt; macro enables or disables overlay mode. In overlay mode, video is displayed using hardware overlay.&lt;br /&gt;&lt;br /&gt;BOOL capOverlay(&lt;br /&gt;　hwnd,&lt;br /&gt;　f&lt;br /&gt;　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; hwnd&lt;/span&gt;   Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; f&lt;/span&gt;   Overlay flag. Specify TRUE for this parameter to enable overlay mode or FALSE to disable it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;Using an overlay does not require CPU resources. The fHasOverlay member of the CAPDRIVERCAPS structure indicates whether the device is capable of overlay. The fOverlayWindow member of the CAPSTATUS structure indicates whether overlay mode is currently enabled. Enabling overlay mode automatically disables preview mode.&lt;br /&gt;&lt;/blockquote&gt; 註: USB 攝影機將類比影像訊號轉成數位資料, 透過 USB 傳輸介面傳送到系統記憶體中, 然後 CPU 再將影像資料顯示於螢幕上。至於影像擷取卡, 透過 A/D 轉換模組, 將類比影像訊號轉成數位資料, 並儲存於影像擷取卡的記憶體中。某些較高階的影像擷取卡還包含了影像處理晶片, 提供一些基本的影像處理功能。&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179063565042925?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179063565042925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179063565042925.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179063565042925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179063565042925'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179063565042925.html' title='VFW: 設定顯示模式'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179084560205019</id><published>2006-10-15T11:40:00.002+08:00</published><updated>2010-03-16T11:48:50.720+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 取得視訊裝置驅動程式的效能</title><content type='html'>由於各家視訊裝置所提供的驅動程式功能並不完全相同, 因此, 我們開發的應用程式有必要了解自己所安裝的驅動程式到底提供了什麼功能。VFW SDK 提供了 capDriverGetCaps 函數來讓你了解自己的視訊系統。&lt;br /&gt;&lt;blockquote&gt; The capDriverGetCaps macro returns the hardware capabilities of the capture driver currently connected to a  capture window.&lt;br /&gt;&lt;br /&gt;capDriverGetCaps(&lt;br /&gt;　hwnd,&lt;br /&gt; 　psCaps,&lt;br /&gt; 　wSize&lt;br /&gt; 　);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;hwnd&lt;/span&gt;     Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;psCaps&lt;/span&gt;  Address of the CAPDRIVERCAPS structure to contain the hardware capabilities.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;wSize&lt;/span&gt;     Size, in bytes, of the structure referenced by s.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE if the capture window is not connected to a capture driver.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;The capabilities returned in CAPDRIVERCAPS are constant for a given capture driver. Applications need to retrieve this information once when the capture driver is first connected to a capture window.&lt;br /&gt;&lt;/blockquote&gt; 呼叫了這個函數後, 我們的應用程式就會得知你的電腦中代表該視訊驅動程式的索引值, 你的視訊裝置有沒有提供影像 Overlay 模式, 提供了哪些對話盒供你呼叫使用...等等。&lt;br /&gt;&lt;br /&gt;既然這個函數要告訴我們這麼多資料, 顯然呼叫時, 就要設定很多個輸入或輸出的參數。為了方便我們使用, VFW 所採用的作法就是在 &lt;a href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/vfw.h"&gt;vfw.h&lt;/a&gt;, line 3493 起, 宣告了 tagCapDriverCaps 結構資料型態&lt;s&gt;攻&lt;/s&gt;供我們使用:&lt;br /&gt;&lt;blockquote&gt; typedef struct tagCapDriverCaps {&lt;br /&gt;　UINT          wDeviceIndex;                       // Driver index in system.ini&lt;br /&gt;　BOOL        fHasOverlay;                                               // Can device overlay?&lt;br /&gt;　BOOL        fHasDlgVideoSource;           // Has Video source dlg?&lt;br /&gt;　BOOL        fHasDlgVideoFormat;           // Has Format dlg?&lt;br /&gt;　BOOL        fHasDlgVideoDisplay;          // Has External out dlg?&lt;br /&gt;　BOOL        fCaptureInitialized;            // Driver ready to capture?&lt;br /&gt;　BOOL        fDriverSuppliesPalettes;        // Can driver make palettes?&lt;br /&gt;　// following always NULL on Win32.&lt;br /&gt;　HANDLE      hVideoIn;                                               // Driver In channel&lt;br /&gt;　HANDLE      hVideoOut;                                         // Driver Out channel&lt;br /&gt;　HANDLE      hVideoExtIn;                                    // Driver Ext In channel&lt;br /&gt;　HANDLE      hVideoExtOut;                              // Driver Ext Out channel&lt;br /&gt;　} CAPDRIVERCAPS, *PCAPDRIVERCAPS, FAR *LPCAPDRIVERCAPS;&lt;br /&gt;&lt;/blockquote&gt; 因此, 我們只要在程式中宣告一個變數 s 屬於 tagCapDriverCaps 資料型態, 我們就可以將 s 的位址 &amp;amp;s 放到 capDriverGetCaps 的參數之中來用了。&lt;br /&gt;&lt;br /&gt;範例程式:&lt;br /&gt;// 宣告部份:&lt;br /&gt;tagCapDriverCaps s;&lt;br /&gt;&lt;br /&gt;// 呼叫與傳回值使用部份&lt;br /&gt;if (capDriverGetCaps(hwndVideo,&amp;amp;s,sizeof(s)))&lt;br /&gt;  　{&lt;br /&gt;      　if ( s.fHasOverlay )&lt;br /&gt;        　　lblOverlay-&gt;Caption = AnsiString("Overlay: Yes");&lt;br /&gt;  　else&lt;br /&gt;　　lblOverlay-&gt;Caption = AnsiString("Overlay: No");&lt;br /&gt;　}&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179084560205019?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179084560205019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179084560205019.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179084560205019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179084560205019'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179084560205019.html' title='VFW: 取得視訊裝置驅動程式的效能'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179492495753005</id><published>2006-10-13T03:57:00.001+08:00</published><updated>2008-03-25T13:04:40.279+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 連結視訊擷取視窗與視訊裝置</title><content type='html'>The capDriverConnect macro connects a capture window to a capture driver.&lt;br /&gt;&lt;blockquote&gt; BOOL capDriverConnect(&lt;br /&gt;　hwnd,  &lt;br /&gt;　iIndex  &lt;br /&gt;   　);  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;hwnd&lt;/span&gt;   Handle of a capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;iIndex&lt;/span&gt;   Index of the capture driver. The index can range from 0 through 9.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE if the specified capture driver cannot be connected to the capture window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;Connecting a capture driver to a capture window automatically disconnects any previously connected capture driver. &lt;/blockquote&gt; 當我們的應用程式建立一個視訊擷取視窗時, 視窗的畫面仍然會黑壓壓的一片, 這是由於視訊裝置所拍攝的資料並沒有餵進所建立之視訊擷取視窗的緣故。我們可以用 capDriverConnect 這個函數將兩者連結起來。很自然而然地, 輸入參數一個是之前建立視窗時傳回的 handle 值, 另一個是視訊裝置驅動程式的編號 iIndex。不過, 要中斷兩者的連結 capDriverDisconnect , 只要指出哪個視訊擷取視窗要中斷連結即可, 並不需要指出兩邊的參數。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The capDriverDisconnect macro disconnects a capture driver from a capture window.&lt;br /&gt;&lt;br /&gt;BOOL capDriverDisconnect(&lt;br /&gt;　hwnd  &lt;br /&gt;   　);  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns TRUE if successful or FALSE if the capture window is not connected to a capture driver.&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;   注意:&lt;/span&gt; 連結成功後, 視訊擷取視窗的影像仍然是靜態的, 並不是即時動態的視訊資料, 這是由於尚未 &lt;a target="blank" href="http://leebcb.blogspot.com/2006/10/vfw_116179063565042925.html"&gt;設定顯示模式&lt;/a&gt; 的緣故。&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179492495753005?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179492495753005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_13.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179492495753005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179492495753005'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_13.html' title='VFW: 連結視訊擷取視窗與視訊裝置'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179517330030752</id><published>2006-10-13T01:11:00.001+08:00</published><updated>2008-03-25T13:07:03.565+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 如何建立一個視訊擷取視窗</title><content type='html'>The capCreateCaptureWindow function creates a capture window.&lt;br /&gt;&lt;blockquote&gt; HWND VFWAPI capCreateCaptureWindow(&lt;br /&gt;    LPCSTR lpszWindowName,   &lt;br /&gt;    DWORD dwStyle,   &lt;br /&gt;    int x,   &lt;br /&gt;    int y,   &lt;br /&gt;    int nWidth,   &lt;br /&gt;        int nHeight,   &lt;br /&gt;    HWND hWnd,   &lt;br /&gt;        int nID   &lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; lpszWindowName&lt;/span&gt;     Null-terminated string containing the name used for the capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; dwStyle&lt;/span&gt;     Window styles used for the capture window.&lt;br /&gt;                 ( Note: Window styles are described with the CreateWindowEx function.)&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; x and y&lt;/span&gt;     The x- and y-coordinates of the upper left corner of the capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; nWidth and nHeight&lt;/span&gt;      Width and height of the capture window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; hWnd&lt;/span&gt; Handle of the parent window.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; nID&lt;/span&gt;   Window identifier.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;Returns a handle of the capture window if successful or NULL otherwise.&lt;br /&gt;&lt;/blockquote&gt;看完 BCB Help 的說明後, 我們一樣也來看看 &lt;a href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/vfw.h" target="blank"&gt;vfw.h&lt;/a&gt; 之中, capCreateCaptureWindow 是如何宣告的:&lt;br /&gt;&lt;blockquote&gt; HWND VFWAPI capCreateCaptureWindowA (&lt;br /&gt;    LPCSTR lpszWindowName,&lt;br /&gt;    DWORD dwStyle,&lt;br /&gt;    int x, int y, int nWidth, int nHeight,&lt;br /&gt;    HWND hwndParent, int nID);&lt;br /&gt;&lt;br /&gt;HWND VFWAPI capCreateCaptureWindowW (&lt;br /&gt;    LPCWSTR lpszWindowName,&lt;br /&gt;    DWORD dwStyle,&lt;br /&gt;    int x, int y, int nWidth, int nHeight,&lt;br /&gt;    HWND hwndParent, int nID);&lt;br /&gt;&lt;/blockquote&gt; 我們要建立一個視訊擷取視窗, 自然要告訴電腦要把視窗建立在哪邊? 是要直接放在 Form 上呢? 還是放在 Form 上的 Panel 物件上呢? 因此, 我們必須透過 handleParent 這個參數來告訴電腦, 也就是需要告訴電腦一個代碼, 這個代碼表示了所產生的視窗將要顯示在哪個物件之上。除此, 要放在這個物件的何處, 則是透過 x, y 來指定視窗的左上角要放這個物件的哪一個 ( x, y ) 座標上; 至於所建立的擷取視窗大小則是透過 nWidth 與 nHeight 兩個參數來表示。&lt;br /&gt;&lt;br /&gt;capCreateCaptureWindow 的傳回值的資料型態為 HWND, 也就是所建立的視訊擷取視窗的代碼 ( handle ), 將來我們程式中要提到或針對此視窗的相關處理時, 只要指明這個代碼即可。&lt;br /&gt;&lt;br /&gt;要關閉視訊擷取視窗的方法, 如同要關閉一般視窗一樣, 只要利用 Win32 API 的 DestroyWindow 函數, 並告訴電腦你要關閉的視窗代碼 ( handle ) 即可。&lt;br /&gt;&lt;br /&gt;程式範例:&lt;br /&gt;HWND hwndVideo;&lt;br /&gt;&lt;br /&gt;hwndVideo = capCreateCaptureWindow(&lt;br /&gt;     (LPSTR) "My Capture Window", WS_CHILD | WS_VISIBLE,&lt;br /&gt;     0, 0, iImageWidth, iImageHeight, Form1-&gt;pnlCapture1-&gt;Handle, 1 );&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179517330030752?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179517330030752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179517330030752.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179517330030752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179517330030752'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/vfw_116179517330030752.html' title='VFW: 如何建立一個視訊擷取視窗'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179531261494195</id><published>2006-10-12T20:46:00.000+08:00</published><updated>2006-10-26T00:55:12.616+08:00</updated><title type='text'>RGB macro</title><content type='html'>The RGB macro selects a red, green, blue (RGB) color based on the arguments supplied and the color capabilities of the output device.&lt;br /&gt;&lt;blockquote&gt; COLORREF RGB(&lt;br /&gt;BYTE bRed,        // red component of color&lt;br /&gt;BYTE bGreen,    // green component of color&lt;br /&gt;BYTE bBlue        // blue component of color&lt;br /&gt;);   &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parameters&lt;/span&gt;&lt;br /&gt;cRed      Specifies the intensity of the red color.&lt;br /&gt;cGreen  Specifies the intensity of the green color.&lt;br /&gt;cBlue     Specifies the intensity of the blue color.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Return Values&lt;/span&gt;&lt;br /&gt;The return value is the resultant RGB color.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remarks&lt;/span&gt;&lt;br /&gt;The intensity for each argument is in the range 0 through 255. If all three intensities are zero, the result is black. If all three intensities are 255, the result is white.&lt;br /&gt;&lt;br /&gt;The RGB macro is defined as follows:&lt;br /&gt;&lt;br /&gt;#define RGB(r, g ,b)  ((DWORD) (((BYTE) (r) | \ &lt;br /&gt;((WORD) (g) &lt;&lt; 8)) | (((DWORD) (BYTE) (b)) &lt;&lt; 16)))&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179531261494195?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179531261494195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/rgb-macro.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179531261494195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179531261494195'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/rgb-macro.html' title='RGB macro'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179616223432730</id><published>2006-10-06T10:31:00.006+08:00</published><updated>2009-11-18T00:42:03.349+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><title type='text'>TCanvas</title><content type='html'>TCanvas 這個類別是用來處理 Window 繪圖的介面, 負責與 Window 的裝置驅動程式溝通, 透過裝置驅動程式將資料顯示在顯示器上面。&lt;br /&gt;&lt;br /&gt;C++ Builder 中, 具有 Canvas 的元件有 TForm, TImage, TbitButton ... 等等, 換句話說, 你可以在這些元件上繪圖。&lt;br /&gt;&lt;br /&gt;TCanvas 透過畫筆 (TPen) 和 畫刷 (&lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/tbrush.html"&gt;TBrush&lt;/a&gt;) 兩個類別來進行繪圖。除此, 也可以直接透過 &lt;a target="blank" href="http://leebcb.blogspot.com/2009/11/tcanvaspixels.html"&gt;Pixels property&lt;/a&gt; 對畫布上的像素色彩值進行存取。&lt;br /&gt;&lt;br /&gt;TCanvas provides an abstract drawing space for objects that must render their own images.&lt;blockquote&gt; &lt;span style="font-weight: bold;"&gt;Hierarchy&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.wretch.cc/blog/yklee&amp;amp;article_id=4482269" taregt="blank"&gt;TObject&lt;/a&gt; -&gt; TPersistent -&gt; TCanvas&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;Graphics&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;Use TCanvas as a drawing surface for &lt;a href="http://www.wretch.cc/blog/yklee&amp;amp;article_id=4482269"&gt;objects&lt;/a&gt; that draw an image of themselves. Standard window controls such as edit controls or list boxes do not require a canvas, as they are drawn by the system.&lt;br /&gt;&lt;br /&gt;TCanvas provides properties, events and methods that assist in creating an image by&lt;br /&gt;。Specifying the type of brush, pen and font to use.&lt;br /&gt;。Drawing and filling a variety of shapes and lines.&lt;br /&gt;。Writing text.&lt;br /&gt;。Rendering graphic images.&lt;br /&gt;。Enabling a response to changes in the current image.&lt;br /&gt;&lt;br /&gt;TCanvas has two descendants, TControlCanvas and TMetafileCanvas, which assist in drawing images of controls and in creating metafile images for objects.&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179616223432730?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179616223432730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcanvas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179616223432730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179616223432730'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcanvas.html' title='TCanvas'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116179544346220270</id><published>2006-10-06T03:45:00.000+08:00</published><updated>2007-12-20T13:56:55.616+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><title type='text'>TColor type</title><content type='html'>TColor is used to specify the color of an object.&lt;br /&gt;&lt;blockquote&gt; &lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;Graphics&lt;br /&gt;&lt;br /&gt;enum TColor {clMin=-0x7fffffff-1, clMax=0x7fffffff};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;TColor is used to specify the color of an object. It is used by the Color property of many components and by a number of other properties that specify color values.&lt;br /&gt;&lt;br /&gt;The Graphics unit contains definitions of useful constants for TColor. These constants map either directly to the closest matching color in the system palette (for example, clBlue maps to blue) or to the corresponding system screen element color defined in the Color section of the Windows Control panel (for example, clBtnFace maps to the system color for button faces).&lt;br /&gt;&lt;br /&gt;If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit, the low three bytes represent RGB color intensities for blue, green, and red, respectively. The value 0x00FF0000 represents full-intensity, pure blue, 0x0000FF00 is pure green, and 0x000000FF is pure red. 0x00000000 is black and 0x00FFFFFF is white.&lt;br /&gt;&lt;br /&gt;If the highest-order byte is zero (0x00), the color obtained is the closest matching color in the system palette. If the highest-order byte is one (0x01), the color obtained is the closest matching color in the currently realized palette. If the highest-order byte is two (0x02), the value is matched with the nearest color in the logical palette of the current device context. &lt;/blockquote&gt; 注意: TColor 本身已經是一個最底層的資料型態了, 本身是一個 enum 的型態, 長度為 4 個位元組(bytes) 的整數。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116179544346220270?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116179544346220270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcolor-type.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179544346220270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116179544346220270'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/10/tcolor-type.html' title='TColor type'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180087842143140</id><published>2006-09-29T09:37:00.001+08:00</published><updated>2008-03-25T13:04:07.465+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW: 取得視訊裝置驅動程式的資訊</title><content type='html'>任何一個電腦週邊硬體裝置安裝時, 作業系統必須要能與硬體裝置溝通, 我們把溝通媒介稱為驅動程式 ( &lt;a taregt="blank" href="http://en.wikipedia.org/wiki/Device_driver"&gt;device driver&lt;/a&gt; )。電腦與周邊裝置的溝通必需透過特定介面傳送資料, 傳送的資料也必須符合特定格式, 驅動程式可以認得傳送的資料為何, 就可以驅動硬體裝置執行電腦所派達的命令。&lt;br /&gt;&lt;br /&gt;我們可以透過 capGetDriverDescription 這個函數, 讓應用程式知道你所使用的視訊裝置驅動程式相關資訊。如果你在  &lt;a href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/vfw.h" target="blank"&gt;vfw.h&lt;/a&gt; 中搜尋, 你可以在 line  3618 找到底下這段定義與函數的宣告。&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;BOOL VFWAPI capGetDriverDescriptionA (UINT wDriverIndex,&lt;br /&gt;          LPSTR lpszName, int cbName,&lt;br /&gt;                     LPSTR lpszVer, int cbVer);&lt;br /&gt;&lt;br /&gt;BOOL VFWAPI capGetDriverDescriptionW (UINT wDriverIndex,&lt;br /&gt;          LPWSTR lpszName, int cbName,&lt;br /&gt;          LPWSTR lpszVer, int cbVer);&lt;br /&gt;&lt;br /&gt;#ifdef UNICODE&lt;br /&gt;           #define capCreateCaptureWindow  capCreateCaptureWindowW&lt;br /&gt;      #define capGetDriverDescription capGetDriverDescriptionW&lt;br /&gt;#else&lt;br /&gt;           #define capCreateCaptureWindow  capCreateCaptureWindowA&lt;br /&gt;           #define capGetDriverDescription capGetDriverDescriptionA&lt;br /&gt;#endif &lt;/blockquote&gt; /* 說明:&lt;br /&gt;1. 有關 #ifdef 的 C 前置處理的部份, 請參考 &lt;a href="http://nknucc.nknu.edu.tw/%7Ejwu/c/cpgch8.htm" target="blank"&gt;http://nknucc.nknu.edu.tw/~jwu/c/cpgch8.htm&lt;/a&gt;&lt;br /&gt;2. capGetDriverDescriptionA 函數的傳回值為 BOOL ( 布林值, &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;false&lt;/span&gt; ) , 傳入值一共有 5 個分別如下:&lt;br /&gt;     UINT wDriverIndex,  指定要取得的視訊裝置編號。( 你要先告訴人家要取得哪一個視訊裝置的相關資訊! )&lt;br /&gt;           LPSTR lpszName,   取得驅動程式的名稱後, 要儲存到哪一個字串給你知道呢?&lt;br /&gt;                              &lt;span style="color: rgb(255, 0, 0);"&gt;( 注意: 這邊傳入的是這個字串的指標! )&lt;/span&gt;&lt;br /&gt;           int cbName,                指定存放驅動程式名稱的字串的大小。&lt;br /&gt;     LPSTR lpszVer,        取得驅動程式的版本後, 存放在這個字串中。&lt;br /&gt;     int cbVer,                    指定存放驅動程式版本的字串的大小。&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;範例程式:&lt;br /&gt;long dwDriverIndex;&lt;br /&gt;char szDeviceName[80];              // Driver Name&lt;br /&gt;char szDeviceVersion[80];           // Driver Version&lt;br /&gt;&lt;br /&gt;dwDriverIndex = 0;&lt;br /&gt;if (capGetDriverDescription(dwDriverIndex, szDeviceName, sizeof(szDeviceName),&lt;br /&gt;      szDeviceVersion, sizeof(szDeviceVersion)))&lt;br /&gt;              {&lt;br /&gt;     lblCapDriverName-&gt;Caption = szDeviceName;&lt;br /&gt;     lblCapDriverVer-&gt;Caption = szDeviceVersion;&lt;br /&gt;     }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180087842143140?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180087842143140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/vfw.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180087842143140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180087842143140'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/vfw.html' title='VFW: 取得視訊裝置驅動程式的資訊'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180098823420896</id><published>2006-09-28T17:52:00.002+08:00</published><updated>2011-02-28T23:34:07.950+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vfw'/><title type='text'>VFW.H</title><content type='html'>&lt;a target="blank" href="http://en.wikipedia.org/wiki/Video_for_Windows"&gt;Video For Windows&lt;/a&gt; ( VFW ) 是 Microsoft 於 1992 年所推出, 針對多媒體視訊的應用程式開發介面 ( &lt;a target="blank" href="http://en.wikipedia.org/wiki/Application_programming_interface"&gt;Application Programming Interface&lt;/a&gt; , API )。只要本身有支援 VFW 的硬體裝置, 都可以透過 VFW SDK ( &lt;a target="blank" href="http://en.wikipedia.org/wiki/SDK"&gt;Software Development Kit&lt;/a&gt; ) 來控制, 並開發出有關音訊、視訊的多媒體處理軟體。&lt;br /&gt;&lt;br /&gt;在 BCB 的目錄( C:\Program Files\Borland\CBuilder6\ ) 中, 你可以在 Include 子目錄裏找到 &lt;a target="blank" href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/vfw.h"&gt;vfw.h&lt;/a&gt; 這個 &lt;a target="blank" href="http://en.wikipedia.org/wiki/Header_file"&gt;header file&lt;/a&gt;, 當我們在 BCB 中要使用 VFW SDK 所提供的函數時, 就要將下面一行指令加入到程式的最前面。&lt;br /&gt;&lt;br /&gt;#include &amp;lt;vfw.h&amp;gt;&lt;br /&gt;　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180098823420896?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180098823420896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/vfwh.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180098823420896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180098823420896'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/vfwh.html' title='VFW.H'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180130480176075</id><published>2006-09-26T01:10:00.000+08:00</published><updated>2006-10-26T02:35:04.803+08:00</updated><title type='text'>Objects</title><content type='html'>An object is a specific region of memory that can hold a fixed or variable value (or set of values). (This use of the word object is different from the more general term used in object-oriented languages.) Each value has an associated name and type (also known as a data type). The name is used to access the object. This name can be a simple identifier, or it can be a complex expression that uniquely references the object. The type is used&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      to determine the correct memory allocation required initially.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      to interpret the bit patterns found in the object during subsequent accesses.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      in many type-checking situations, to ensure that illegal assignments are trapped.&lt;/li&gt;&lt;/ul&gt; C++Builder supports many standard (predefined) and user-defined data types, including signed and unsigned integers in various sizes, floating-point numbers in various precisions, structures, unions, arrays, and classes. In addition, pointers to most of these objects can be established and manipulated in memory.&lt;br /&gt;&lt;br /&gt;The C++Builder standard libraries and your own program and header files must provide unambiguous identifiers (or expressions derived from them) and types so that C++Builder can consistently access, interpret, and (possibly) change the bit patterns in memory corresponding to each active object in your program.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; Objects and declarations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Declarations establish the necessary mapping between identifiers and objects. Each declaration associates an identifier with a data type. Most declarations, known as defining declarations, also establish the creation (where and when) of the object; that is, the allocation of physical memory and its possible initialization. Other declarations, known as referencing declarations, simply make their identifiers and types known to the compiler. There can be many referencing declarations for the same identifier, especially in a multifile program, but only one defining declaration for that identifier is allowed.&lt;br /&gt;&lt;br /&gt;Generally speaking, an identifier cannot be legally used in a program before its declaration point in the source code. Legal exceptions to this rule (known as forward references) are labels, calls to undeclared functions, and class, struct, or union tags.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180130480176075?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180130480176075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/objects.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180130480176075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180130480176075'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/objects.html' title='Objects'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180155244888510</id><published>2006-09-25T13:44:00.000+08:00</published><updated>2006-10-26T02:39:45.186+08:00</updated><title type='text'>TPicture</title><content type='html'>TPicture contains a bitmap, icon, metafile graphic, or user-defined graphic.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hierarchy&lt;br /&gt;&lt;/span&gt;TObject - TPersistent - TInterfacedPersistent - TPicture&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;Graphics&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;TPicture is a TGraphic container, used to hold a graphic, the type of which is specified in the Graphic property. It is used in place of a TGraphic if the graphic can be of any TGraphic class. LoadFromFile and SaveToFile are polymorphic. For example, if the TPicture is holding an Icon, it is valid to LoadFromFile a bitmap file, where the class TIcon can only read .ICO files.&lt;br /&gt;&lt;br /&gt;If the TPicture contains a bitmap graphic, the Bitmap property specifies the graphic. If the TPicture contains an icon graphic, the Icon property specifies the graphic. If the TPicture contains a metafile graphic, the Metafile property specifies the graphic.&lt;br /&gt;&lt;br /&gt;The properties of TPicture indicate the type of graphic that the picture object contains, and its size. The methods of TPicture are used to load, save, and manipulate graphics.&lt;br /&gt;&lt;br /&gt;To load or save a picture to the Clipboard, use the Assign method of a TClipboard object.&lt;br /&gt;&lt;br /&gt;To draw a picture on a canvas, call the Draw or StretchDraw methods of a TCanvas object, passing the Graphic property of a TPicture as a parameter.&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180155244888510?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180155244888510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/tpicture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180155244888510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180155244888510'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/tpicture.html' title='TPicture'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180183379478864</id><published>2006-09-25T13:36:00.000+08:00</published><updated>2006-10-26T02:43:53.796+08:00</updated><title type='text'>TImage</title><content type='html'>TImage displays a graphical image.&lt;br /&gt;&lt;blockquote&gt;  &lt;span style="font-weight: bold;"&gt;Hierarchy&lt;br /&gt;&lt;/span&gt;TObject - TPersistent - TComponent - TControl - TGraphicControl - TImage&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unit&lt;/span&gt;&lt;br /&gt;ExtCtrls&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description&lt;/span&gt;&lt;br /&gt;Use TImage to display a graphical image on a form. Use the &lt;a target="blank" href="http://leebcb.blogspot.com/2006/09/tpicture.html"&gt;TPicture&lt;/a&gt; object in the Picture property to specify the actual bitmap, icon, metafile, or other graphic object displayed by TImage. Properties and methods of TPicture can be used for such things as loading an image from file, clearing the image in the TImage, and assigning an image for another control. TImage introduces several properties to determine how the image is displayed within the boundaries of the TImage object.&lt;br /&gt;&lt;br /&gt;To add an image to a form or data module so that it is available for display by other controls, such as action lists and bitmap buttons, use a TImageList control instead. &lt;/blockquote&gt; 如果要在 form 中顯示一張影像, 就必須要用到 Image 元件, 可以從 TImage 類別的 Help 資料著手, 了解 BCB 對於顯示影像是如何運作的。在 Image 元件中, 有一個屬性 ( property ) 稱為 Picture, 其型態原型為 &lt;a href="http://leebcb.blogspot.com/2006/09/tpicture.html" target="blank"&gt;TPicture&lt;/a&gt;, 是用來儲存影像資料的地方。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180183379478864?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180183379478864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/timage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180183379478864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180183379478864'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/timage.html' title='TImage'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180195512422943</id><published>2006-09-25T01:27:00.001+08:00</published><updated>2008-09-25T23:17:08.727+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>Component Palette</title><content type='html'>&lt;img alt="" src="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/ComponentPalette.jpg" vspace="10" width="545" border="0" height="55" hspace="5" /&gt;&lt;br /&gt;BCB 的核心除了以 C++ 程式語言為基礎之外, 最重要的就是 &lt;a href="http://leebcb.blogspot.com/2006/09/visual-component-library-vcl.html" target="blank"&gt;Visual Component Library&lt;/a&gt; 了。BCB 把在視窗應用程式 ( window application ) 中常用的一些功能, 包裝成一個個的元件 ( component ), 這些元件通通被放到上圖的 Component Palette 中, 由於元件太多了, 因此 BCB 用分頁選單的方式, 將性質相近的元件放到同一個標籤頁中, 方便我們使用。&lt;br /&gt;&lt;br /&gt;&lt;img src="http://eclips.cornell.edu/images/icons/palette.jpg" alt="" vspace="5" width="150" align="left" border="0" height="120" hspace="5" /&gt;你可以比較出畫家用的調色盤 ( palette ) 和 BCB 中的 component palette 之間的異同嗎?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180195512422943?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180195512422943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/component-palette.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180195512422943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180195512422943'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/component-palette.html' title='Component Palette'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180209705255943</id><published>2006-09-24T21:32:00.000+08:00</published><updated>2007-12-20T13:44:50.443+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>Visual Component Library (VCL)</title><content type='html'>視覺化元件程式庫( &lt;a href="http://en.wikipedia.org/wiki/Visual_Component_Library" target="blank"&gt;Visual Component Library&lt;/a&gt;, VCL ) 是 &lt;a href="http://www.borland.com/tw/" target="blank"&gt;Borland&lt;/a&gt; 所發展出來的, 包含 Objects, Components, Routines, Types, Constants and Variables 等五大部分。底下的說明是從 Borland C++ Builder Help 所寫的說明文字。&lt;br /&gt;&lt;blockquote&gt; &lt;span style="font-weight: bold;"&gt;Objects&lt;/span&gt;&lt;br /&gt;An object consists of methods, and in many cases, properties, and events. Properties represent the data contained in the object. Methods are the actions the object can perform. Events are conditions the object can react to. All objects descend from the ancestor object TObject.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Components&lt;/span&gt;&lt;br /&gt;Components are visual objects that you can manipulate at design time. All components descend from TComponent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Routines&lt;/span&gt;&lt;br /&gt;Global routines are the procedures and functions from the runtime library and from the VCL. These routines are not part of a class, but can be called either directly or from within class methods.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Types&lt;/span&gt;&lt;br /&gt;The types described in the Help are used as return types and parameter types for object methods, properties and events, and for global routines. In many cases, types are documented in the entry for the method, property, event or global routine in which they are used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Constants and Variables&lt;/span&gt;&lt;br /&gt;The constants and variables defined in the Help are declared in the runtime library and in the VCL. Some of these are instantiations of objects. Examples are the Application and Screen variables. Others represent routines that provide the underlying implementation of other methods or global routines. Examples include the AnsiResemblesProc and RegisterComponentsProc variables. Still other variables and constants represent information that can vary with the system or platform, such as the DateSeparator variable and PathDelim constant.&lt;br /&gt;&lt;/blockquote&gt; &lt;a href="http://www.borland.com/tw/products/cbuilder/index.html" target="blank"&gt; Borland C++ Builder&lt;/a&gt; 是 Borland 針對 C++ 程式語言所開發的快速應用程式開發工具 ( &lt;a href="http://en.wikipedia.org/wiki/Rapid_application_development" target="blank"&gt;Rapid Application Development&lt;/a&gt;, RAD ), Borland 為 C++ 加入了許多的視覺化元件, 配合整合開發環境 ( &lt;a href="http://en.wikipedia.org/wiki/Integrated_development_environment" target="blank"&gt;Integrated Development Environment&lt;/a&gt;, IDE ), 推出了 Borland C++ Builder 這個產品, 加速了一個視窗應用程式的開發。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180209705255943?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180209705255943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/visual-component-library-vcl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180209705255943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180209705255943'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/visual-component-library-vcl.html' title='Visual Component Library (VCL)'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180217650837173</id><published>2006-09-13T00:16:00.002+08:00</published><updated>2011-11-09T21:43:30.200+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>動態宣告二維陣列</title><content type='html'>寫程式時, 『變數宣告』指的是請作業系統分配 (allocate) 一塊大小合適的記憶體, 讓我們作為儲存資料之用。因此, 我們必須告訴作業系統, 我們要儲存的資料是什麼型態, 然後, 根據程式設計師所提供的變數型態, 作業系統就會知道該分配多大的記憶體給我們使用。因此, 變數宣告通常會寫在程式的最前面, 希望程式一開始執行時, 就把需要用到的記憶體通通分配好。&lt;br /&gt;&lt;br /&gt;標題中『動態宣告』指的是當程式設計師在寫程式時, 並無法確實知道程式在執行時需要用的多大的記憶體, 必須等到程式真正執行時(run time), 才會知道確實的大小。為了解決這樣的問題, 就必須允許程式設計師在執行程式時, 才臨時去宣告, 要求分配記憶體, 這就是『動態』兩個字的意義由來。&lt;br /&gt;&lt;br /&gt;用二維陣列來儲存數位影像是非常直覺的想法, 不過, 需要用動態宣告方式的原因則是因為我們不知道要事先宣告一個多大的二維陣列才夠儲存你所開啟的影像。這邊就是要介紹 BCB 中, 要動態宣告一個二維陣列的作法。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; #include  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;iostream.h&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt; &lt;iostream.h&gt;&lt;/iostream.h&gt;&lt;/span&gt;&lt;br /&gt;//  注意: 必須加入這一行到程式最前面, 否則我們後面用到的 std::bad_alloc 會沒有定義&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; unsigned char **ucMatrix;&lt;/span&gt;&lt;br /&gt;/* 說明:&lt;br /&gt;1. ucMatrix 就是我們要宣告的二維陣列的名稱, 為了讓我們在寫程式時, 一看到這個名稱就知道其資料型態為何, 我們在名稱之前加入了小寫的 uc, 代表 unsigned char 的縮寫,&lt;br /&gt;2. 這邊用 unsigned char 當例子的原因是影像的色彩值範圍為 0 ~ 255, 剛好就是 unsigned char 可以表示的數值範圍。&lt;br /&gt;3. 名稱之前, 我們放了兩個 star 符號 ( ** ), 就是要告訴 BCB 的編譯器, 這個名稱本身是一個指到二維陣列的名稱。&lt;br /&gt;結束說明 */&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;br /&gt;int iImageHeight=0, iImageWidth=0;&lt;/span&gt;&lt;br /&gt;// 說明: 這兩個變數是用來儲存影像 ( image ) 的高 ( height ) 與寬 ( width ) 的, 至於變數名稱最前面的小寫 i, 也是用來指出其資料型態為 int&lt;br /&gt;&lt;br /&gt;　try&lt;br /&gt;　　{&lt;br /&gt;　　ucMatrix = new unsigned char *[iImageHeight];&lt;br /&gt;　　for (j=0;j&amp;lt;iImageHeight;j++)&lt;br /&gt;　　　ucMatrix[j] = new unsigned char [iImageWidth];&lt;br /&gt;　　}&lt;br /&gt;　catch (std::bad_alloc)&lt;br /&gt;　　{&lt;br /&gt;　　ShowMessage("Could not allocate memory...Bye");&lt;br /&gt;　　exit(-1);&lt;br /&gt;　　}&lt;br /&gt;　&lt;br /&gt;/* 說明:&lt;br /&gt;1. 如果有一段程式 ( 用大括號 {}, 括起來) 有可能發生一些特殊例外的情況, 以上面的例子來說,  要求系統給予一塊記憶體, 在一般情況下, 這段程式可以順利要到記憶體繼續執行; 可是, 當系統已經沒有多餘的記憶體分配給你的時候, 程式該怎麼辦呢? 這種情況就是可能發生的例外情況。在 C++ (BCB) 中, 你可以將這段程式碼的前面加上 &lt;span style="font-weight: bold;"&gt;try&lt;/span&gt; 這個 keyword, 讓系統知道可能會發生例外情況, 需要例外處理程序支援。&lt;br /&gt;2. 至於不同的例外情況, 要做不同的例外處理, 我們必須用 &lt;span style="font-weight: bold;"&gt;catch &lt;/span&gt;這個 keyword 來加以分別。以我們的例子來說, 當發生了 std::bad_alloc 這種情況時, 請秀出 "Could not allocate memory... Bye" 字串, 然後程式結束 exit(-1);&lt;br /&gt;3. &lt;span style="font-weight: bold;"&gt;new&lt;/span&gt; 就是提供動態記憶體配置 (dynamic storage allocation) 的指令。如果成功配置到記憶體, &lt;span style="font-weight: bold;"&gt;new&lt;/span&gt; 這個 operator 就會傳回一個指標 (pointer), 指向所配置到的記憶體位置。如果失敗了, &lt;span style="font-weight: bold;"&gt;new&lt;/span&gt; operator 就會呼叫 new_handler 函數。這個函數內定的處理方式就是指出發生了一個 bad_alloc 的例外情況。然後再由程式設計師透過例外處理指令 &lt;span style="font-weight: bold;"&gt;catch&lt;/span&gt; 來接手該如何處理這個例外情況。&lt;br /&gt;4. 由於我們要宣告的是一個二維陣列, 因此整個步驟分成兩部份, 首先要求配置 iImageHeight 個一維陣列的指標, 每一個指標都是指向一個資料型態為 unsigned char 的變數。如果成功了, 就將這個陣列的指標存到 ucMatrix 這個變數中。接著, 再利用&lt;span style="font-weight: bold;"&gt;for&lt;/span&gt; 迴圈要求 iImageHeight 個陣列, 每個陣列都有 iImageWidth 個元素 (elements), 每一個元素的資料型態都是 unsigned char。&lt;br /&gt;結束說明 */&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;注意:&lt;/span&gt; 上述程式為了程式的可讀性, 用了全型的空白"　"來控制部落格文章的內縮顯示。因此, 如果你要直接複製上述程式到 C++ Builder 執行, 請務必將全型空白"　"改成半型空白" ", 否則, 編譯時發出現以下的錯誤訊息。:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt; [C++ Error] Unit1.cpp(40): E2206 Illegal character '　' (0xa140)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180217650837173?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180217650837173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180217650837173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180217650837173'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/blog-post.html' title='動態宣告二維陣列'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180347043237013</id><published>2006-09-11T16:18:00.000+08:00</published><updated>2007-12-20T13:42:40.753+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>開啟 JPEG 影像</title><content type='html'>&lt;a target="blank" href="http://www.borland.com/tw/products/cbuilder/index.html"&gt;BCB&lt;/a&gt; Professional 版本並不提供直接開啟 JPEG 影像的功能, 要開啟 JPEG 影像, 要自己寫 JPEG 的 decoder, 這個有點難度, 不然就是直接上網找別人寫的程式, 弄懂後, 想辦法和自己的程式結合起來。不過, 如果是 BCB Enterprise 版本, 要開啟 JPEG 影像就容易多了, 只要在程式最前面宣告的部份, 加入:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;#include "jpeg.hpp"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;至於其他的步驟, 則都和 &lt;a target="blank" href="http://www.wretch.cc/blog/yklee&amp;amp;article_id=4366887"&gt;開啟 BMP 影像&lt;/a&gt; 相同。&lt;br /&gt;&lt;br /&gt;如果你想要看看 jpeg.hpp 這個檔案的內容, 你可以在&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; C:\Program Files\Borland\CBuilder6\Include\Vcl\ &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;這個目錄中找到這個檔案。如果你沒有安裝 BCB Enterprise 版, 你可以按這邊 &lt;a href="http://www.csie.mcu.edu.tw/%7Eyklee/Blog/BCB/jpeg.hpp" target="blank"&gt;一賭為快&lt;/a&gt;。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180347043237013?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180347043237013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/jpeg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180347043237013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180347043237013'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/jpeg.html' title='開啟 JPEG 影像'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-116180354825999638</id><published>2006-09-11T15:12:00.001+08:00</published><updated>2011-03-22T09:57:01.877+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='basic'/><title type='text'>開啟與儲存 BMP 影像</title><content type='html'>在 &lt;a href="http://www.borland.com/tw/products/cbuilder/index.html" target="blank"&gt;BCB&lt;/a&gt; 中, 要寫程式開啟一張 BMP 影像, 非常的簡單, 主要步驟有二:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; 1. 利用 OpenPictureDialog1-&gt;Execute() 來選定你所希望開啟的影像。&lt;/span&gt;&lt;br /&gt; OpenPictureDialog 這個對話方塊專門設計用來開啟一張影像的, Execute() 這個method 並不需要任何的傳入值, 當我們用對話視窗選定一個影像檔後, 則會傳回一個 boolean 值 ( &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;false)&lt;/span&gt;, 來表示是否執行成功。如果傳回值是 &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;, Execute() 就會把你所選擇的檔案名稱 (包刮路徑), 存在FileName 這個字串中。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; 2. 再利用 Image1-&gt;Picture-&gt;LoadFromFile(OpenPictureDialog1-&gt;FileName) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;    將影像顯示到 Image1 這個影像物件中。&lt;/span&gt;&lt;br /&gt; LoadFromFile 這個 method 的輸入值就是你要開啟的路徑與檔案名稱。&lt;br /&gt;&lt;br /&gt;同樣地, 要將影像物件的內容儲存成 BMP 影像檔案, 也是有兩個步驟:&lt;br /&gt;&lt;br /&gt;1. &lt;span style="color: rgb(0, 0, 255);"&gt;利用 SavePictureDialog1-&gt;Execute() 來選定你所希望開啟的影像。&lt;br /&gt;&lt;br /&gt;2. &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;利用 Image1-&gt;Picture-&gt;SaveToFile(SavePictureDialog1-&gt;FileName) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;    　&lt;span style="color: rgb(0, 0, 0);"&gt;將影像內容儲存成檔名為&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; SavePictureDialog1-&gt;FileName 的 BMP 檔案中&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;。&lt;br /&gt;　&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-116180354825999638?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/116180354825999638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/09/bmp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180354825999638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/116180354825999638'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/09/bmp.html' title='開啟與儲存 BMP 影像'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-36592004.post-4299884578897056663</id><published>2006-05-28T20:55:00.000+08:00</published><updated>2007-04-20T11:10:11.203+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data type'/><title type='text'>tagPOINT type</title><content type='html'>tagPOINT 是一個結構型資料型態, 剛剛費了一點力氣把原始宣告的程式碼從&lt;br /&gt;&lt;br /&gt;C:\Program Files\Borland\CBuilder6\Include\Vcl\&lt;br /&gt;&lt;br /&gt;中給找出來, 我是在 types.hpp 這個檔案中找到宣告的程式碼的:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; struct TPoint : public POINT&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;TPoint() {}&lt;br /&gt;TPoint(int _x, int _y) { x=_x; y=_y; }&lt;br /&gt;TPoint(POINT&amp; pt)  { x = pt.x; y = pt.y; }&lt;br /&gt;};&lt;br /&gt;typedef TPoint  &lt;span style="color: rgb(255, 0, 0);"&gt;tagPoint&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;也就是說, 由於 BCB 透過 vcl.h 將這段程式碼放到程式的開頭, 所以我們寫程式時, 只要前面有加上&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;#include &amp;lt; vcl.h &amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;就可以使用這個 tagPOINT 資料型態了。&lt;br /&gt;&lt;br /&gt;但, 要怎麼使用呢?&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 102);"&gt;宣告部份:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;tagPOINT ptCurrent;&lt;/span&gt;&lt;br /&gt;/* 當滑鼠的位置點在 (X, Y) 時, 我們就可以把這個座標存到 ptCurrent 這個變數之中。*/&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 102);"&gt;程式部份:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;ptCurrent.x = X;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;ptCurrent.y = Y;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;同學們可以先試試使用 tagPOINT 這個資料型態, 然後嘗試把 tagPOINT 與 stack 的用法結合起來。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36592004-4299884578897056663?l=leebcb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://leebcb.blogspot.com/feeds/4299884578897056663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://leebcb.blogspot.com/2006/05/tagpoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4299884578897056663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36592004/posts/default/4299884578897056663'/><link rel='alternate' type='text/html' href='http://leebcb.blogspot.com/2006/05/tagpoint.html' title='tagPOINT type'/><author><name>YKLee</name><uri>http://www.blogger.com/profile/18064709962112077522</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://www.csie.mcu.edu.tw/~yklee/YK2006s.jpg'/></author><thr:total>0</thr:total></entry></feed>
