; ********************************************************************
;                   !!! IMPORTANT INFORMATION !!!
; 
; YOU MUST NAME YOUR .rgn FILE IN YOUR .rc FILE AS THE FOLLOWING!...
;
; IDR_REGION RNG "<name_of_file>.rgn"
;
; ok.. ;], call this with 'MakeRegion, HWND' 
; returns handle to created region if successful so if u want to use
; shape u have created call 'SetWindowRgn'.
; VERY IMPORTANT!!! -> DONT FORGET THE HANDLE IS RETURNED IN eax !!
; ********************************************************************
;
; -NONE- of this would be possible without titi's tut so go here..
; -> http://titiasm.cjb.net <- and get the dlgshape.zip file 
; that includes his tut and the 'RGNerator.exe' and get making those
; CrAzY shapes :]]],
;                   nova.
; ********************************************************************
; here we go!...


MakeRegion PROTO :DWORD

; ********************************************************************

int2Real32 MACRO val        ;integer to real32 macro
      fild val
      fstp val
ENDM

; ********************************************************************

.data
    szRgnName     db "IDR_REGION",0     
    szRgnType     db "RNG",0

.data?
    hRgnName      dd ?
    hRgnPoint     dd ?
    hRgnSize      dd ?
    srClient      POINT <>
    srXform		XFORM <>
    srWinrect	RECT <>

.code

; ********************************************************************
    
    MakeRegion proc hWindow:DWORD

        invoke FindResource,hInstance,addr szRgnName,addr szRgnType
        mov hRgnName, eax         
        invoke LoadResource, hInstance, eax
        mov hRgnPoint, eax
        invoke SizeofResource, hInstance, hRgnName
        mov hRgnSize, eax
        mov	srClient.x, 0
        mov	srClient.y, 0
        invoke GetWindowRect,hWindow,addr srWinrect
        invoke ClientToScreen,hWindow,addr srClient
        mov	eax, srClient.x
        sub	eax, srWinrect.left
        mov	srXform.ex, eax
        mov	eax, srClient.y
        sub	eax, srWinrect.top
        mov	srXform.ey, eax
        mov	srXform.eM11, 1
        mov	srXform.eM22, 1
        int2Real32 srXform.eM11
        int2Real32 srXform.eM22
	  int2Real32 srXform.ex
	  int2Real32 srXform.ey
        invoke ExtCreateRegion,addr srXform,hRgnSize,hRgnPoint
        
ret     ;we return from proc with handle to region in eax

MakeRegion endp

; ********************************************************************
    

