|
david fox wrote:
CString FileName;
...
char File[100];
Why are you mixing char* and CString so heavily?
Most things can be done with CString (use ist buffer-access functions).
And all you buffers (char* and those that you take from CString) should really be of size _MAX_PATH !
Hope this helps
|
|
|
|
|
Hi,
A while ago , and I cant find it now, I thought I saw a post about creating a directory chooser using some MFC class. Can you please give me some ideas on how to implement this dialog in the simplest way?
Thanks,
ns
|
|
|
|
|
You don't need MFC class - SHBrowseForFolder API will do nicely.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
BROWSEINFO strBrwsInfo = {0};
LPITEMIDLIST lpIdl ;
char szFilePath[MAX_PATH] = {0} ;
strBrwsInfo.hwndOwner = m_hWnd ;
strBrwsInfo.pidlRoot = NULL;
strBrwsInfo.pszDisplayName = (LPSTR)malloc(MAX_PATH) ;
strBrwsInfo.lpszTitle = "Select the folder..." ;
strBrwsInfo.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT ;
strBrwsInfo.lParam = 0 ;
lpIdl = SHBrowseForFolder(&strBrwsInfo);
if(lpIdl)
{
if( SHGetPathFromIDList( lpIdl, szFilePath ) == FALSE )
return false;
}
else
return false;
free(strBrwsInfo.pszDisplayName);
You get the Folder path which the user selects in szFilePath
Renjith-CPian.
|
|
|
|
|
Many thanks. One question though. I'm using mfc and I think it wil all fit in, but I dont know where to get m_hwnd. Also Do we define MAX_PATH or is it known?
Whose m_hwnd is it?
Thanks,
ns
|
|
|
|
|
MAX_PATH is a standard C definition. I think it's #defined in <stdlib.h> . m_hWnd can be got from your CWnd derived object's GetSafeHwnd() method.
That being said, I humbly suggest you use Davide Calabro's CFileDialogST class (call the SelectFolder() method) to select a folder. It's a drop-in MFC replacement and rocks big time! Here's the article[^].
PS: How did the college send-off go?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ah Thanks. Thats my task this morning - to implement two browsers. My original plan of embedding my blobs into the db failed because though I put in very valid bmp data into APpendChunk, it never showed up in my THBImage (a acool image control)> but if I put the same bmp in directly it shows fine. SO appendchunk is putting in extra stuff or something and theres no info on that. SO my db now quizzes for the directory where the images are located, goes out grabs them, and extracts the binary info striaght from the bmps.
Sunday was hectic. Four hour drive, then parking hassle since the whole world was there with their parents on the first day of moving in. Then went to the bookstore for $500 worth of textbooks. After which we made repeated trips to depts stores and grocery stores etc for -"I forgot shampoo" , " I need acne stuff", and then we remembered laundry. So three separate trips in the heat to the grocery store. Four trips to Target like stores for phone, lamp, and then in search of a mini fridge. EVery one was all out of this popular dorm item, so we'll get in a couple of weeks.
(ANother trip). He seems to be surviving okay - configured his email, found the dining hall, and has a roommate from Louisiana.
I'm off to investigate your link above. I slept early last night and was wide awake at 2 AM so I've been up since 2:30 pottering around. Getting old - dont need too much sleep.
I need another computer at work to install dot.net on so I can play with it. I installed the beta on my primary machine last year and didnt like the side effects of having both 6 and 7 on the same machine. Of course I could buy a laptop (personal) - when I get time to breathe, I'll think about it. In the meantime, this project marches on. My partner went along with an assumption I had made about the info embedded in his binary files , and I was wrong. So I have to unravel a bit of code and weed it out. Thats not fun. Oh well.
|
|
|
|
|
WoW! It looks cool and seems ultra easy to use . No work at all! Hey - thanks so much! I was going to slave over this last night and got lazy.Glad I did. Its a nifty solution!
|
|
|
|
|
Yeah, Davide did a great job! Now go rate his article "5".
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I'm using a vector to save objects. Looking at STL documentation it says that it will make a copy of the objects for the vector when using push_back(). I'm probably doing this wrong but it does not appear to make copies of my data.
To make the copy, I have a default constructor which does nothing but clear all of the object's attributes. Next, I have an operator= overload but it never gets called when calling push_back(). I thought that a copy constructor used operator= or do I have to make it explicit like this??? :
class myObj
{
public:
myObj() { attribute1 = 0; attribute2 = 0;}
myObj(myObj& obj)
{
*this = obj;
}
myObj& operator=(const myObj& objPassed)
{
attribute1 = objPassed.attribute1;
attribute2 = objPassed.attribute2;
return *this;
}
private:
long attribute1, attribute2;
};
All I have now is the default constructor and operator= overloaded. I thought the compiler provided a default copy constructor.
My implementation code looks like:
myObj theObj;
for(int i = 0; i < numObjsToBuild; i++)
{
theObj.attribute1 = value1;
theObj.attribute2 = value2;
myObjArray.push_back(theObj);
}
Anything wrong here?
|
|
|
|
|
VC6 doesn't compile your code, unless you change the reference in copy constructor to const. Otherwise, the code works OK.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
The compiler provides default copy constructor & assignment operator - they take the form of copying/assigning each member of the class. For your class, the compiler-supplied methods would be fine, as you've only got POD(Plain Old Datatype) data members.
The copy constructor will never call the assignment operator unless that's the way you implement it. In addition, I think vector implements element insertion (which is what push_back calls down to) without using the assignment operator (i.e. copy constructor only).
It's probably all working OK - the STL tends to most of the time
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Thanks, for the help guys. Actually, it really is more than just POD type. I have some arrays in there. I have another problem related to this but won't bother you guys with it. However, I'd like to make a comment about how STL was implemented.
In troubleshooting this, I put a breakpoint in my overload of operator= and found that this was getting called way more than I expected. It turns out that the push_back() as you said, calls insert(). But, why does it not just insert the object at the end, without calling the copy constructor/operator= once for each object that is already in the vector? For example, if I have two objects in the vector, when I place the third via push_back(), insert() appears to copy the first two objects in the vector to other objects (I'm assuming they're moving up the chain and that an empty object was put in the front of the vector and the contents are being copied to it, then the 2nd object is copied to the original first obj, and finally my new object is copied to the original 2nd object). Huh??? Alot of copying going on.
There doesn't appear to be a way to put an object into the vector without this copying going on is there?
|
|
|
|
|
Is it possible to tell the OS to tell us when an opened socket gets diconnected, for whatever reason?
I have a project which maintains opened sockets, and sending messages on them occasionnally. The problem is that when the socket get disconnected, I will only notice when I try to send a message. I would like to be informed by the OS asynchronously (using a callback function for instance).
If this is possible, could you point to some useful info on how to achieve this?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
In theory if your socket is opened and you are 'looping through' the read function (recv ). You could setup a timeout before you call the read function. In that case, if the peer connection is closed (or lost), the read function will fail. If you are using Microsoft Socket extension, you may want to look at WSAAsyncSelect function.
VOTD: "The work of God is this: to believe in the one he has sent." - John 6:29(NIV)
|
|
|
|
|
Send regular data packages, then you'll see if your socket is still connected. e.g. the IRC server sends a regular "ping-data-chunk" to see if the clients are still there.
|
|
|
|
|
I want to know what are the basic steps for creating a toolbar that doks in internet explorer (like the one the codeproject made).
|
|
|
|
|
|
I am designing a MDI program. there are many MDI child window. How can I know the user change the activated status from one MDI child window to another? Why do I want to do this? Because when one MDI child window is deactivated, I have to save its data to files.
Thanks in advance.
|
|
|
|
|
If you are using MFC CViews you will get OnActivateView() and OnKillFocus(). If you are using the Windows API you will get WM_KILLFOCUS.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
How to transform 16-bit value to corresponding symbol UNICODE ?
Obvious transformation:
TCHAR ch = (TCHAR) nValue;
will transform nValue to ANSI .
Best regards,
Eugene Pustovoyt
|
|
|
|
|
For TCHAR to be a Unicode character, you need to #define _UNICODE before doing #include <tchar.h> . Alternatively, try wchar_t ch = (wchar_t)nValue; - wchar_t is always a 16-bit character.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Not sure what you're asking. You have a 16-bit unicode value in a WORD? Then just do:
WCHAR wch = (WCHAR) nValue;
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Not. I have a word array which I want print as unicode symbols.
for (WORD i = 0; i <= 0xFFFF; i++)
{
pDC->TextOut(LOBYTE(i)*16, HIBYTE(i)*16, (TCHAR)i);
}
This code always print the ANSI code ignored the hibyte. Why?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I am using appendchunk to put images in my database (blobs). Only problemis it 'appends' as advertised. I want to clear the db and overwrite it when I run the program again so an AddChunk would be good. but I dont see one. ALso, I thought maybe some parameter in the call to appendchunk would tell it to overwrite (despite its name) but I didnt fiind that either...
Ideas?
ns
|
|
|
|