當筆寬度爲3或4時(LineTo不繪製任何內容),CreatePen GDI函數在Windows 7上不起作用。它適用於0 - 2寬度。在所有情況下都使用PS_SOLID筆樣式。Windows 7上的CreatePen GDI函數問題
0
A
回答
1
LineTo不包括該行的最後一個點。嘗試一個不同的endcap設置,看看它是否有所作爲。
0
它是否返回一個句柄或NULL?
你有沒有考慮過使用CreatePenIndirect和結構LOGPEN?
http://msdn.microsoft.com/en-us/library/dd183510(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/dd145041(v=VS.85).aspx
這只是正常工作在我的電腦中,Windows 7 64位系統上:
Option Explicit
Private Declare Function CreatePen Lib "gdi32" (_
ByVal nPenStyle As Long, _
ByVal nWidth As Long, _
ByVal crColor As Long) As Long
Private Declare Function LineTo Lib "gdi32" (_
ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (_
ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (_
ByVal hObject As Long) As Long
Dim x As Long
Dim y As Long
Dim w As Long
Private Sub Command1_Click()
w = w + 1
Dim hpen As Long: hpen = CreatePen(0, w, 0)
Dim ret As Long: ret = SelectObject(Me.hDC, hpen)
If ret <> 0 Then
x = x + 10
y = y + 10
Call LineTo(Me.hDC, x, y)
End If
Call DeleteObject(hpen)
End Sub
單擊按鈕多次
+0
謝謝馬克是個好主意。通過用PolyLine調用替換LineTo函數調用解決了該問題。我使用普通的CreatePen API,它不像ExtCreatePen那樣將參數結束標誌設置爲參數。 Intertstingly,這段代碼在Vista和XP上運行良好。只有寬度爲3及以上的Windows 7有問題。 – user486842 2010-10-27 14:55:40
相關問題
- 1. Windows 7和ScreenShot.cpp GDI + PNG問題
- 2. 在Windows XP上的GDI +問題
- 3. Windows 7 shell函數的鏈接問題
- 4. Windows 7上GetLastError API的問題
- 5. 在Windows 7上使用IFileDialog的問題
- 6. 問題:Windows 7上的Fluentd gem安裝
- 7. Windows 7上的Ruby on Rails問題
- 8. Windows 7上Playframework 2.1.0的安裝問題
- 9. Windows 7上的Scala 2.8.0問題
- 10. 在Windows 7上使用LibAo的問題
- 11. Windows 7(cmd)上的Heroku問題
- 12. Windows 7 64位上的Eclipse問題
- 13. C#Windows 7問題
- 14. 問題在Windows 7
- 15. 問題在Windows 7
- 16. GDI +抖動問題
- 17. 奇怪的Windows 7問題
- 18. 在Windows 7上VB6 LstView問題32位
- 19. Cordova安裝問題:在Windows 7上
- 20. BitBlt問題GDI
- 21. GDI +位圖問題
- 22. GDI + DrawImage函數
- 23. Windows 7文件問題
- 24. NTSVC.OCX問題在Windows 7
- 25. Windows 7兼容性問題
- 26. MFC chtmlview Windows 7問題
- 27. Windows 7 WideChar顯示問題
- 28. Windows Phone 7線程問題
- 29. SAPI和Windows 7問題
- 30. Windows 7 Gadget Flyout問題
謝謝你馬克的好主意。通過用PolyLine調用替換LineTo函數調用解決了該問題。我使用普通的CreatePen API,它不像ExtCreatePen那樣將參數結束標誌設置爲參數。 Intertstingly,這段代碼在Vista和XP上運行良好。只有寬度爲3及以上的Windows 7有問題。 - – user486842 2010-10-27 14:57:07