白石 和夫さんへのお返事です。
> Windows Meでも同様なのだろうと思いますが,上位の何ビットが無視されるのかが問題です。
プログラムとしては、ちょっと強引ですが、、、
BASICのグラフィックス画面(タイトルバー、メニューバーを含むウインドウ)をhDCとして確認してみました。
結果は、-2^15~2^15の範囲のようです。(32ビット指定だが、上位16ビットは無効となる)
>> Windows Meの場合は,GDIの座標系が16ビットなので,
>> ピクセル座標系に変換した後,-2^15~2^15-1の範囲に
>> 座標値を切り詰めた後に描画させています
これならちゃんと描画するのでは?
OPTION CHARACTER byte
LET w=320
LET h=240
SET BITMAP SIZE w,h !画面サイズ
SET WINDOW 0,w-1,0,h-1 !左下が原点。横がX、縦Y
LET hWnd=FndWnd("TPaintForm","") !ウインドウハンドルを取得する
LET Rect$=REPEAT$(" ",4*4)
LET n=ClientRect(hWnd, Rect$)
PRINT int32(Rect$,0);int32(Rect$,4);int32(Rect$,8);int32(Rect$,12)
LET n=GetWndRect(hWnd, Rect$)
PRINT int32(Rect$,0);int32(Rect$,4);int32(Rect$,8);int32(Rect$,12)
IF hWnd>0 THEN
LET hDC=GetWndDC(hWnd) !デバイスコンテキストを取得する
IF hDC>0 THEN
!LET n=SetForeWnd(hWnd)
LET n=Ellipse(hDC,20,20,100,200)
LET m=-2^16 !<-------------------- -2^15~2^15はOK
LET n=MoveTo(hDC,0,m,0) !
LET n=LineTo(hDC,200,m) !
WAIT DELAY 2
LET n=ReleaseDC(hWnd, hDC) !デバイスコンテキストを開放する
END IF
END IF
END
!--------------------------------------------------
!
EXTERNAL FUNCTION DWORD$(n)
OPTION CHARACTER byte
LET r=MOD(n,2^8)
LET s$=CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET s$=s$ & CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET s$=s$ & CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET DWORD$=s$ & CHR$(r)
END FUNCTION
EXTERNAL FUNCTION WORD$(n)
OPTION CHARACTER byte
LET r=MOD(n,2^8)
LET s$=CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET WORD$=s$ & CHR$(r)
END FUNCTION
EXTERNAL FUNCTION int32(s$,p)
OPTION CHARACTER byte
LET n=0
FOR i=1 TO 4
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
IF n<2^31 THEN LET int32=n ELSE LET int32=n-2^32
END FUNCTION
EXTERNAL FUNCTION int16(s$,p)
OPTION CHARACTER byte
LET n=0
FOR i=1 TO 2
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
IF n<2^15 THEN LET int16=n ELSE LET int16=n-2^16
END FUNCTION
!user32.dll
EXTERNAL FUNCTION CloseWnd(hWnd)
ASSIGN "user32.dll","CloseWindow"
END FUNCTION
EXTERNAL FUNCTION CopyRect(lpDstRect$, lpSrcRect$)
ASSIGN "user32.dll","CopyRect"
END FUNCTION
EXTERNAL FUNCTION FndWnd(lpClassName$, lpWindowName$)
ASSIGN "user32.dll","FindWindowA"
END FUNCTION
EXTERNAL FUNCTION FillRect(hDC, lpRect$, hbr)
ASSIGN "user32.dll","FillRect"
END FUNCTION
EXTERNAL FUNCTION GetActWnd
ASSIGN "user32.dll","GetActiveWindow"
END FUNCTION
EXTERNAL FUNCTION ClientRect(hWnd, lpRect$)
ASSIGN "user32.dll","GetClientRect"
END FUNCTION
EXTERNAL FUNCTION GetForeWnd
ASSIGN "user32.dll","GetForegroundWindow"
END FUNCTION
EXTERNAL FUNCTION GetWndDC(hWnd)
ASSIGN "user32.dll","GetWindowDC"
END FUNCTION
EXTERNAL FUNCTION GetWndRect(hWnd, lpRect$)
ASSIGN "user32.dll","GetWindowRect"
END FUNCTION
EXTERNAL FUNCTION IsWndVisible(hWnd)
ASSIGN "user32.dll","IsWindowVisible"
END FUNCTION
EXTERNAL FUNCTION MoveWnd(hWnd, x, y, cx, cy)
ASSIGN "user32.dll","MoveWindow"
END FUNCTION
EXTERNAL FUNCTION OffsetRect(lpRect$, dx, dy)
ASSIGN "user32.dll","OffsetRect"
END FUNCTION
EXTERNAL FUNCTION ReleaseDC(hWnd, hDC)
ASSIGN "user32.dll","ReleaseDC"
END FUNCTION
EXTERNAL FUNCTION SetActWnd(hWnd)
ASSIGN "user32.dll","SetActiveWindow"
END FUNCTION
EXTERNAL FUNCTION SetForeWnd(hWnd)
ASSIGN "user32.dll","SetForegroundWindow"
END FUNCTION
EXTERNAL FUNCTION SetRect(lpRect$, xLeftRect, yTopRect, xRightRect, yBottomRect)
ASSIGN "user32.dll","SetRect"
END FUNCTION
EXTERNAL FUNCTION SetWndPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlag)
ASSIGN "user32.dll","SetWindowPos"
END FUNCTION
EXTERNAL FUNCTION SetWndText(hWnd, lpString$)
ASSIGN "user32.dll","SetWindowTextA"
END FUNCTION
EXTERNAL FUNCTION ShowWnd(hWnd, nCmdShow)
ASSIGN "user32.dll","ShowWindow"
END FUNCTION
!gdi32.dll
EXTERNAL FUNCTION SolidBrush(crColor)
ASSIGN "gdi32.dll","CreateSolidBrush"
END FUNCTION
EXTERNAL FUNCTION Ellipse(hDC, nLeftRect, nTopRect, nRightRect, nBottomRect)
ASSIGN "gdi32.dll","Ellipse"
END FUNCTION
EXTERNAL FUNCTION LineTo(hDC, x, y)
ASSIGN "gdi32.dll","LineTo"
END FUNCTION
EXTERNAL FUNCTION MoveTo(hDC, x, y, lpPoint)
ASSIGN "gdi32.dll","MoveToEx"
END FUNCTION
EXTERNAL FUNCTION Rectangle(hDC, nLeftRect, nTopRect, nRightRect, nBottomRect)
ASSIGN "gdi32.dll","Rectangle"
END FUNCTION