C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-24-2002, 10:26 PM   #1
the Corvetter
 
Join Date: Sep 2001
Posts: 1,584
Getting FULL filename from listbox

I made a listbox (standard with the LBS_STANDARD flag) and I sent the listbox the LB_DIR message (with params to put all files and directories in the listbox). Well, I got the listbox to have the filename strings in the listbox, but I need the listbox so when the user dblclicks the item, I get the filename. I would get the index of the click, and then get the string at the index, but that would only be the filename (e.g. "test.txt"). I want the path and file (e.g. "C:\folder\test.txt"). How would I do this with the listbox? Thanks...

Garfield
__________________
1978 Silver Anniversary Corvette
Garfield is offline   Reply With Quote
Old 01-25-2002, 05:48 AM   #2
Registered User
 
The15th's Avatar
 
Join Date: Aug 2001
Posts: 125
hello;

The problem is that your using LB_DIR, because it sets the files with the old dos style. If i were you i would change the way you set your list box. I would either use the FindFirstFile, FindNextFile functions, or i would get whatever directory the user is setting the files from, and then append the file name on the end of that, then i would output the whole file name and location to the list control. Actually the way i would do it is i would just store the current directory location in a buffer and then call that when the user dbl clicks, so they dont see the full directory name just the file name, but when you call on gettext it will get the full directory and file name, so you can shell..() it or whatever you want.

hope this makes some scence.
__________________
arrh, i got nothing good to say.
http://www.praxis1.vic.edu.au/home/dcola/
The15th is offline   Reply With Quote
Old 01-25-2002, 09:25 AM   #3
the Corvetter
 
Join Date: Sep 2001
Posts: 1,584
Yes, I was thinking about appending the filename (from the listbox) onto the full pathname, but how would I get the directory of the view of the listbox at the point in which the user dblclicks? Thanks...

Garfield
__________________
1978 Silver Anniversary Corvette
Garfield is offline   Reply With Quote
Old 01-25-2002, 05:22 PM   #4
Registered User
 
The15th's Avatar
 
Join Date: Aug 2001
Posts: 125
I need a little bit more background information before i can help you any further. Are all the files in the same directory? Are you setting the files with a OpenFile dlg box? Is the user able to set any file on the directory from any location?

After just reading your first post, it sounds like your just setting one directory, which in that case you could just store that location when it is first set, and call upon it on the dblclk message.

Anyway just let me know how your setting your location.
__________________
arrh, i got nothing good to say.
http://www.praxis1.vic.edu.au/home/dcola/
The15th is offline   Reply With Quote
Old 01-25-2002, 06:20 PM   #5
the Corvetter
 
Join Date: Sep 2001
Posts: 1,584
Well, I want to use all of the directories possible. The list box should display the files and the "[..]" to go up and down through the directories. And then at the right directory, the user clicks the file, but I also want to get the full filename including the path. How can I do this?

Garfield
__________________
1978 Silver Anniversary Corvette
Garfield is offline   Reply With Quote
Old 01-26-2002, 02:10 AM   #6
Registered User
 
The15th's Avatar
 
Join Date: Aug 2001
Posts: 125
quite easily;

If you have already enabled the user to navigate through their directories that means your using GetCurrentDirectory() and SetCurrentDirectory(). When you store this information you can just call back on it later. Have you already setup your proc to navigate through the directories? All you need to do is call GetCurrentDirectory (MAX_PATH + 1, DirectoryBuf) ; and hold that information untill the user moves to a new location, then any file name inside the list control will be in the location held in DirectoryBuf.

I hope im helping you, if you would like some code just ask me and ill write some for you, but try and write your own, its more fun that way!
__________________
arrh, i got nothing good to say.
http://www.praxis1.vic.edu.au/home/dcola/
The15th is offline   Reply With Quote
Old 01-26-2002, 06:20 AM   #7
the Corvetter
 
Join Date: Sep 2001
Posts: 1,584
Okay, I know where to go from here. Thanks!
__________________
1978 Silver Anniversary Corvette
Garfield is offline   Reply With Quote
Old 01-26-2002, 09:33 PM   #8
Refugee
 
face_master's Avatar
 
Join Date: Aug 2001
Posts: 2,052
Quote:
Well, I got the listbox to have the filename strings in the listbox...
Can you please tell me how becuase the stuff on msdn is confusing me...
__________________
Please direct all complaints regarding this post to the nearest brick wall Have a nice day.
face_master is offline   Reply With Quote
Old 01-27-2002, 08:28 AM   #9
the Corvetter
 
Join Date: Sep 2001
Posts: 1,584
Quote:
Originally posted by face_master

Can you please tell me how becuase the stuff on msdn is confusing me...
What you have to do is create the child window listbox. And then send the message:

SendMessage(hwndList, LB_DIR, DIRATTR, TEXT("*.*"));

to fill the list box with the filename strings. DIRATTR is a whole list of constants for displaying what type of files, directories. Simply as that. And then you can program to move through the directories with testing the string of the listbox.

Garfield
__________________
1978 Silver Anniversary Corvette
Garfield is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Im getting an error and i cant figure out why. please help. ominub C Programming 8 04-11-2009 01:49 AM
Pass Filename to another function awesmesk8er C Programming 9 10-24-2008 01:43 PM
How to cast a ListBox item to an int for a switch statment? Swaine777 C++ Programming 8 09-26-2004 08:52 PM
hashing help alokin C Programming 17 10-28-2002 06:33 PM
Viewing full filename in ListBox? SyntaxBubble Windows Programming 4 12-09-2001 10:21 PM


All times are GMT -6. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22