2011年4月8日 星期五

BCB TStringGrid之ScrollBar自動捲動方式

在BCB中若要使TStringGrid程式控制上下捲動,我在網路上找了很久,可用下列function來達成

SendMessage(TStringGrid->Handle, WM_VSCROLL, SB_LINEDOWN, 0);

主要可變動的參數式SB_LINEDOWN,有以下選擇



SB_BOTTOM 
  Scrolls   to   the   lower   right. 
SB_ENDSCROLL 
  Ends   scroll. 
SB_LINEDOWN 
  Scrolls   one   line   down. 
SB_LINEUP 
  Scrolls   one   line   up. 
SB_PAGEDOWN 
  Scrolls   one   page   down. 
SB_PAGEUP 
  Scrolls   one   page   up. 
SB_THUMBPOSITION 
  The   user   has   dragged   the   scroll   box   (thumb)   and   released   the   mouse   button.   The   high-order   word   indicates   the   position   of   the   scroll   box   at   the   end   of   the   drag   operation. 
SB_THUMBTRACK 
  The   user   is   dragging   the   scroll   box.   This   message   is   sent   repeatedly   until   the   user   releases   the   mouse   button.   The   high-order   word   indicates   the   position   that   the   scroll   box   has   been   dragged   to. 
SB_TOP 
  Scrolls   to   the   upper   left.

2011年4月6日 星期三

在BCB中之ComPort 設定

來源網址 

找了很久才找到的解法~

在BCB 6.0中,若使用ComPort 4.11,設定Port時所遇到的問題。
錯誤訊息大致如下

unresolved external ...fastcall SetPortA...

而錯誤的程式碼如下

ComPort->Port = "COM8";

解決方式就是修改
C:\Program Files\Borland\CBuilder6\Include\winspool.h

在此檔案找到下面內容


BOOL

WINAPI

SetPortA(

IN LPSTR     pName,

IN LPSTR     pPortName,

IN DWORD       dwLevel,

IN LPBYTE      pPortInfo

);

BOOL

WINAPI

SetPortW(

IN LPWSTR     pName,

IN LPWSTR     pPortName,

IN DWORD       dwLevel,

IN LPBYTE      pPortInfo

);

#ifdef UNICODE

#define SetPort  SetPortW

#else

#define SetPort  SetPortA

#endif // !UNICODE

然後在頭尾分別加上

#ifdef DONT_USE_WINSPOOL_SETPORTA


#endif //!DONT_USE_WINSPOOL_SETPORTA
成為

#ifdef DONT_USE_WINSPOOL_SETPORTA
SetPortA(
...
...
#endif // !UNICODE
#endif //!DONT_USE_WINSPOOL_SETPORTA
存檔後,重新compile即可。

2011年2月12日 星期六

在Ubuntu上安裝Qt之基本lib pkg


在configure Qt之前最好先安裝以下pkg


sudo apt-get install libX11-dev libXext-dev libXtst-dev libxrender-dev

2011年2月8日 星期二

[轉貼]How to set timer in mfc dialog?



原文網址

重點
1. 主程式 .cpp 裡要有ON_WM_TIMER()
// Message Map
BEGIN_MESSAGE_MAP(CDlgDlg, CDialog)
    ...
    ON_WM_TIMER()
END_MESSAGE_MAP()
2.  要在.h 裡宣告OnTimer( UINT nIDEvent),此為Default callback function
// Timer Handler.
void CDlgDlg::OnTimer( UINT nIDEvent )

3. 設定timer可指定ID (即此timer的event ID),藉以在收到多個timers時區分
// Timer Handler.
    SetTimer( ID_TIMER_MINUTE, 60 * 1000, 0 );
    SetTimer( ID_TIMER_SECONDS, 1000, 0 );)
4. timer單位mini sec

2011年1月27日 星期四

Enable Ctrl-Alt-Del log-in window in Windows 7

Go to the old Start button, now just a Windows logo. In the search box, type netplwiz and press enter or click on the result.

2011年1月20日 星期四

[轉貼] Ubuntu 安裝 黑屏問題


在HP TouchSmart tm2 機器上嘗試安裝Ubuntu,安裝過程中出現黑屏之解決方式 


黑屏情況
用CD開機(or USB)的時候,進入選單安裝時即黑屏 或 載入安裝資料後即黑屏

以下是我的情況(參照原文網址的解法)


ubuntu安裝
1.開機後,一出現畫面時按鍵盤任一鍵,使ubuntu的安裝選單畫面出來
2.選完語言後再用上下鍵移動光條選到安裝的選項, 然後按下F6鍵, 勾選nomodeset,再按esc跳出來.
3.這個時候螢幕下方會有一行"開機選項",後面跟著一串能編輯的文字, 請找到"quite splash --",
並在splash這個字之後空一格, 輸入xforcevesa
4.按enter繼續執行試用或安裝.



安裝完系統,重開機,進入選單時
按e編輯選單
一樣找到"quite splash " 在後面加上 nomodeset xforcevesa 
然後按ctrl+x開機


進入系統後
打開Terminal
輸入sudo su,切換到root權限
cd /boot/grub
cp grub.cfg grub.cfg.bk
vi grub.cfg.bk
使用vi搜尋 quiet splash
一樣在後面加入 nomodeset xforcevesa
存檔後離開vi
最後把剛剛編輯的grub.cfg.bk覆蓋掉系統的grub.cfg檔
cp grub.cfg.bk grub.cfg
reboot
即可!

2010年7月21日 星期三

Ubuntu 之 光碟機掛載

Ubuntu用到現在,今天才發現我的光碟機沒有被自動掛載.....=.=

於是上網找了一下解決方法

首先先查看你的硬體是否有備偵測到,利用下面的指令
lshw -C disk

2010年7月7日 星期三

Ubuntu 之 /dev/video0 not found 問題

由於工作的需要,必須在ubuntu上開啟webcam,但不幸的是我用的8.10或10.04上都無法開啟,因此就開始在網路上尋找解決方法,找了好幾天,試過安裝uvcvideo, cheese 等等的webcam app,系統也更新到最新的patch,還是無法開啟,app始終提示 /dev/video0 not found,gstreamer-properties一樣無法找到/dev/video0。後來到/dev下看video0是否存在,也如預期的不存在....=.=,但是幸好lsusb查看,有看到我的webcam device。

在這說一下我的環境,VAIO SZ58, Ubuntu 10.04 TL, 內建的webcame是 Ricoh Co., Ltd Visual Communication Camera VGP-VCC7 [R5U870]

後來知道video0不存在後,開始往driver的方向找答案,總算在今天被我找到,在Ubuntu Forum 這篇討論區有說討論。安裝下面兩個deb

http://download.tuxfamily.org/arakhne/pool/r/ricoh-webcam-r5u870/ricoh-webcam-r5u870-firmware_0.11.4-0arakhne1_i386.deb
http://download.tuxfamily.org/arakhne/pool/r/ricoh-webcam-r5u870/ricoh-webcam-r5u870_0.11.4-0arakhne1_i386.deb

安裝完後,/dev/video0 終於出現了!!

2010年7月1日 星期四

Qt 之 connect 的 error

Qt signal 與 slot 的 connect所傳遞的參數必須要系統能夠識別,否則在run的時候會出現類似下列訊息(compile 不會有錯誤),並且所對應的slot不會被呼叫。
QObject::connect: Cannot queue arguments of type 'CmdSeq'
(Make sure 'CmdSeq' is registered using qRegisterMetaType().)
(CmdSeq是我自己建立的class,無繼承任何class)

搜尋此網誌