Sign in to follow this  
Followers 0
Lej

Using DllStructCreate

2 posts in this topic

Trying to learn a bit about how to use dll commands, structs etc.

This is supposed to draw a purple square.

Why does this work when I use $RectRgn2[0] but not when it's $RectRgn1Pointer?

DllCall("gdi32.dll", "long", "FillRgn", "long", $hDC[0], "long", $RectRgn2[0], "long", $hBrush[0])oÝ÷ Ù«­¢+Ù!½Ñ-åMÐ ÅÕ½ÐííM
ôÅÕ½Ðì°ÅÕ½Ðí}á¥ÐÅÕ½Ðì¤()±½°ÀÌØíá¥Ðô±Í((ÀÌØí¡]¹ôMÁ±Í¡QáÑ=¸ ÅÕ½ÐíÉÝ]¥¸ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÐÀÀ°ÐÀÀ°À°À°Ä¤((ì´´´Iѹ±Ä´´´(ÀÌØíIÑI¸Äô±±MÑÉÕÑ
ÉÑ ÅÕ½Ðí¥¹Ðí¥¹Ðí¥¹Ðí¥¹ÐÅÕ½Ðì¤(ÀÌØíIÑI¸ÅA½¥¹ÑÈô±±MÑÉÕÑÑAÑÈ ÀÌØíIÑI¸Ä¤)±±MÑÉÕÑMÑÑ ÀÌØíIÑI¸Ä°Ä°ÄÀ¤)±±MÑÉÕÑMÑÑ ÀÌØíIÑI¸Ä°È°ÄÀ¤)±±MÑÉÕÑMÑÑ ÀÌØíIÑI¸Ä°Ì°ØÀ¤)±±MÑÉÕÑMÑÑ ÀÌØíIÑI¸Ä°Ð°ØÀ¤((ì´´´Iѹ±È´´´(ÀÌØíIÑI¸Èô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÄÀ°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÄÀ°ÅÕ½Ðí±½¹ÅÕ½Ðì°ØÀ°ÅÕ½Ðí±½¹ÅÕ½Ðì°ØÀ¤((ì´´´ÉÜ´´´(ÀÌØí¡ô11
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡]¹¤(ÀÌØíÉ
½±½ÈôÁáÀÁ(ÀÌØí¡   ÉÕÍ ô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑM½±¥ ÉÕÍ ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíÉ
½±½È¤)±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí¥±±I¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí¡
lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíIÑI¸ÉlÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí¡  ÉÕÍ¡lÁt¤)11
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíI±ÍÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¡
lÁt°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°À¤()]¡¥±9½ÐÀÌØíá¥Ð(M±À ÈÔ¤)]¹()Õ¹}á¥Ð ¤(ÀÌØíá¥ÐôQÉÕ)¹Õ¹

Share this post


Link to post
Share on other sites



Since there are no takers on this I'll throw in some thoughts. I can't test at the moment so regard this for what it is, thoughts.

According to this sample on codeprohect (the first thing that came up from google)

BOOL FillRgn(
  HDC hdc,  // handle to device context
  HRGN hrgn,  // handle to region to be filled
  HBRUSH hbr  // handle to brush used to fill the region
);

So I guess the reason is that you pass on a long (which should work), but I have found from experience that it it's worth to try with ptr if stuff goes wrong. So (again untested):

DllCall("gdi32.dll", "long", "FillRgn", "long", $hDC[0], "ptr", $RectRgn1Pointer, "long", $hBrush[0])oÝ÷ Ø(ºWZÊ-º0{(ç«®Üç$x¡×¢|³*.Ù^jËZ²Z'«2¢êâ׬·÷^nè&¡×¢g­)à)jëh×6chk(DllCall("gdi32.dll", "long", "FillRgn", "long", $hDC[0], "ptr", $RectRgn1Pointer, "long", $hBrush[0]))

Func chk($val, $erl=@ScriptLineNumber, $err=@Error, $ext=@Extended)
    If $err <> 0 OR $ext <> 0 Then 
        ConsoleWrite("(" & $erl & ") := (" & $err & ")(" & $ext & ")" & @LF)
        Return SetError($err, $xt, $val)
    EndIf
    Return $val
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0