|
>> so it seems that we both had a defective perception of each other anyway...
The larger point: You shouldn't be abusive to anybody.
|
|
|
|
|
e40s wrote: The larger point: You shouldn't be abusive to anybody
what i thought when i read you : You shouldn't have replied to Mr. DavidCrow like that either
|
|
|
|
|
Again, I ask you where? "How?"
What about "How?", other than its conciseness, offends you?
Nothing at all tense was exchanged beforehand in the conversation to contextually read terseness, and hence rudeness, into it. Frustration, however, can be read into it. (Thanks could easily be assumed among most readers.) People who don't derive joy from offending posters out of a sense of insecurity wouldn't read what you read into it.
Although I did pause considerably before posting that as one word. I had wanted to preface it beforehand with what I always try to preface anything with: "Thank you very much for replying to my post." But as I had still only intended to post "How?" in trailing, I chose the route of informality.
What is it about toxcct that wants to not only assume the worst about his fellow man, but to insult them too? If toxcct learns in milieu, it's an example, but if others do it's only having something they can stick in their own code. If somebody asks about one thing, he doesn't know main(). Stuff like that. I think David was also wondering why you mistreat the poster that way.
|
|
|
|
|
Hi,
add a string member to your class 'CMemMapCppClientDlg'
in header file
class CMemMapCppClientDlg
{
...
protected:
CString m_strContent;
public:
CString GetContent();
};
in the source file
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM)
{
HANDLE hMapFile = NULL;
PVOID pView = NULL;
hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);
if(hMapFile == NULL) {
MessageBox("Can not open file mapping");
return 0;
}
pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
if(pView == NULL) {
MessageBox("Can map view of file");
CloseHandle(hMapFile);
return 0;
}
LPSTR szContent = reinterpret_cast(pView);
int nLen = strlen(szContent);
while(nLen > 0) {
m_strContent += *szContent++;
--nLen;
}
m_strContent += '\0';
m_strContent.Replace("\n", "\r\n");
MessageBox(m_strContent);
if(pView) UnmapViewOfFile(pView);
if(hMapFile) CloseHandle(hMapFile);
return 0;
}
CString CMemMapCppClientDlg::GetContent()
{
return m_strContent;
}
Now you can use the GetContent function to get the content
{
...
CMemMapCppClientDlg dlg;
...
CString strContent = dlg.GetContent();
...
}
codito ergo sum
|
|
|
|
|
Thank you BK.
Perfect answer. Extremely helpful.
I'll try this in my project and hope it works.
|
|
|
|
|
At this point, your confusion seems to be less about C++ and classes and more about high-level programming languages in general. For example:
void foo ( void )
{
x = 1;
}
void main( void )
{
int x;
} In this example, the variable x is an auto matic variable that is local to the main() function. It cannot be accessed by the foo() function. To remedy that, you'd need to give x global scope like:
int x;
void foo ( void )
{
x = 1;
}
void main( void )
{
x = 5;
} Now foo() and main() both have access to the global variable x .
Fast forward to C++ and classes results in much the same. Consider:
class myClass
{
void foo( void )
{
int x;
}
}; In this example, the variable x is an auto matic variable that is local to the foo() method. It cannot be accessed by any other member of the class. To remedy that, you'd need to give x class-level scope like:
class myClass
{
private:
int x;
void foo( void )
{
x = 9;
}
}; In this example, the variable x is accessible by all methods of the class. Now if you wanted x to be made accessible to users of the class, then you'd have to put it in the public section like:
class myClass
{
public:
int x;
void foo( void )
{
x = 9;
}
}; Any clearer? There's much more to it (e.g., multiple instances sharing the same data), but I think this is enough to get you going.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I learned about global and local variables when I started programming in C a couple of years ago from K&R. Both were clear. I don't use C often, and when I don't it becomes rusty, but global and local variables were pretty basic stuff then as now. They are not the issue.
I could have carried this out with a global variable, but everywhere I turned I was advised to use a class member variable. This is why your confirmation of that advice as well as your convincing statement that the ::OnDataReady contruct was off limits was so valuable.
But I don't know the class nomenclature or what the rules are beyond the basics of public, private, protected; I don't know that I'm supposed to write something this way
CString CMemMapCppClientDlg::GetContent()<br />
{<br />
return m_strContent;<br />
}
and I also don't know that there necessarily isn't a pointer or something or other way to get at something behind a scope resolution operator that I don't know about because I've never learned C++ (unless someone experienced with the language like you tells me in the earlier post at top), and I've never learned about both objects and class syntax in the same breath. I don't know that in addition to overloaded operators that there may also be some way to dereference some variable out of an off-limits ::OnDataReady method. That's why your posts helped and why BK's post was so incredible important in helping me to learn how the syntax is constructed while getting at the variable--not just any way, but the experienced C++ coder's way.
Otherwise why bother. I'd have just used a global and called it a day, but I wouldn't have grown. I wouldn't have learned the proper way. Everybody was telling me to use a class member variable, but I had no idea how to implement one, what to write?, which goes where?, etc. It's Greek to me. Now I can learn from BK's generous and incredibly detailed example.
Thanks all. Everyone. Including txcct. You all helped me to learn how to do this.
-- modified at 16:03 Thursday 8th November, 2007
|
|
|
|
|
Hi!
I'm looking for a collection of useful functions finalised
to joining paths tokens, retrieving file extension, file name
or parent directory and so on...
Just working with string (or char) data.
Where can I find them?
(I'm using Windows platform, not a Linux one)
Tnx
Mike
|
|
|
|
|
I don't know if you can use Windows APIs, but these always work well for me...
Shell Path Handling Functions[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
There's some wacky functions in that list. It's nice of Microsoft to give us such a varied list of functions, they've helped me out a lot.
But, there's functions in there that I can't figure a use for...
Like, why would someone use PathUndecorate[^] or PathMakePretty[^]
The other side, there's some great stuff in there too. PathAppend, PathAddBackslash come to mind.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
PathUndecorate could be very usefull when copying files out of the IE cache. PathMakePretty is wierd, mostly because it only works on all uppercase path. I only discoverred this wonderfull collection of functions within the last month, after doing nearly all my path manipulations by hand for 20 years, except for splitpath/makepath from the CRT.
|
|
|
|
|
I need to open some window application ( Form ) from some other application.
I know the name of the other ( father ) window that need to create and open my window - but that all ... i don't know anything else about the other window.
How can i do it ?
Thanks for the help .
|
|
|
|
|
Do you want to show these windows or want to create them of other application?
|
|
|
|
|
I want to create them and show them from the other application.
|
|
|
|
|
If you want different CFormViews in just one Application, this[^] will help you.
If you want an Application to call another application, then you should use ShellExecute or thread functions.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I think he needs to make and show forms of other applications.
|
|
|
|
|
Hi all,
Is there anyone who knows add-in for VC2005 to make snapshot of current project before serious changes made to the project?
Regards,
L.
|
|
|
|
|
How about using a source control system ? That's what they are (partly) made for.
|
|
|
|
|
I agree -- version control is what you need! Most of us can't live without it...
Commonly what you do - is store all of your code and project materials in it's special database. As you make changes, you check-in those changes to the master copy -- which lives on a server.
You can also create branches -- which basically makes a snapshot of the master. You can then work on the snapshot, make changes and check them back in without altering the master.
Once your happy with your changes, you merge them back into the master... incorporating these changes in one transaction.
Within the masters, you can record labels (put down a marker) and also do all kinds of reporting -- like who changed what or when did this change...
There's various products out there -- some of them are more difficult to manage. I currently use SVN... have used CVS and Microsoft SourceSafe.... SVN is the best so far... but any idiot could install a SourceSafe system...
I know there's other choices out there.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Dear all
i have the following class header
#include "stdafx.h"
#include < iostream >
using namespace std;
class test
{
private:
int n1;
int n2;
public:
test(int n1,int n2);
output(std::ostream& outs);
};
VS 2005 display the following error
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
for
output(std::ostream& outs);
any tips
i searched the net and i didn't find any solutions
thanks all
bye
|
|
|
|
|
you have to have a return type for your class methods.
Use void if there's no applicable type...
class test
{
private:
int n1;
int n2;
public:
test(int n1,int n2);
void output(std::ostream& outs);
};
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
more than 3 hours try to solve this problem and then at the end IT IS VOID LOL
thanks alot
|
|
|
|
|
Adore C++ wrote: more than 3 hours try to solve this problem
Next time try this[^]... where the fourth entry is this[^]
it should prove to be faster.
|
|
|
|
|
Hi Guys
I want to associate a button when clicked to connect to a port so that i can send data to an extenal device. I really don't have the idea even where to start, so if anyone can maybe refer me to a site i can read about that or offer some advice would really save me.
Thanks guys.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Wamuti wrote: I really don't have the idea even where to start
This could help[^]
|
|
|
|