投稿時間:2003/07/16(Wed) 18:39 投稿者名:みさき
URL :
タイトル:ExtCreatePen関数について
いつも参考にさせてもらっています。 みさきと申します。
ExtCreatePen関数にて任意のペンを作成したいのですが、 どうしてもExtCreatePen関数が失敗してしまいます。 エラーメッセージを見ると「パラメータが間違っています。」 と出ます。 Msdnどうりにしてるつもりなのですが・・・。
どこが間違っているのでしょうか? よろしくお願いします。
開発環境:Win2000(SP4)、VB6(SP5)
Dim typLog As LOGBRUSH Dim hPen As Long Dim hOldPen As Long With typLog .lbStyle = BS_SOLID .lbColor = vbWhite .lbHatch = 0 End With
hPen = ExtCreatePen(PS_GEOMETRIC Or PS_SOLID Or PS_ENDCAP_SQUARE Or PS_JOIN_BEVEL, 2, typLog, 0, 0) If hPen = 0 Then MsgBox GetErrMsg(Err.LastDllError) End If
Option Explicit
'LOGBRUSH構造体(ブラシ設定) Public Type LOGBRUSH lbStyle As Long lbColor As Long lbHatch As Long End Type
Public Const BS_SOLID = 0 Public Const BS_NULL = 1
Public Const PS_GEOMETRIC = &H10000 Public Const PS_SOLID = 0 Public Const PS_DASH = 1 ' ------- Public Const PS_DOT = 2 ' ....... Public Const PS_DASHDOT = 3 ' _._._._ Public Const PS_DASHDOTDOT = 4 ' _.._.._ Public Const PS_NULL = 5 Public Const PS_USERSTYLE = 7 Public Const PS_INSIDEFRAME = 6 Public Const PS_ENDCAP_ROUND = &H0 Public Const PS_ENDCAP_SQUARE = &H100 Public Const PS_ENDCAP_FLAT = &H200 Public Const PS_JOIN_BEVEL = &H1000 Public Const PS_JOIN_MITER = &H2000 Public Const PS_JOIN_ROUND = &H0
'任意のペンを作成する Public Declare Function ExtCreatePen Lib "gdi32" (ByVal dwPenStyle As Long, _ ByVal dwWidth As Long, lplb As LOGBRUSH, ByVal dwStyleCount As Long, lpStyle As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
'線描画 Public Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Public Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpPoint As Long) As Long
' メッセージ文字列を書式化する関数の宣言 Public Declare Function FormatMessage Lib "kernel32.dll" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
' 書式化の処理方法を示す定数の宣言 Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200 Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
' プロセスのデフォルト言語IDを示す定数 Public Const PROCESS_DEFAULT_LANGUAGE = &H400
'▲Dllエラーのメッセージを返す '引数:lHdc Err.LastDllErrorを指定
Public Function GetErrMsg(lHwnd As Long) As String Dim strLastDllErrMsgBuffer As String * 1024 Dim lngWin32apiResultCode As Long lngWin32apiResultCode = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM Or _ FORMAT_MESSAGE_IGNORE_INSERTS, _ ByVal vbNullString, _ lHwnd, _ PROCESS_DEFAULT_LANGUAGE, _ strLastDllErrMsgBuffer, _ Len(strLastDllErrMsgBuffer), ByVal 0) 'エラーメッセージを表示 GetErrMsg = Left(strLastDllErrMsgBuffer, InStr(strLastDllErrMsgBuffer, vbNullChar) - 1)
End Function
|