'DrawEdge API demo - author unknown 'Ported from an iBasic standard snippet to iwBasic 'Ported to IWB by Brian 11/11/2023 WINRECT rc 'DrawEdge inner and outer border constants CONST EDGE_BUMP=0x1|0x8 CONST EDGE_ETCHED=0x2|0x4 CONST EDGE_RAISED=0x1|0x4 CONST EDGE_SUNKEN=0x2|0x8 'DrawEdge border types CONST BF_ADJUST=0x2000 CONST BF_BOTTOM=0x8 CONST BF_BOTTOMLEFT=0x8|0x1 CONST BF_BOTTOMRIGHT=0x8|0x4 CONST BF_DIAGONAL=0x10 CONST BF_DIAGONAL_ENDBOTTOMLEFT=0x10|0x8|0x1 CONST BF_DIAGONAL_ENDBOTTOMRIGHT=0x10|0x8|0x4 CONST BF_DIAGONAL_ENDTOPLEFT=0x10|0x2|0x1 CONST BF_DIAGONAL_ENDTOPRIGHT=0x10|0x2|0x4 CONST BF_FLAT=0x4000 CONST BF_LEFT=0x1 CONST BF_MIDDLE=0x800 CONST BF_MONO=0x8000 CONST BF_RECT=0x1|0x2|0x4|0x8 CONST BF_RIGHT=0x4 CONST BF_SOFT=0x1000 CONST BF_TOP=0x2 CONST BF_TOPLEFT=0x2|0x1 CONST BF_TOPRIGHT=0x2|0x4 DECLARE IMPORT,DrawEdge(hDC:INT,rc:WINRECT,edge:UINT,flags:UINT),INT DECLARE IMPORT,GetSysColor(nindex:INT),INT DECLARE IMPORT,GlobalAlloc(flags:INT,bytes:INT),UINT DECLARE IMPORT,GlobalLock(handle:UINT),POINTER DECLARE IMPORT,GlobalUnlock(handle:UINT),INT DECLARE IMPORT,OpenClipboard(hWnd:UINT),INT DECLARE IMPORT,CloseClipboard(),INT DECLARE IMPORT,SetClipboardData(format:INT,handle:INT),INT DECLARE IMPORT,EmptyClipboard(),INT SETID "CFTEXT",1 SETID "GHND",0x42 WINDOW main INT error,cID UINT edge,style,hDC,lock STRING dEdge1,dEdge2 OPENWINDOW main,0,0,478,380,@MINBOX|@CAPTION|@SYSMENU|@NOAUTODRAW,0,"DrawEdge Demo",&Handler SETWINDOWCOLOR main,RGB(216,207,196) 'GetSysColor(15) CONTROL main,@STATIC,"API Call - no Constants needed:",10,304,192,20,0,2 SETFONT main,"Arial",10,400,0,2 CONTROL main,@EDIT,"",10,324,452,20,0x50810000,1 SETFONT main,"Arial",8,400,0,1 CONTROL main,@STATIC,"Pressing 'Draw' copies the API call to the Clipboard",134,80,120,60,0|@CTEDITCENTER,27 hDC=GETHDC(main) rc.left=10 rc.top=160 rc.right=288 rc.bottom=294 CONTROL main,@GROUPBOX,"Border Styles",10,10,278,138,0x50000007,3 CONTROL main,@RADIOBUTTON,"Edge Bump",15,30,90,20,0x50018009,4 CONTROL main,@RADIOBUTTON,"Edge Etched",15,60,90,20,0x50018009,5 CONTROL main,@RADIOBUTTON,"Edge Raised",15,90,90,20,0x50018009,6 CONTROL main,@RADIOBUTTON,"Edge Sunken",15,120,90,20,0x50018009,7 CONTROL main,@BUTTON,"Draw",134,46,120,20,0x50008001,40 CONTROL main,@CHECKBOX,"Adjust Rectangle",300,10,146,20,0x50018003,8 CONTROL main,@CHECKBOX,"Border at Bottom",300,26,132,20,0x50018003,9 CONTROL main,@CHECKBOX,"Border at Bottom and Left",300,42,154,20,0x50018003,10 CONTROL main,@CHECKBOX,"Border at Bottom and Right",300,58,155,20,0x50018003,11 CONTROL main,@CHECKBOX,"Diagonal Border",300,74,136,20,0x50018003,12 CONTROL main,@CHECKBOX,"Diagonal - End at Bottom Left",300,90,163,20,0x50018003,13 CONTROL main,@CHECKBOX,"Diagonal - End at Bottom Right",300,106,166,20,0x50018003,14 CONTROL main,@CHECKBOX,"Diagonal - End at Top Left",300,122,147,20,0x50018003,15 CONTROL main,@CHECKBOX,"Diagonal - End at Top Right",300,138,162,20,0x50018003,16 CONTROL main,@CHECKBOX,"Flat Border",300,154,83,20,0x50018003,17 CONTROL main,@CHECKBOX,"Border at Left Side",300,170,141,20,0x50018003,18 CONTROL main,@CHECKBOX,"Fill Rectangle Interior",300,186,143,20,0x50018003,19 CONTROL main,@CHECKBOX,"One-dimensional Border",300,202,142,20,0x50018003,20 CONTROL main,@CHECKBOX,"Draw Entire Border",300,218,134,20,0x50018003,21 CONTROL main,@CHECKBOX,"Border at Right Side",300,234,137,20,0x50018003,22 CONTROL main,@CHECKBOX,"Soft Buttons instead of Tiles",300,250,156,20,0x50018003,23 CONTROL main,@CHECKBOX,"Border at Top",300,266,112,20,0x50018003,24 CONTROL main,@CHECKBOX,"Border at Top and Left",300,282,159,20,0x50018003,25 CONTROL main,@CHECKBOX,"Border at Top and Right",300,298,167,20,0x50018003,26 'Set colours and font sizes SETCONTROLCOLOR main,2,RGB(0,0,250),RGB(216,207,196) FOR cID=3 TO 27 SETFONT main,"Arial",8,400,0,cID SETCONTROLCOLOR main,cID,RGB(0,0,0),RGB(216,207,196) NEXT cID SETFONT main,"Arial",8,400,0,40 SETFONT main,"Arial",8,400,0,41 dEdge1="edgecall=DrawEdge(hDC,rc," WAITUNTIL IsWindowClosed(main) RELEASEHDC main,hDC END SUB Handler(),INT SELECT @MESSAGE CASE @IDCREATE CENTERWINDOW main CASE @IDCLOSEWINDOW CLOSEWINDOW main CASE @IDERASEBACKGROUND RETURN 1 CASE& @IDCONTROL SELECT @CONTROLID CASE 4 'Edge Bump edge=0x0|EDGE_BUMP CASE 5 'Edge Etched edge=0x0|EDGE_ETCHED CASE 6 'Edge Raised edge=0x0|EDGE_RAISED CASE 7 'Edge Sunken edge=0x0|EDGE_SUNKEN CASE 40 'Draw the box style=0x0 IF (GETSTATE(main,8))=1 THEN style=style|BF_ADJUST IF (GETSTATE(main,9))=1 THEN style=style|BF_BOTTOM IF (GETSTATE(main,10))=1 THEN style=style|BF_BOTTOMLEFT IF (GETSTATE(main,11))=1 THEN style=style|BF_BOTTOMRIGHT IF (GETSTATE(main,12))=1 THEN style=style|BF_DIAGONAL IF (GETSTATE(main,13))=1 THEN style=style|BF_DIAGONAL_ENDBOTTOMLEFT IF (GETSTATE(main,14))=1 THEN style=style|BF_DIAGONAL_ENDBOTTOMRIGHT IF (GETSTATE(main,15))=1 THEN style=style|BF_DIAGONAL_ENDTOPLEFT IF (GETSTATE(main,16))=1 THEN style=style|BF_DIAGONAL_ENDTOPRIGHT IF (GETSTATE(main,17))=1 THEN style=style|BF_FLAT IF (GETSTATE(main,18))=1 THEN style=style|BF_LEFT IF (GETSTATE(main,19))=1 THEN style=style|BF_MIDDLE IF (GETSTATE(main,20))=1 THEN style=style|BF_MONO IF (GETSTATE(main,21))=1 THEN style=style|BF_RECT IF (GETSTATE(main,22))=1 THEN style=style|BF_RIGHT IF (GETSTATE(main,23))=1 THEN style=style|BF_SOFT IF (GETSTATE(main,24))=1 THEN style=style|BF_TOP IF (GETSTATE(main,25))=1 THEN style=style|BF_TOPLEFT IF (GETSTATE(main,26))=1 THEN style=style|BF_TOPRIGHT DrawEdge(hDC,rc,EDGE_BUMP,BF_MIDDLE) 'DrawEdge Call error=DrawEdge(hDC,rc,edge,style) 'DrawEdge Call IF error=0 SETCONTROLTEXT main,1,"Invalid Call" ELSE dEdge2=APPEND$(dEdge1,"0x",LTRIM$(STR$(edge)),",0x",LTRIM$(STR$(style)),")") SETCONTROLTEXT main,1,dEdge2 'Copy value to Clipboard handle=GlobalAlloc(@GHND,255) lock=GlobalLock(handle) #lock=dEdge2 GlobalUnlock(handle) OpenClipboard(main.hWnd) EmptyClipboard() SetClipboardData(@CFTEXT,handle) CloseClipboard() ENDIF ENDSELECT ENDSELECT RETURN 0 ENDSUB