IonicWind Software

Creative Basic => GUI Programs => Topic started by: GWS on October 25, 2008, 09:15:02 AM

Title: Borderless Controls ..
Post by: GWS on October 25, 2008, 09:15:02 AM
Hi folks,

This one nearly got away ..  :)    I was searching some old backup files, and found this little gem by Fletchie.

One thing always bugs me, is how clunky Edit Boxes are with that thick border.

This bit of clever code gets rid of the border - it also works for list boxes ..  :)


def w1:window
def run,t:int
declare "user32",GetWindowLongA(hnd:int,ind:int),int
declare "user32",GetDlgItem(Hwnd:int,cntid:int),int
declare "user32",SetWindowLongA(hwnd:int,ind:int,nwv:int),int

declare RemoveBorder(w:window,cnt:int,x:int,y:int,wi:int,h:int)

setid "gwl_style",-16
setid "gwl_exstyle",-20
setid "WS_EX_CLIENTEDGE",512

window w1,100,100,300,150,0,0,"CBasic Test",WHnd
setwindowcolor w1,rgb(0,0,100)
CONTROL w1,"E,,60,30,150,50,0x50800140,1"
'Parameters for RemoveBorder:-
'window,control,x,y,width,height
'should be same as given in control statement

RemoveBorder(w1,1,60,30,150,50)

'  use this bit for testing a list box example
'  for t=1 to 10
'  addstring w1,1,str$(t)
'  next t
setcontroltext w1,1,"test"
setcontrolcolor w1,1,0,rgb(150,240,250)
run=1
waituntil run=0

closewindow w1
end

'---------------------------------------------------------------------

sub RemoveBorder(w,cnt,x,y,wi,h)

def n,d:int

  n=GetDlgItem(w,2024+cnt)
  d=GetWindowLongA(n,@gwl_style)
  d=d & not(@border)
  SetWindowLongA(n,@gwl_style,d)
  d=getWindowLongA(n,@gwl_exstyle)
  d=d & not(@ws_ex_clientedge)
  SetWindowLongA(n,@gwl_exstyle,d)
'has to a different size here, as otherwise control
'doesn't get redrawn without border
  setsize w,x,y,wi,h+1,cnt

return

'----------------------------------------------------------------------

sub WHnd
select @class
case @idclosewindow
run=0
endselect
return



I can never claim to understand Fletchie's clever bits - they just work  :)

The 0x50800140 flags set for the control must do something, but I prefer to see all the flags separately shown myself.

all the best, :)

Graham