English
Source / code snippets

to determine Combinergn Fensterformen

 
Wiedermal dank Sebastian king can of these Snipped The shape of Windows discretionary changed go:
+----------------------------------------------------------+
| combrgn.prf                                              |
| Author: Sebastian king                                   |
| email: feedback@sekoenig.de                              |
| Homepage: http://www.sekoenig.de                         |
| Spielereien with CombineRgn()                             |
+----------------------------------------------------------+
+===================================================+
# this View source building on code from PRFellow 99    #
# of Thomas Hölzer on. on this place yet      #
# time many Thanks and one grosses praise on whom        #
# Author!                                            #
#                                                   #
# More To PRFellow gives`s under:                    #
# http://prfellow.home.pages.de                   #
+===================================================+
--Benötigte functions
DEF SetWindowRgn(3) !USER32,SetWindowRgn
DEF CreateEllipticRgn(4) !GDI32,CreateEllipticRgn
DEF CreateRectRgn(4) !GDI32,CreateRectRgn
DEF CreatePolyRgn(3) !GDI32,CreatePolygonRgn
DEF CombineRgn(4) !GDI32,CombineRgn
DEF DeleteObject(1) !GDI32,DeleteObject
--Deklarationen
declare DEST&,SOURCE1&,SOURCE2&                for CombineRgn()
---New Window create
windowstyle 16
window 0,0-400,400
windowtitle ...
now goes`s go...
---Window with eckigem vent
SetWindowPos %hwnd=0,0-400,400                   Window adjust
windowtitle Eckiges vent
cls 0                                            so the Result rather
visible becomes
Text Color @RGB(31,31,31),-1
DrawText 1,1,Click = moreover
let DEST&    = CreateRectRgn(0,0,0,0)            The new Region with 0 initialisiern
let SOURCE1& = CreateRectRgn(0,0,400,400)        The 1. the both To kombinierenden
regions
let SOURCE2& = CreateRectRgn(100,100,300,300)    ...and The 2.
CombineRgn(DEST&,SOURCE1&,SOURCE2&,3)            The both regions go combined
and the Result becomes in
DEST& stored
SetWindowRgn(%hwnd,DEST&,1)                      now ändern we only yet The Region
the Fensters...
waitinput   Waiting...
---Window with rundem vent
SetWindowPos %hwnd=%winLeft,%winTop-400,400
windowtitle Rundes vent
cls 0
Text Color @RGB(31,31,31),-1
DrawText 1,1,Click = moreover
let DEST&    = CreateRectRgn(0,0,0,0)
let SOURCE1& = CreateRectRgn(0,0,400,400)             |
let SOURCE2& = CreateEllipticRgn(100,100,300,300)     |
>  see supra...
CombineRgn(DEST&,SOURCE1&,SOURCE2&,3)                 |
|
SetWindowRgn(%hwnd,DEST&,1)                          /
waitinput   and again Waiting...
---Window, the in 2 Hälften shared is
SetWindowPos %hwnd=%winLeft,%winTop-400,400
windowtitle Geteiltes Window
cls 0
Text Color @RGB(31,31,31),-1
DrawText 1,1,Click = moreover
let DEST&    = CreateRectRgn(0,0,0,0)
let SOURCE1& = CreateRectRgn(0,0,170,400)             |
let SOURCE2& = CreateRectRgn(230,0,400,400)           |
>  see supra...
CombineRgn(DEST&,SOURCE1&,SOURCE2&,3)                 |
|
SetWindowRgn(%hwnd,DEST&,1)                          /
waitinput   the übliche...
---too shared, only differently....
SetWindowPos %hwnd=%winLeft,%winTop-400,400
windowtitle Geteiltes Window, The 2.
cls 0
Text Color @RGB(31,31,31),-1
DrawText 1,1,Click = moreover
let DEST&    = CreateRectRgn(0,0,0,0)
let SOURCE1& = CreateRectRgn(0,0,200,200)             |
let SOURCE2& = CreateEllipticRgn(200,200,400,400)     |
>  see supra...
CombineRgn(DEST&,SOURCE1&,SOURCE2&,3)                 |
|
SetWindowRgn(%hwnd,DEST&,1)                          /
waitinput   and again...
---Schlüsselloch-Window
SetWindowPos %hwnd=%winLeft,%winTop-200,300
windowtitle ...     sees one eh´ not integrally...
cls 0
Text Color @RGB(31,31,31),-1
DrawText 33,1,Click = moreover
let DEST&    = CreateRectRgn(0,0,0,0)
let SOURCE1& = CreateEllipticRgn(0,0,200,200)         |
let SOURCE2& = CreateRectRgn(50,100,150,400)          |
>  see supra...
CombineRgn(DEST&,SOURCE1&,SOURCE2&,2)                 |
|
SetWindowRgn(%hwnd,DEST&,1)                          /
waitinput   what too otherwise?
---4-geteiltes-Window
SetWindowPos %hwnd=%winLeft,%winTop-400,400
windowtitle 4-geteiltes-Window
cls 0
Text Color @RGB(31,31,31),-1
DrawText 1,1,Click = end
let DEST&    = CreateRectRgn(0,0,0,0)
let SOURCE1& = CreateRectRgn(0,0,170,400)        |
let SOURCE2& = CreateRectRgn(230,0,400,400)       > see supra...
|
CombineRgn(DEST&,SOURCE1&,SOURCE2&,2)            /
now becomes it differently:
let SOURCE1& = DEST&                            we Save DEST in SOURCE1,
let SOURCE2& = CreateRectRgn(0,170,400,230)     create yet a Region...
CombineRgn(DEST&,SOURCE1&,SOURCE2&,4)           ...and join one 2. time
SetWindowRgn(%hwnd,DEST&,1)                     ex now again everything How supra...
waitinput   too the remaining same...
---and the was`s...
DeleteObject(DEST&)                             we give The erstellten regions
DeleteObject(SOURCE1&)                          again spare
DeleteObject(SOURCE2&)                          (Thanks on Christian Zietz)
end
 
04/20/04  
 



The Thanks for this code goes on Herrn Dieter Zornow
stood 06/04, fountain:  [...] 

Window regions
Author: Dieter Zornow
not any Def´s are using
code is spare
Def WindowFromDC(1) ! user32,WindowFromDC
Def GetDC(1) ! user32,GetDC
Def GetWindowDC(1) ! user32,GetWindowDC
Def ReleaseDC(2) ! user32,ReleaseDC
Def SaveDC(1) ! gdi32,SaveDC
Def RestoreDC(2) ! gdi32,RestoreDC
Def GetCurrentObject(2) ! gdi32,GetCurrentObject
Def GetWindowRgn(2) ! user32,GetWindowRgn hndl&,reg-hndl&
Def SetWindowRgn(3) ! user32,SetWindowRgn hndl&,reghndl&,redrawflag
Def DeleteObject(1) ! gdi32,DeleteObject hndl&
Def SelectObject(2) ! gdi32,SelectObject hdc,hndl&
Def InvertRgn(2) ! gdi32,InvertRgn hdc&,hdnl&
Def FillRgn(3) ! gdi32,FillRgn hdc, handl,brush
Def PaintRgn(2) ! gdi32,PaintRgn hdc,handl
Def FrameRgn(5) ! gdi32,FrameRgn
Def GetRgnBox(2) ! gdi32,GetRgnBox  hdnl,rect
Def CombineRgn(4) ! gdi32,CombineRgn
Def Moverect(3) ! gdi32,OffsetRgn
Def PtInRegion(3) ! gdi32,PtInRegion hndl the Region, x, y
Def PtVisible(3) ! gdi32,PtVisible
Def RectVisible(2) ! gdi32,RectVisible hdc,rect#
Def RectInRegion(2) ! gdi32,RectInRegion
Def SetRectRgn(5) ! gdi32,SetRectRgn
Def CreateRectRgn(4) ! gdi32,CreateRectRgn
Def CreateEllipticRgn(4) ! gdi32,CreateEllipticRgn
Def CreateRoundRectRgn(6) ! gdi32,CreateRoundRectRgn x%,y%,x1%,y2%,height%,width%
Def CreatePolygonRgn(3) ! gdi32,CreatePolygonRgn
Def CreateSolidBrush(1) ! GDI32,CreateSolidBrush
Def CreateHatchBrush(2) ! GDI32,CreateHatchBrush
Def CreatePen(3) ! gdi32,Def CreatePen
Def CreatePenIndirect(3) ! gdi32,CreatePenIndirect

proc Rahmenrec

    Parameter %hdc, lever the region, 1 or 2 for brushauswahl,Rahmenbreite,Rahmenhöhe,brushstyle,color
    parameters hdc&,rgn&,brush&,x%,y%,style&,col&
    Declare sb&
    case Brush& = 1:sb& = CreateHatchBrush(style&,col&)
    case Brush& = 2:sb& = CreateSolidBrush(col&)
    FrameRgn(hdc&,rgn&,sb&,x%,y%)
    DeleteObject(sb&)

endproc

Proc InvertRgn XOR, at second appeal again normal

    parameter %hdc, lever the Region
    parameters hdc&,hndl&
    InvertRgn(hdc&,hndl&)
    InvertRgn(%hdc2,hndl&) backup copy

endproc

Proc CreateRechteck

    Parameter xecke, yecke, length, höhe
    parameters x%,y%,xl%,yh%
    Declare Hndl&
    xl% = x%+xl%
    yh% = y%+yh%
    hndl& = CreateRectRgn(x%,y%,xl%,yh%)
    return hndl&

endproc

Proc CreateKreis

    Parameter xecke, yecke, Durchmesser, Durchmesser - > with circle,  / with Elipse values apiece to Size
    parameters x%,y%,xl%,yh%
    Declare Hndl&
    xl% = x%+xl%
    yh% = y%+yh%
    hndl& = CreateEllipticRgn(x%,y%,xl%,yh%)
    return hndl&

endproc

Proc CreateRundEck

    Parameter xecke, yecke, length, höhe round down, width round down
    parameters x%,y%,xl%,yh%,h%,w%
    Declare Hndl&
    xl% = x%+xl%
    yh% = y%+yh%
    hndl& = CreateRoundRectRgn(x%,y%,xl%,yh%,h%,w%)
    return hndl&

endproc

Proc CreateVieleck amount Parameter must always one multiple of 2 be.

    Variable amount of Parameters, apiece to Eckenzahl, each corner needed 2 values, x and Y
    Declare corners%,hndl&,point#,offset%,point1#
    corners% = %PCount
    offset% = 0
    Dim point#,corners% * 4

    whileloop corners% ex Profan 7 under in a normal while - Loop transfiguring and To corners% enumerate

        long point#,offset% = @%(&loop)
        offset% = offset% + 4

    endwhile

    hndl& = CreatePolygonRgn(point#,(corners% / 2),2)
    Dispose point#
    return hndl&

endproc

proc Sfillregn

    Parameter %hdc, lever the Region, Color
    parameters hdc&,hndl&,col&
    Declare sb&
    sb& = CreateSolidBrush(col&)
    FillRgn(hdc&,hndl&,sb&)
    FillRgn(%hdc2,hndl&,sb&)
    DeleteObject(sb&)

endproc

proc Hfillregn

    Parameter %hdc, lever the Region, brush style, Color
    parameters hdc&,hndl&,style&,col&
    Declare sb&
    sb& = CreateHatchBrush(style&,col&)
    FillRgn(hdc&,hndl&,sb&)
    FillRgn(%hdc2,hndl&,sb&)
    DeleteObject(sb&)

endproc

proc compregn

    Parameter lever the Zielregion, lever the 1. To integrierenden Region, lever the 2. To integrierenden Region, Integrierungsmodus
    parameters HdDes&,Hdsour1&,Hdsour2&,mode&
    CombineRgn(HdDes&,Hdsour1&,Hdsour2&,mode&)

endproc

example
cls
Declare rk&,kr&,re&,ve&,kr2&,rk2&,rk3&,el&
CreateRechteck 10,10,50,20 1 rectangle
rk& = @&(0)
sfillregn %hdc,rk&,255
CreateKreis 10,35,50,50  circle
kr& = @&(0)
sfillregn %hdc,kr&,16740608
CreateKreis 100,35,25,50  Elipse
el& = @&(0)
sfillregn %hdc,el&,16740608
CreateRundEck 10,90,50,30,20,30
re& = @&(0)
sfillregn %hdc,re&,65280
CreateKreis 10,130,50,50 combin 1
kr2& = @&(0)
Hfillregn %hdc,kr2&,5,65535
CreateRechteck 58,145,50,20 Combin 2
rk2& = @&(0)
Hfillregn %hdc,rk2&,5,65535
CreateRechteck 10,185,50,20 umrahmtes rectangle
rk3& = @&(0)
Rahmenrec %hdc,rk3&,2,2,2,0,255
compregn kr2&,kr2&,rk2&,2 combin1 and combin2 go To of/ one Region lever = kr2& RGN_OR
DeleteObject(rk2&) existing already not More
CreateVieleck 10,400,50,300,100,400 Dreieck
ve& = @&(0)
Sfillregn %hdc,ve&,255
Locate 30,30
case PtInRegion(ve&,30,380) = 1:Print These Koordinate lying in the Dreieck request whether Koordinate in the Dreieck lying
waitinput
InvertRgn(%hdc,rk&) The regions go at first time invertiert
InvertRgn(%hdc,kr&)
InvertRgn(%hdc,re&)
InvertRgn(%hdc,kr2&)
InvertRgn(%hdc,rk3&)
InvertRgn(%hdc,ve&)
InvertRgn(%hdc,el&)
waitinput
InvertRgn(%hdc,rk&) The regions go at second time again normal displayed
InvertRgn(%hdc,kr&)
InvertRgn(%hdc,re&)
InvertRgn(%hdc,kr2&)
InvertRgn(%hdc,rk3&)
InvertRgn(%hdc,ve&)
InvertRgn(%hdc,el&)
waitinput
SetWindowRgn(%Hwnd,ve&,1) Window becomes only yet in this area displayed, 1 = Redraw, 0 = No
Parameter Window lever, Region lever, neuzeichen
waitinput
DeleteObject(rk&) everything again enable, is necessary
DeleteObject(kr&)
DeleteObject(re&)
DeleteObject(kr2&)
DeleteObject(rk2&)
DeleteObject(rk3&)
DeleteObject(ve&)
DeleteObject(el&)
end
-----------------------------------------------------------------------
for Vieleck
ALTERNATE = 1 alternative between filled and ungefüllt
WINDING = 2 the dreieck normal filled
fnCombineMode
Specifies a fashion indicating how the two regions wants be combined. Diese parameter can be one of the following values:
Value	Description
RGN_AND	Creates the intersection of the two combined regions.
RGN_COPY	Creates a copy of the region identified by hrgnSrc1.
RGN_DIFF	Combines the parts of hrgnSrc1 that are hardship part of hrgnSrc2.
RGN_OR	        Creates the union of two combined regions.
RGN_XOR	Creates the union of two combined regions except for any overlapping areas.
{ CombineRgn() Styles }
RGN_AND = 1;
RGN_OR = 2;
RGN_XOR = 3;
RGN_DIFF = 4;
RGN_COPY = 5;
RGN_MIN = ~RGN_AND;
RGN_MAX = ~RGN_COPY;
Hatch-brush-values
HS_HORIZONTAL = 0;       { ----- }
HS_VERTICAL   = 1;       { ||||| }

HS_FDIAGONAL  = 2;       {///// }

    HS_BDIAGONAL  = 3;       { \\ }
    HS_CROSS      = 4;       { +++++ }
    HS_DIAGCROSS  = 5;       { xxxxx }
 
06/02/04  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.974 Views

Untitledvor 0 min.
p.specht07/14/18
Paul Glatz09/27/14
Manfred Barei12/27/13
Julian Schmidt10/24/12
More...

Themeninformationen

this Topic has 1 subscriber:

unbekannt (2x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie