|
A control needs to have the WS_TABSTOP style for it to be included in the tab order.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Aarrgh!!
How can I get the file names from a dir?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
there are many articles on CodeProject that demonstrate this (look in the Files and Folders section, and, here's mine). or, if you want to do it yourself, you can use FindFirstFile or _findfirst.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
But if I want to get the file names from only "C:\Pictures\MyNewPic" only... how can I specify a dir so all these findfile functions only searches one dir?
I can't explain better I think!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Read the MSDN docs on FindFirstFile or _findfirst.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I assume you want this? sometimes I find I need to attach to the directory and not use a path.
hFind = FindFirstFile("C:\\Pictures\\MyNewPic\\*.*", &FindData);
bOK = (hFind != INVALID_HANDLE_VALUE);
while(bOK)
{
bOK = FindNextFile(hFind, &m_FindData)
}
|
|
|
|
|
bOK = FindNextFile(hFind, &FindData)
I MUSt learn to type, and too proof read!
|
|
|
|
|
Ted Ferenc wrote:
FindFirstFile("C:\\Pictures\\MyNewPic\\*.*", &FindData);
Ooh!
So I can just do that, okay... I didn't understand it when I read in MSDN Library.
Thank you!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I want to make a proxy scaner, but I don't know how to open a socket.
I want to make connection to some computer and try to make a TCP/IP connection to a definite port. If I can connect to try whether It is a proxy server.
But I do not know how to make this in MFC.
Can someone help me?
Trin2
|
|
|
|
|
ummmmm i would suggest u do some reading about tcp/ip and the various protocols b4 taking on this level of project if u dont understand how to open a socket
try www.w3c.org and look up some rfcxxx docs
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
lauren wrote:
try www.w3c.org and look up some rfcxxx docs
Now that's the nicest way I've seen somebody tell somebody else to sod off in a while
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi everyone. I have a question about the use of CFile. I have the code below, and the filename is that of a file which I have tested and determined exists, and is not shared. The file is an HTML file, and I want to take the contents of the HTML file (the text), and put it into a CString. The string will then be parsed and the hyperlinks extracted.
<br />
CFile cFile;<br />
CString strFileContents;<br />
<br />
cFile.Open(m_strFileName, CFile::modeRead | CFile::shareExclusive);<br />
cFile.Read(&strFileContents, cFile.GetLength());<br />
cFile.Close();<br />
The problem with the code above is that when the Read is performed, the program crashes. I tried using an old style C string in place of a CString, the data is read but a bunch of garbage chars are at the end of the string, and the program crashes when I hit Close(). Anyone know what I am doing wrong? I really want the file contents in a CString, because the necessary memory is allocated dynamically, and the CString Find functions are great for parsing.
|
|
|
|
|
First of all, you can't put the whole file in a single CString object.
You may try to read the file line by line.
You do not use the Read function correctly, first parameter is the block you read, the second is the size of that block. Usualy used for reading a binnary file.
Good Luck!
Trin2
|
|
|
|
|
CSting doesn't allocated anything till you initialize it.
Since you didn't allocated, you got crash.
Change your code to the following:
cFile.Read(strFileContents.GetBuffer(SIZE), cFile.GetLength());
After finishing working with the string call
strFileContents.ReleaseBuffer();
|
|
|
|
|
Excuse me.
Today,I study the WTL Library's CSimpleArray class source code,I find the following code:
<code>template<class T>
class CSimpleArray
{
T* m_aT;
...
class Wrapper
{
public:
Wrapper(T& _t) : t(_t)
{
}
template <class _Ty>
void *operator new(size_t, _Ty* p)
{
return p;
}
T t;
};
void SetAtIndex(int nIndex, T& t)
{
new(&m_aT[nIndex]) Wrapper(t);
}
...
}</code> I can not understand the syntax about "new(&m_aT[nIndex]) Wrapper(t)" ,anyone can explain it? thanks first.
SIMPLE IS BEAUTY
|
|
|
|
|
ZBUILDER wrote:
I can not understand the syntax about
ZBUILDER wrote:
new(&m_aT[nIndex]) Wrapper(t);
returns the pointer and that new allocates using that pointer
* * * Code the dreams * * *
|
|
|
|
|
Then What about Wapper(t)?
And How does it modify the Adderss of &m_aT[nIndex]?
SIMPLE IS BEAUTY
|
|
|
|
|
It's called placement new. You're executing the Wrapper-constructor on an already allocated memory block.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
ZBUILDER wrote:
new(&m_aT[nIndex]) Wrapper(t)
It's called placement new. It executed the constructor Wrapper(t) on a preallocated memory block &m_aT[nIndex]. So basically, you're telling new not to allocate new memory for the object but use existing memory.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
hi everyone,
i added a context menu to my sdi project, based on treeview, but the context menu doesn't work correctly. the problem with my context menu is that whenever i right single click on a treenode, the context menu doesn't popup, which the context menu supposes to popup. the context menu only pops up when i double right click on a node.. i'm running winxp and using visual studio.net.. any suggestion is welcome.. thx in advance.
this is the code i added to my message map:
ON_WM_CONTEXTMENU()
this are the codes that i used for my context menu:
void CLeftView::OnContextMenu(CWnd *pWnd, CPoint point)
{
CMenu menu;
menu.LoadMenu(IDR_MENU1);
menu.GetSubMenu(0)
->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this);
}
|
|
|
|
|
NOTE: This is a fairly long post.
I have not implemented my own template class before though I have used STL and MFC template classes extensively. I have a situation that I believe can be best dealt with by writing a template class.
Here's the deal:
I have 10-20 console apps which generate data files of various formats from a specified input data source of a known type. For the most part the source data defines the structure of the output based on its configuration. The simplest way to implement these is to just iterate the input records and then in an inner loop examine the data's configuration and produce the correct output.
What I would like to do is to create a template class from which I can construct an "execution plan". The template class would provide an interface for 1) examining the data source and making decisions on the output structure, 2) iterating the data source recordset, 3) following the steps that were decided in #1 for each record.
The way I see it being implemented is something like this (pseudocode):
class BaseExecutionStep
{
}
class ExecutionStep_OutputNumber
{
short sLength;
bool bLeadingZeroes;
short sDecimalPlaces;
}
class ExecutionStep_OutputDate
{
string strFormat;
date dtNullDate;
bool bHideNullDates;
}
class ExecutionStep_OutputText
{
short sLength;
bool bRemoveUndesiredChars;
short sAlign; (left, right, center)
}
class ExecutionStepFactory
{
ExecutionStep* CreateStep(SomeSourceObject);
}
template class ExecutionPlan<ExecutionStepFactory, DataSource, Filter>
{
BuildPlan(); // build a list, array, set of ExecutionSteps using the ExecutionStepFactory
DescribePlan(); // for auto-documentation
ExecutePlan(); //
}
What I would ideally want is to be able to use this same execution plan template class to make the development of these "iterative" proccesses a little more standardized. Ideally I could create any new ExecutionStepFactory and any new DataSource object and be able to use the template to deal with the nasty little details of actually doing this work.
Is this a reasonable use of templates? Is there a better way than what I have descrived here?
|
|
|
|
|
This looks like an example of some really contemporary design techniques (policies) described by Andrei Alexandrescu in his book "Modern C++ Design."
While his ideas look great in theory, I've never been game to try them out because they look like a maintenance nightmare and it would be harder to find developers capable of maintaining such sophisticated code. Don't be fooled - writing (good) templated code is *much* harder than it first might appear (and VC6's support for templates is woeful!)
There's no reason why a simpler solution would not be just as effective e.g. creating your worker classes as you describe but instantiating them and passing them to ExecutionPlan as runtime parameters rather than templated, compile-time parameters.
If you go the template route, I'd be very interested to hear how it went. Write an article about it!
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Thanks for the feedback.
Taka Muraoka wrote:
maintaining such sophisticated code
I tend to agree, but not having done it I am just not certain how complex it will be in the end.
Taka Muraoka wrote:
There's no reason why a simpler solution would not be just as effective e.g. creating your worker classes as you describe but instantiating them and passing them to ExecutionPlan as runtime parameters rather than templated, compile-time parameters.
This was my first idea, but even this will be somewhat complicated and will require a funamental understanding of the implementation to be able to use it. The reason I am looking into templates is because I think the complexity may not be much more and would be far more flexible (I think??) with not much more actual coding on my part.
Taka Muraoka wrote:
If you go the template route, I'd be very interested to hear how it went. Write an article about it!
While I need this for an actual real-life problem, I had thought of using it as the basis for a future article. Only time will tell.
Thanks again,
Matt Gullett
|
|
|
|
|
Matt Gullett wrote:
I am just not certain how complex it will be in the end.
Writing templated code is *much* harder than writing bog-standard OO code because you have no idea what your template parameters are. If you know they're only going to be standard data types like an int or a float that's one thing, but when they're classes like what you're proposing, it gets much more tricky. You either require that all classes have a uniform interface, in which case you might as well just have a class hierarchy, or you allow a varying interface.
With a class hierarchy, you have a base class with a bunch of pure virtual functions and derived classes have to implement them, regardless of whether or not they actually use them. The cool things about policies is that Alexandrescu takes advantage of the fact that template code that is never used doesn't get compiled (and therefore cannot cause compile errors). So he passes in classes with varying interfaces and as long as you don't try to use functionality that is not provided by your template parameter classes, your stuff will work just fine.
The book is worth a read but it's really tough! I couldn't read more than a chapter at a time because it just made my head hurt. I still don't understand half of it
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Thanks for the additional advice. I actually own this book, but I have never fully read it. I guess I need to get it out and re-read it.
One thing that concerns me in your statement:
Taka Muraoka wrote:
The cool things about policies is that Alexandrescu takes advantage of the fact that template code that is never used doesn't get compiled (and therefore cannot cause compile errors).
As I understand it, this is not really true. If I need to export a fully-qualified template class from a DLL, the compiler will always compile the whole thing. My software applications make heavy use of DLLs and this has already been an issue when working with STL.
Anyway, you have just about convinced me to not bother with the template based solution, but I will keep researching a little. I have a little time before I need to make a decision.
Thanks,
Matt Gullett
|
|
|
|