|
-
May 6th, 2000, 05:21 PM
#1
Thread Starter
Member
Okay, here is(are) my problem(s):
I'm using VB 6.0 in Win98. I have made an app that has two form. In form number 1 is a listbox called list1. Its multiselect property is set to extended. In form 2 is a filelist box that shows only *.mp3-files. This object is also been set to extended multiselection.
a) I want to select one more files from filelist box (form2) and then add them to the listbox of form one. But how?
b) And how does multiselection work in listbox?
c) And is there any kind of way to divide listbox to two different columns, like directory and filename. And if user wants she/he can minimize the space that either dir-column or filename-column uses (dragging with mouse)
And the last question (this one has nothing to do with the first three):
d) Is it possible to change windows title from my vb-application. I mean this window isn't a windows on my app. It can be for example Excel's or Word's windows. Can I change their windows title....???

RieBBo
-
May 6th, 2000, 09:42 PM
#2
Addicted Member
Wow, you hid alot of questions in such an innocent looking thread title! Anyways, here's your answers:
A) + B)
You need to use the Selected property of the (File)ListBox:
Code:
Private Const LB_FINDSTRINGEXACT As Long = &H1A2
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Sub MatchSelections()
Dim idx As Integer
Dim iMatchPos As Integer
For idx = 0 To File1.ListCount - 1 Step 1
If File1.Selected(idx) = True Then
iMatchPos = SendMessage(List1.hwnd, LB_FINDSTRINGEXACT, 0, ByVal File1.List(idx))
If iMatchPos >= 0 Then
List1.Selected(iMatchPos) = True
End If
End If
Next idx
End Sub
C) To do this you can use the MS FlexGrid Control (add it
to your project from the components dialog). Play around
with it to get your desired effect. The only problem with using
this is that you don't get the 'MultiSelect' effect, but
you do get complete control over the cells, so maybe you
could put arrows (">") in the far left column of every row
that is selected. Keep in mind though that the SendMessage
API call will no longer work with the FlexGrid, so you'll
have to step through each row to find your matches.
D) To change another Window's title you first need to get
the Handle of the Window you want to change. I'm not going
to show you how to do that here, there are TONS of examples
on this site already. To change the title you need to use
the SetWindowText API call, as follows:
Code:
Private Declare Function SetWindowText _
Lib "user32" _
Alias "SetWindowTextA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Private Sub ChangeAppTitle(hOtherWnd As Long, sTitle As String)
If hOtherWnd <> 0 Then
Call SetWindowText(hOtherWnd, sTitle & vbNullChar)
End If
End Sub
Whew, hope this helps.
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
-
May 7th, 2000, 03:42 AM
#3
Thread Starter
Member
Thanks man,
but still i can't get it work. Where I should paste this code for A and B? And should I use some call -string. I'm just a beginner and.... 
And one question more: How can I delete an item from listbox? I mean the one is selected. How does this work if I have selected more than one item? I have tried couple of methods but they wont work. They just remove all items from listbox, one by one...
And is there a link to a page that would show how to get a window to handle?
Thanks in advance,
RieBBo
-
May 7th, 2000, 05:49 AM
#4
Addicted Member
I'm sorry I didn't read A) carefully enough, I thought you
wanted to match all of the selections made in FileListBox
with the entries in the ListBox, oops! To copy all of the
selected items in the FileListBox to the ListBox use the
following code:
Code:
Private Sub CopySelections()
Dim idx As Integer
For idx = 0 To File1.ListCount - 1 Step 1
If File1.Selected(idx) = True Then
Call List1.AddItem(File1.List(idx))
End If
Next idx
End Sub
I'm not too sure what you're asking in B), but I think that
it is answered in the previous example. It just allows
you to Highlight several entries in the ListBox.
To remove all of the selected items in a (File)ListBox just
use the above code, only modified a little bit, as follows:
Code:
Private Sub RemoveSelections()
Dim idx As Integer
For idx = 0 To File1.ListCount - 1 Step 1
If File1.Selected(idx) = True Then
Call File1.RemoveItem(idx)
End If
Next idx
End Sub
As for a link to an example of how to attain a Window's handle,
I'll get back to you. I want to find you a good example, be
warned however that the code to do this requires a fair
amount of knowledge of how the API (Application Programmer
Interface) works.
Back in a bit
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
-
May 7th, 2000, 06:08 AM
#5
Addicted Member
Hey! I'm back, here's a few good examples:
Keep in mind though that these are fairly complicated,
to use them effectively I suggest that you learn how to
use the API first (at least the fundamentals, it's a
big topic). Good Luck!
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
-
May 8th, 2000, 09:24 PM
#6
Thread Starter
Member
Thanks a lot!!! You've been very helpful and kind to me, SonGouki
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|