May 18, 2024, 10:05:18 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Borderless listbox

Started by Andy, September 16, 2014, 07:19:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

I have some listboxes, which I think may look better without a border.

Graham had a go some time ago, but in IW his code gives an error:
http://www.ionicwind.com/forums/index.php?topic=4849.0

Is there any way in IW to remove the border from a list box - this is purely a cosmetic request,
if it can't be done then ok.

Best wishes,
Andrew.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

September 16, 2014, 12:08:12 PM #1 Last Edit: September 16, 2014, 12:23:49 PM by Brian Pugh
Andy, got it to compile OK, but it doesn't remove the borders. Have a play with it...

See below: Fixed!

WINDOW w1
INT run,t

declare import,GetWindowLongA(hnd:int,ind:int),int
declare import,GetDlgItem(Hwnd:int,cntid:int),int
declare import,SetWindowLongA(hwnd:int,ind:int,nwv:int),int

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

CONST gwl_style=-16
CONST gwl_exstyle=-20
const WS_EX_CLIENTEDGE=512

openwindow w1,100,100,300,250,0,0,"Borderless Listview",&handler
setwindowcolor w1,rgb(150,180,180)

control w1,@LISTBOX,"",70,20,150,180,@VSCROLL,1
setcontrolcolor w1,1,0,rgb(0,200,250)

' Parameters for RemoveBorder: window,control,x,y,width,height should be same as given in control statement ...

RemoveBorder(w1,1,70,20,150,180)

for t=1 to 20
addstring w1,1,str$(t)
next t

run=1
waituntil run=0

closewindow w1
end

sub RemoveBorder(window w,int cnt,int x,int y,int wi,int h)
UINT n,d

n=GetDlgItem(w1.hWnd,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)

setsize w1,x,y,wi,h,cnt
return
ENDSUB

sub handler(),int
select @class
 case @idclosewindow
  run=0
endselect
return 0
endsub

Brian

Brian

Andy,

Got it! All of a sudden it occurred to me what was wrong. The 2024 was a
"magic number" you needed in previous versions of IB, and not needed with IWB

Change this line: n=GetDlgItem(w1.hWnd,2024+cnt)

to: n=GetDlgItem(w1.hWnd,cnt)

Brian

LarryMc

It's a little simpler to use the IWBasic commands to do it.

WINDOW w1
INT run,t
const WS_EX_CLIENTEDGE=512

openwindow w1,100,100,300,250,0,0,"Borderless Listview",&handler
setwindowcolor w1,rgb(150,180,180)

control w1,@LISTBOX,"",70,20,150,180,@VSCROLL,1
setcontrolcolor w1,1,0,rgb(0,200,250)

' Remove the 3D border from an edit control

MODIFYEXSTYLE w1, 0, WS_EX_CLIENTEDGE|@border, 1
MODIFYSTYLE w1, 0, @border, 1
REDRAWFRAME w1, 1

for t=1 to 20
addstring w1,1,str$(t)
next t

run=1
waituntil run=0

closewindow w1
end


sub handler(),int
select @class
  case @idclosewindow
   run=0
endselect
return 0
endsub
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian


Andy

Thanks everyone,

The listboxes look great without a border now.

Once again - thanks!
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.