|
I have not used such a code defining function inside function. but i am eager to know why such a thing cannot be done. wht r the problems tht we come accross. does ur statement "givinge the inner function access to the outer function local variables" hold true?? I may sound silly, but i want to get it clarified.
|
|
|
|
|
Anonymous wrote:
i am eager to know why such a thing cannot be done
Of course it can be done, you just redefine the language
Anonymous wrote:
does ur statement "givinge the inner function access to the outer function local variables" hold true??
It is you asking about nested functions, I have no idea if you mean the Pascal flavour of this (slightly bizarre) concept. They give access to the local variables in the "function parent".
Why isn't this included in the C++ language definition? Who knows, I wasn't consulted - and if I had been, I had most certainly advocated against it
It leads to long and difficult-do-read functions, giving functionality that can be replaced by other constructs.
|
|
|
|
|
It does. Just put a class within another class, and hey presto - instant nested functions.
|
|
|
|
|
Probably because it is never necessary to have such a construct in C++.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
In MFC,can somebody explain me how the mapping takes place.I mean where does the info comes -list of messages?
Does it come from a database?
I know that DECLARE_MESSAGE_MAP() creates 3 entries.
One of which is structure of array which consists of eventsid and functions call.
|
|
|
|
|
hello blacktiger
mapping of messages happens in the message map (im not trying to be smart it really does )
DECLARE_MESSAGE_MAP is only half the story
in your cpp file there is something like this
BEGIN_MESSAGE_MAP(FxMarginsDlg, VDialog)
//{{AFX_MSG_MAP(FxMarginsDlg)
ON_BN_CLICKED(IDC_BUTTON_CLOSE, OnButtonClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
this is the message map. Entries are added by the Wizard in Visual Studio or you can edit it manually.
In this example the control with ID IDC_BUTTON_CLOSE is mapped to function OnButtonClose
Your best bet in understading how this works is to insert a command in an empty app, add a handler as above and set a breakpoint in the handler function. When the code hits the breakpoint you can look at the call stack and trace into the MFC code.
Hope this helps
|
|
|
|
|
How should I map my own events and notifications in MFC?
In my app I created a Dialog box in a SDI app where I have events in one Combo Box and Notifications in another Combo Box?
Now I wish to map events and notifications,
How should I proceed?
|
|
|
|
|
Events and notifications are really different names for the same thing. I would recomend you spend some time reading MSDN and online tutorials or a good Win32 programming book.
|
|
|
|
|
Check out this place. This might probably give some ideas.
http://www.codersource.net/mfc_tutorial_Part2.html
Thanks
Muthu
Muthukumar.V
|
|
|
|
|
hi
Wix XP SP2 brings new window's firewall and turns it on automatically. It blocks all the ports (which are not in common use like 80 and 21) and unsolicited traffic.
My software is wokring on some different port and connets to the serveral computer over the local network as well to the web server. So if either the source machine or the destination machine is XP SP2 it prompts the user for allowing the traffic.
I dont want this dialog box. In some cases software is required to do the work silently without any user interaction. But this XP SP2 does not denys to do so.
In the tech articles its mentioned that one can add the name of the application or the port it is using in the exception list which firewall ingnores during the traffic control if the the "Dont' Allow Exception" on the General tab is not checked.
So now I want to add my application name programmatically in this exception list. And when my work is over I would like to delete it from the list.
Can some one tell me the APIs to achieve this?
__________________
Vaibhav...
|
|
|
|
|
What's the use of a firewall if it can be bypassed programmatically? Can't you instuct your users that they must allow the traffic explicitly. I for one would be very, very... annoyed is a too weak word - by a program that silently circumvented my firewall...
|
|
|
|
|
Actually the scenario is some thing like this...
A user will run my software to migrate some settings of his PC to the other PC he has. He will be the Adminstrator for that other PC. Software pushes some destination agent to accomplish the work. The destination agen runs on the destination machine and migrates the necessary settings.
Again let me tell you that the user context in which this agent will run on the destination machine would be the Administrator of that destination machine. And I belive an adminstrator can change the firewall settings programmatically also.
I dont want the user to go explicitely on the remote destination machine and set the firewall settings.
I guess now the picutre is pretty clear..
--------------
Vaibhav...
|
|
|
|
|
|
Unbelievable, sort of negates the setting of a firewall in the first place!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I especially enjoy the VBScript examples... why not do it properly, and create a full virus writing API for script coders? ActiveTrojan?
|
|
|
|
|
Exactly, if I wasn't laughing at the absurdity of it I'd surely cry!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
The XP SP2 firewall is not allowing any other machine to connect it if the firewall is turned on.
ie. Say machine B has XP SP2 firewall (new windows firewall) and its turned on. There is one more machine on the same local network - machine A.
When machine A tries to access machine B on the same local network and same domain firewall on machine B does not allow access. If you turn off the firewall then access is allowed.
Does it mean any computer on the network can not access the machine B if the firewall is turned on?
In that case file sharing would be impossible.
Any clue?
------ Apart from that-------
The APIs to manipulate firewall settings are available in the XP SP2 PSDK RC1. But right now only the image version is availbale from which you may burn the CD.
If you are more interested to know about this you may visit this link.
http://blogs.tonygoodhew.com/xpsp2
--------------
Vaibhav...
|
|
|
|
|
Vaibhav Sanghavi wrote:
In that case file sharing would be impossible.
I don't know enough about the XP firewall, but this can't be true!??! A firewall that can be shut down with VBScript (at least when the API is released ) and by default stops file sharing inside a network...
I would suggest that you demand that the clients turn off the built-in XP firewall and get themselves a proper one - ZoneAlarm, for example. The XP-one seems like a dangerous joke.
|
|
|
|
|
Hello,
Sorry for the repost, but I didn't see the checkbox for ignoring <'s.
I am new to this forum, so howdy!
I am using Visual C++ 6.
I have a weird problem with SetItemText when trying to use multiple CListCtrls.
I have mail that I am reading from a POP3 server and trying to put it in separate CListCtrls based on certain mail header entries.
Here is a snippet of code that is causing the problems:
<snip>
for (msg_num=1;msg_num<=num_msgs;msg_num++)
{
cmsg_num.Format(_T("%d"), msg_num);
POP_messages[msg_num].pop_num = msg_num;
POP_messages[msg_num].msg_num = msg_num;
if (m_pop3handle.GetMailSubject(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (m_pop3handle.GetMailSender(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].From = msg;
m_listHam.SetItemText(nItem,1,(LPCTSTR)msg);
} else {
POP_messages[msg_num].From = msg;
m_listSpam.SetItemText(nItem,1,(LPCTSTR)msg);
AfxMessageBox((LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (strcmp(classified,"Ham") == 0) {
m_listHam.SetItemText(nItem,2, (LPCTSTR)cmsg_num);
m_listHam.SetItemText(nItem,3, "");
} else {
m_listSpam.SetItemText(nItem,2, "");
m_listSpam.SetItemText(nItem,3, "");
}
nItem++;
} // End for (msg_num=1;msg_num<=num_msgs;msg_num++)
<snip>
Now the problem is, that all the InsertItem calls get set properly, but only the SetItemText values for the first row get set. That is, none of the other rows get values set in the second and third columns.
The MessageBox show valid data coming through the msg variable, but SetItemText is not successful (i.e,returns 0).
Anybody ever seen a problem like this?
Now, if I let everything come into a single CListCtrl, then all the SetItemText calls return successfully and values are placed in the
second and third columns.
Another weirdness is that is I double up on the InsertItem statements, i.e.,
<snip>
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
<snip>
then I get a row as before, with data in just the first column, followed by a row with data in all three columns, where the first column entry is the same as the previous row.
That is, I get something like the following:
<subject>
<subject> <email address> <msg num>
<subject>, <email address>, and <msg num> actually have values.
Any help would be greatly appreciated. Please reply via email also.
Thanks,
Murrah
otrcomm@isp-systems.com
|
|
|
|
|
The return value from InsertItem() should be used as the first parameter to SetItemText() . You currently have them both using nItem , which is incorrect.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
David,
Thank you so much man, that did it!
I am new to Visual C++ (15 years on Unix/Linux boxes), and I feel like a fish out of water.
I know I will be using this forum quite a bit, since I have a few projects that require Win32 interfaces.
Thanks again,
Murrah Boswell
|
|
|
|
|
Hello,
I am new to this forum, so howdy!
I am using Visual C++ 6.
I have a weird problem with SetItemText when trying to use multiple CListCtrls.
I have mail that I am reading from a POP3 server and trying to put it in separate CListCtrls based on certain mail header entries.
Here is a snippet of code that is causing the problems:
<snip>
for (msg_num=1;msg_num<=num_msgs;msg_num++)
{
cmsg_num.Format(_T("%d"), msg_num);
POP_messages[msg_num].pop_num = msg_num;
POP_messages[msg_num].msg_num = msg_num;
if (m_pop3handle.GetMailSubject(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (m_pop3handle.GetMailSender(msg_num, &msg))
{
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].From = msg;
m_listHam.SetItemText(nItem,1,(LPCTSTR)msg);
} else {
POP_messages[msg_num].From = msg;
m_listSpam.SetItemText(nItem,1,(LPCTSTR)msg);
AfxMessageBox((LPCTSTR)msg);
}
}
else
{
m_pop3handle.GetLastError(&msg);
m_edtMsg += msg+"\r\n";
}
if (strcmp(classified,"Ham") == 0) {
m_listHam.SetItemText(nItem,2, (LPCTSTR)cmsg_num);
m_listHam.SetItemText(nItem,3, "");
} else {
m_listSpam.SetItemText(nItem,2, "");
m_listSpam.SetItemText(nItem,3, "");
}
nItem++;
} // End for (msg_num=1;msg_num<=num_msgs;msg_num++)
<snip>
Now the problem is, that all the InsertItem calls get set properly, but only the SetItemText values for the first row get set. That is, none of the other rows get values set in the second and third columns.
The MessageBox show valid data coming through the msg variable, but SetItemText is not successful (i.e,returns 0).
Anybody ever seen a problem like this?
Now, if I let everything come into a single CListCtrl, then all the SetItemText calls return successfully and values are placed in the
second and third columns.
Another weirdness is that is I double up on the InsertItem statements, i.e.,
<snip>
if (strcmp(classified,"Ham") == 0) {
POP_messages[msg_num].Subject = msg;
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
m_listHam.InsertItem(nItem,(LPCTSTR)msg);
} else {
POP_messages[msg_num].Subject = msg;
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
m_listSpam.InsertItem(nItem,(LPCTSTR)msg);
}
<snip>
then I get a row as before, with data in just the first column, followed by a row with data in all three columns, where the first column entry is the same as the previous row.
That is, I get something like the following:
<subject>
<subject> <email address=""> <msg num="">
<subject>, <email address="">, and <msg num=""> actually have values.
Any help would be greatly appreciated. Please reply via email also.
Thanks,
Murrah
otrcomm@isp-systems.com
|
|
|
|
|
Hi guys,
I want to know that how i can send and recieve messages to msn online users through my own program. For this, i was reading Microsoft RTC, but i haven't found any solution yet. Does RTC provide the mechanism of communication with msn online users? if not then what would be the solution ?
Common Man
|
|
|
|
|
Either use the COM API of MSN
or implement the protocol yourself
an example is here[^]
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi all,
I was thinking of starting my own little project, and, well... it looks like I don't know where to begin.
Well, actually, I kind of do: I can handle the UI part of it and some other parts too, but there are still a few very essential pieces missing. Namely:
* Opening a video file (AVI or MPEG) or an audio file (MP2, MP3, AVI, MPEG, WAV etc) for reading and finding out its format
* Loading the next frame from the opened video file
* Seeking to a specific frame and loading it
* Opening a video or an audio file for writing
* Letting the user choose codecs for the output file
* Saving a frame and/or audio data into an opened file
The main idea is to hide all the complexity of handling video files behind a simpler construct (e.g. data sources and streams). Once that I get to that level of abstraction, it will be easy to write UI and processing because I wouldn't have to worry about details.
So... that said, I am having trouble finding any tutorials or code examples that will get me started. There are quite a few DirectX tutorials on the 'Net, for example, that walk you through the basic tasks and give you the code to work with. MSDN is all good and nice, but it's not exactly the best resource for a beginner.
Now the question is... does anybody know of any tutorials, FAQs, sample code or anything else that could help me?
Thanks
M.C.
|
|
|
|
|