全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2268
推到 Plurk!
推到 Facebook!

TImage的問題

尚未結案
mnsf
初階會員


發表:104
回覆:90
積分:48
註冊:2003-11-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-15 17:56:49 IP:61.30.xxx.xxx 未訂閱
請教各位大大 Image1.Canvas.Polygon()的參數只允許輸入整數型態 但因為需求的關係,必須使用到符點數(可以畫出更精確的矩形) 請問有什麼其他屬性可以畫出座標為符點數的矩形嗎?? 或許有其他元件可以做到的??請各位大大賜教.....
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-15 18:08:56 IP:61.221.xxx.xxx 未訂閱
[Arc - 在繪圖物件上畫弧線] 語法: (1).宣告 Declare Function Arc Lib "gdi32" Alias "Arc" ( ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long ◎hdc:某個設備環境的handle值。 ◎(X1,Y1):繪圖範圍在XY軸上的起始值。 ◎(X2,Y2):繪圖範圍在XY軸上的末值。 ◎(X3,Y3):弧線在XY軸上的開始值。 ◎(X4,Y4):弧線在XY軸上的末值。 (2).呼叫 Call Arc (hdc, X1, Y1, X2, Y2, X3, Y3, X4, Y4) 範例: ' 在點(0,0)與點(100,200)繪圖範圍內,畫出一個 ' 從點(45,25)開始到點(80,180)結束的弧線。 Private Sub Form_Click() Call Arc (Form1.hdc, 0, 0, 100, 200, 45, 25, 80, 180) End Sub [AddFontResource - 加入新的字型檔] 語法: (1).宣告 Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long ◎lpFileName:字型檔的檔案路徑。 ◎注意: 需加入下列這一行,才能使Windows內部字型資料庫更新,之後才能引用。 Const HWND_BROADCAST = &HFFFF& Const WM_FONTCHANGE = &H1D Call SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) (2).呼叫 Call AddFontResource ( lpFileName ) 範例: Const HWND_BROADCAST = &HFFFF& Const WM_FONTCHANGE = &H1D Private Sub Command1_Click() Call AddFontResource ( "C:\文鼎中行書.TTF" ) Call SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) Label1.FontName = "文鼎中行書" End Sub [BitBlt - 複製DC內的圖形至另一個DC內] 語法: (1).宣告 Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long ◎hDestDC:目標的hdc值。 ◎(X,Y):複製到目標DC的圖形之XY軸起始值。 ◎(nWidth,nHeight):複製到目標DC的圖形之寬度和高度。 ◎hSrcDC:來源的hdc值。 ◎(XSrc,YSrc):所要複製的圖形在來源DC上的XY軸起始值。 ◎dwRop:[vbSrcCopy] ' 直接覆寫到目的物件上 [vbSrcPaint] ' 兩者進行OR運算 [vbSrcAnd] ' 兩者進行AND運算 [vbSrcInvert] ' 兩者進行XOR運算 (2).呼叫 Bitblt hDestDC, X, Y, nWidth, nHeight, hSrcDC, XSrc, YSrc, dwRop 範例: ' 要把物件[Picture2]的圖貼到物件[Picture1]上 Private Sub Command1() Call BitBlt (Picture1.hdc, 0, 0, Picture2.ScaleWidth, _ Picture2.ScaleHeight, Picture2.hdc, 0, 0, vbSrcCopy) End Sub [BringWindowToTop - 使物件或視窗在最上層顯示] 語法 (1).宣告 Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As Long ◎hwnd:物件的代碼。 (2).呼叫 Call BringWindowToTop ( hwnd ) [Chord-在繪圖物件上畫弓形] 語法 : 1. 宣告 Declare Function Arc Lib "gdi32" Alias "Chord" ( _ ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, _ ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) _ As Long 2. 呼叫 Call Chord ([被繪圖的物件].hdc, 繪圖範圍的起始值(X軸) , 繪圖範圍的起始值(Y軸), 繪圖範圍的末值(X軸) , 繪圖範圍的末值(Y軸), 弓形的開始值(X軸) , 弓形的開始值(Y軸), 弓形的末值(X軸) , 弓形的末值(Y軸)) 範例 : 在點(0,0)與點(100,200)繪圖範圍內,畫出一個 從點(45,25)開始到點(80,180)結束的弓形。 Private Sub Form_Click() Call Chord (Form1.hdc, 0, 0, 100, 200, 45, 25, 80, 180) End Sub [ClipCursor - 將滑鼠限制在某個區域] 語法 (1).宣告 Declare Function ClipCursor Lib "user32" Alias "ClipCursor" (lpRect As Any) As Long Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type (2).呼叫 Dim a As RECT a.Left = ? a.Top = ? a.Right = ? a.Bottom = ? Call ClipCursor ( a ) [CloseHandle - 關閉在記憶體中的Handle值] 語法 (1).宣告 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long ◎hObject:物件在記憶體中分配的代碼。 (2).呼叫 Call CloseHandle ( nObject ) [CreateEllipticRgn-製作出橢圓形的hRegion] 語法 : 1. 宣告 Declare Function CreateEllipticRgn Lib "gdi32" _ (ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long) As Long 2. 呼叫 A = CreateEllipticRgn ( 橢圓形左上角的起始值(X軸), 橢圓形左上角的起始值(Y軸), 橢圓形右下角的末值(X軸), 橢圓形右下角的末值(Y軸)) 範例 : Private Sub Command1_Click() A = CreateEllipticRgn (0, 0, 100, 50) End Sub <註> : 製作出的Region資訊,套入SetWindowRgn函數後可改變視窗 (即有hWnd屬性的物件)的形狀。 [CreatePolygonRgn-製作出多邊形的hRegion] 語法 : 1. 宣告 Declare Function CreatePolygonRgn Lib "gdi32" Alias _ "CreatePolygonRgn" (lpPoint As POINTAPI, ByVal nCount _ As Long, ByVal nPolyFillMode As Long) As Long Type POINTAPI x As Long y As Long End Type 2. 呼叫 A = CreatePolygonRgn ( 起始陣列, 陣列大小, 繪圖模式) <註> : 繪圖模式 不為 0 重覆劃分的區域變成通透 繪圖模式 = 0 重覆劃分的區域變成非通透 範例 : Private Sub Command1_Click() Dim A(6) As POINTAPI Dim B As Long A(0).X = 0: A(0).Y = 0 A(1).X = 0: A(1).Y = 100 A(2).X = 50: A(2).Y = 30 A(3).X = 30: A(3).Y = 30 A(4).X = 30: A(4).Y = 50 A(5).X = 100: A(5).Y = 0 B = CreatePolygonRgn(A(0), 6, 1) End Sub <註> : 製作出的Region資訊,套入SetWindowRgn函數後可改變視窗 (即有hWnd屬性的物件)的形狀。 [CreateRectRgn-製作出矩形的hRegion] 語法 : 1. 宣告 Declare Function CreateRectRgn Lib "gdi32" Alias _ "CreateRoundRectRgn" (ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long) As Long 2. 呼叫 A = CreateRoundRectRgn ( 矩形左上角的起始值(X軸), 矩形左上角的起始值(Y軸), 矩形右下角的末值(X軸), 矩形右下角的末值(Y軸)) 範例 : Private Sub Command1_Click() A = CreateRectRgn (0, 0, 100, 50) End Sub <註> : 製作出的Region資訊,套入SetWindowRgn函數後可改變視窗 (即有hWnd屬性的物件)的形狀。 [CreateRoundRectRgn-製作出圓角矩形的hRegion] 語法 : 1. 宣告 Declare Function CreateRoundRectRgn Lib "gdi32" Alias _ "CreateRoundRectRgn" (ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, _ ByVal Y3 As Long) As Long 2. 呼叫 A = CreateRoundRectRgn ( 圓角矩形左上角的起始值(X軸), 圓角矩形左上角的起始值(Y軸), 圓角矩形右下角的末值(X軸), 圓角矩形右下角的末值(Y軸), 圓角矩形的圓弧半徑(X軸), 圓角矩形的圓弧半徑(Y軸)) 範例 : Private Sub Command1_Click() A = CreateRoundRectRgn (0, 0, 100, 50, 20, 20) End Sub <註> : 製作出的Region資訊,套入SetWindowRgn函數後可改變視窗 (即有hWnd屬性的物件)的形狀。 [DeleteDC - 將物件的DC從記憶體刪除] 語法 (1).宣告 Declare Function DeleteDC Lib "gdi32" Alias "DeleteDC" (ByVal hdc As Long) As Long ◎hdc:某個設備環境的handle值。 (2).呼叫 Call DeleteDC ( hdc ) [DeleteObject - 將物件從記憶體中刪除] 語法 (1).宣告 Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Long) As Long (2).呼叫 Call DeleteObject(物件的handle值) [GetClientRect - 得知視窗或物件的大小] 語法 (1).宣告 Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type ◎hwnd:視窗或物件的代碼。 ◎lpRect:執行完成後所得到的區域大小。 (2).呼叫 Dim a As RECT Call GetClientRect ( a ) [GetWindowWord - 得到視窗的額外記憶值] 語法 (1).宣告 Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer ◎hwnd:視窗的代碼。 ◎wCmd:[GWW_HINSTANCE = -6] ' 得到視窗的模組值。 (2).呼叫 a = GetWindowWord ( hwnd , -6 ) [GetWindowRect-得知物件相對於螢幕的座標] 語法 : 1. 宣告 Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect AsRECT)As Long Type RECT Left As Long ToP As Long Right As Long Bottom As Long End Type 2. 呼叫 Dim 變數 As RECT Call GetWindowRect( 物件的hwnd值 , 變數 ) 範例 : Dim abs As RECT GetWindowRect Form1.hwnd , abc Debug.print "Bottom : " & abc.Bottom Debug.print "Top : " & abc.Top Debug.print "Left : " & abc.Left Debug.print "Right : " & abc.Right [GetWindowDC - 藉傳入的hwnd值取得整個視窗的hdc值] 語法 (1).宣告 Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long ◎hwnd:視窗或物件的代碼。 ◎傳回值即為此視窗或物件的hdc值。 (2).呼叫 a = GetWindowDC ( hwnd ) [RoundRect - 繪製矩形、圓角矩形或圓形的圖形] 語法 (1).宣告 Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long ◎(x1,y1):圖形的起點。 ◎(x2,y2):圖形的終點。 ◎(x3,y3):圖形四個角落的弧度大小。 (2).呼叫 Call RoundRect (hdc,x1,y1,x2,y2,x3,y3) [ScreenToClient - 藉物件的hwnd取得此物件在螢幕上的座標] 語法 (1).宣告 Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long Type POINTAPI x As Long y As Long End Type ◎hwnd:就是物件代碼([Object].hWnd)。 (2).呼叫 Dim a As POINTAPI Call ScreenToClient ( hwnd , a ) ◎取得的值("a.x","a.y")是負地,所以必須加絕對值。 [SetPixel - 設定在繪圖物件上某一點的顏色值] 語法 (1).宣告 Declare Function SetPixel Lib "gdi32" Alias "SetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long ◎hdc:某個設備環境的handle值。 ◎(x,y):建立顏色值的那一點座標。 ◎crColor:顏色值[可由QBColor()或RGB()取得]。 (2).呼叫 Call SetPixel( hdc , x , y , crColor ) [WindowFromPoint - 利用所輸入的(x,y)得到螢幕上(x,y)處之視窗的視窗代碼] 語法 (1).宣告 Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long ◎(xPoint):X座標的值。 ◎(yPoint):Y座標的值。 (2).呼叫 ahandle = WindowFromPoint ( xPoint , yPoint ) 'ahandle --> 所得到的視窗代碼
------
======================
昏睡~
不昏睡~
不由昏睡~
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-15 18:16:07 IP:211.76.xxx.xxx 未訂閱
mnsf 您好:    一個建議是: 將所有的座標值均成上一個常數,例如乘以十,將有效提高您的解析度十倍,但同樣的也會讓畫圖的區域放大成100倍。 其間的取捨要依您的需求來決定了。
Miles
尊榮會員


發表:27
回覆:662
積分:622
註冊:2002-07-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-19 17:37:28 IP:220.135.xxx.xxx 未訂閱
Hi mnsf 您好: 因為我們的銀幕解析度都是整數的關係, 所以無法輸入座標為浮點數的值, 若你的需求需要用到浮點數, 你必須做個取捨, 將他進位或捨去, 譬如解析度是800*600的畫面, 表示他有480000個點, 這些點的座標都是整數, 你若要找(X=10.5, Y=20.3)是沒有這個點的, 解決方法還是需要透過數學運算將你的數字變成整數才行. Good Luck 我不是高手, 高手是正在銀幕前微笑的人.
------


我不是高手, 高手是正在銀幕前微笑的人.
系統時間:2024-11-22 11:56:24
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!