何が違うのでしょうか。
システム変数HDCとGetDCでは値が違います。
HSPのHDCでTextOutとDrawTextではredrawが必要です。
#uselib "user32.dll" #cfunc GetDC "GetDC" int mes GetDC(hwnd) mes hdc stop
GetDCではredrawを入れると文字が消えます。
#uselib "user32.dll" #cfunc GetDC "GetDC" int #func DrawText "DrawTextW" int,str,int,int,int #uselib "gdi32.dll" #func TextOut "TextOutA" int,int,int,str,int sdim buf,256 buf="Hello!" ;文字列 len=strlen(buf) ;長さ mes "HSPのHDC:"+hdc mes "TextOut:\nDrawtext:" TextOut hdc,70,20,buf,len rect=80,35,640,480 DrawText hdc,buf,len,varptr(rect),$0 ;/* redraw ;*/ stop
何か勘違いしている気がするので教えて下さい。
#uselib "user32.dll" #cfunc GetDC "GetDC" int #func DrawText "DrawTextW" int,str,int,int,int #uselib "gdi32.dll" #func TextOut "TextOutA" int,int,int,str,int sdim buf,256 buf="Hello!" ;文字列 len=strlen(buf) ;長さ hdc_=GetDC(hwnd) ;デバイスコンテキスト取得 mes "GetDCで取得:"+hdc_ mes "TextOut:\nDrawtext:" TextOut hdc_,70,20,buf,len rect=80,35,640,480 DrawText hdc_,buf,len,varptr(rect),$0 ;/* redraw ;*/ stop