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即可。

搜尋此網誌