?
Solved

Turning off border of a Listbox in VB6?

Posted on 2004-03-29
9
Medium Priority
?
1,451 Views
Last Modified: 2013-11-13
I'm finding it strange that I can't adjust the borderstyle of a VB6 listbox.  I want to turn it off so that it is not visible and so that the listbox can blend in with the surrounding background color.   Anyone know how this can be done?  

I'm not opposed to seeing a solution using Win32 API to accomplish this.

Thank you for your time!
0
Comment
Question by:steveuci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 10

Expert Comment

by:Kavar
ID: 10710672
WOW, thats crappy...

Best I can think of... Use a Line (set the width to a couple of pixels to make it easier
make the line the background color of your listbox, then position right on top of the border, should make it look like the inside of the listbox (making it appear 1 or 2 pixels higher) but should hide the border :)
0
 
LVL 14

Expert Comment

by:wayside
ID: 10713334
The Windows API solution to this would be to remove the WS_BORDER style from the list box when it created by the CreateWindow() call. It might also be possible to change this style using Get/SetWindowLong(), although the docs don't explicitly say that this style can be changed after the window is created.

I don't know vb6 well enough to know if you can tie into the control creation and remove the WS_BORDER style, though.
0
 

Author Comment

by:steveuci
ID: 10715806
Kavar, I thought about doing something like that, with a box shape control, but for some reason both that box shape and your Line idea can't seem to rise above a listbox control z-order-wise; the line always gets hidden by the listbox no matter what.  So that can't work as a workaround unfortunately, so I'll hold out for a more concise solution.

wayside, I'll experiment a little bit with your ideas and see what can be done.  

Any other ideas?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 10

Expert Comment

by:Kavar
ID: 10715897
okay then... if nothing else pans out... (I don't think you can change window styles once they are created)

create a text box without a border, place it on top of listbox, whenever getfocus or mousedown or keydown, send them to listbox, whenever listbox changes update textbox text

your other (more techinical, probably better solution, is to create a borderless list box class...)
0
 
LVL 10

Accepted Solution

by:
Kavar earned 1600 total points
ID: 10716330
WAY TOO EASY...

Dim result As Long
Dim style As Long
style = -16
ws_border=&H800000
result = GetWindowLong(List1.hwnd, style)
result = result And Not (WS_BORDER)
result = SetWindowLong(List1.hwnd, style, result)
0
 
LVL 14

Expert Comment

by:wayside
ID: 10716545
Glad it worked.

MSDN is not clear on whether the border can be changed after the window is created, but apparently you can. :)
0
 

Author Comment

by:steveuci
ID: 10716573
Well well well!  That's fantastic!   Works like a charm :D

Thanks Kavar!  I'll accept your answer as the solution, but will try to give credit to wayside for mentioning the Get/SetWindowLong first.
0
 

Author Comment

by:steveuci
ID: 10716599
^ Hmm, not sure if that's even possible -- I'm new to experts-exchange and don't see a way to assign credit to multiple contributors!   Sorry to wayside, you were on the right track at least.

Thanks again Kavar.
0
 
LVL 14

Expert Comment

by:wayside
ID: 10716640
>Sorry to wayside, you were on the right track at least.

Not a big deal.

But just so you know, you can split the points between different contributors when you go to accept an answer. See here for details:

http://www.experts-exchange.com/Programming/help.jsp#hi19
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question