|
well, I sure dont have the answer to ur questions, but have a suggestion to make. Why dont u try organising ur huge question into paragraphs, so that will improve its readability!!!
Also I didnt get what u meant by the following:
JeremieJ wrote:
The picture display examples I have seen all want you to already have the pictures and none of them show you how to open a picture from a file or just automatically display the picture from a pre-defined location.
Good Luck with ur project.
Mahadevan.
|
|
|
|
|
I mean that they want you to code the picture into the program and they don't show you how to open a picture from the hard drive and display it to the screen or automatically display a picture to the screen when u press a button. You know like open a picture and display it to the screen like paint.
|
|
|
|
|
I am trying to write some C++ code (on a Linux machine) that will allow me to join a multicast group. I have successfully coded and compiled a basic program using setsockopt() and the optnames IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
I am aware that without notifying the router (via the IGMP protocol) I am limited to receiving only multicasts originating from hosts on my side of the router.
My question is....Has my call to setsockopt() automatically sent and IGMP packet to the router? If not, does anyone have any C++ code that demonstrates the implementation of the IGMP protocol?
Thanks!!
Cameron
|
|
|
|
|
byrd_cam wrote:
Has my call to setsockopt() automatically sent and IGMP packet to the router?
It should, in theory. Supposedly, the network card (or driver) is supposed to take care of this. In practice however, some don't. I'm not sure if Linux guarantees that the IGMP messages are sent, but I do know that Solaris and some other Unix's don't.
Not sure if that helps
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi ,
I am trying to implement PrintPreview in my SDI App. Basically I want to print a log and I have the DataStructure set up to provide me with a line by line text input that I use in the OnPrint Method.
Due to the fact that these lines of text may exceed a Page's width , i have a variable that helps me keep track of lines and I move on to the next page .
Everything draws ok , but the page Numbers (shown in the preview Dialog) are messed up
page 1 instead of page 2 and vice versa , but sometimes it seems allright . Plus at this moment i cannot get the page numbers to get displayed on the preview ? How do i achieve this ? and a solution to my previous problem
Thanks
Engineering is the effort !
|
|
|
|
|
Hi there,
I know that it's bad coding practice to have public data members but what if you have a private struct containing about 10 fields. If I create a public struct containing the exact same fields and assign values you to them say from a form, can I pass that public struct as a parameter to the mutator method to set the private data members to? If the struct is public, I guess I don't need to pass it to the mutator. It can just be referenced within the method named for example Get_Data(). I included a snippet of code below:
public:
struct Data_1
{
int name;
int age;
//several other fields
};
Data_1 data1;
Get_Data();
Put_Data();
private:
typedef struct
{
int name;
int age;
//several other fields
}Data_2;
Data_2 data2;
void Get_Data()
{
data2.name = data1.name;
data2.age = data1.age;
}
void Put_Data()
{
data1.name = data2.name;
date1.age = data2.age;
}
Values of fields within the public structs are assigned to member variables in a form. Once set, the data in the private struct will then be written to a file. Am I doing this right or have I violated the coding convention?
Thanks!
|
|
|
|
|
I have an enum that I'm trying to declare in my App, that will be accessed by the other dialogs and such in the project. However I keep getting the following error message: error C2061: syntax error :identifier 'MODE'
I've tried to do this before and ended up doing a workaround. I'd rather do it the right way and have never seemed to get the hang of it. Here's what I have in my class definition, with the line it specifies in bold:
class CBugReporterApp : public CWinApp
{
public:
CBugReporterApp();
enum _MODE {NEWMODE,EDITMODE,BROWSEMODE} ;
_MODE MODE;
public:
virtual BOOL InitInstance();
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
void SetAppState(MODE enumState); MODE GetAppState(void);
private:
MODE m_enumState;
};
I know it's something very stupid, but I can't figure out what I'm doing wrong. Any help would be appreciated. Thanks in advance
[insert witty comment here]
bdiamond
|
|
|
|
|
bdiamond wrote:
I know it's something very stupid...
No, just something you may not have thought of. The enum keyword is not like typedef in that you also have to declare an actual variable of the new type before it can be used. So, just remove the _MODE MODE; statement, and change the three references to MODE to be _MODE instead. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I tried that first with just 'MODE' as the name of the enum like this:
class CBugReporterApp : public CWinApp
{
public:
CBugReporterApp();
enum MODE {NEWMODE,EDITMODE,BROWSEMODE} ;
public:
virtual BOOL InitInstance();
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
void SetAppState(MODE enumState);
MODE GetAppState(void);
private:
MODE m_enumState;
};
but I get this errormessage:
error C2248: 'CBugReporterApp::GetAppState' : cannot access protected member declared in class 'CBugReporterApp'
[insert witty comment here]
bdiamond
|
|
|
|
|
error C2248: 'CBugReporterApp::GetAppState' : cannot access protected member declared in class 'CBugReporterApp'
What line generates that error? That seems to be something else - this code fragment looks much closer to being correct than the first one you posted.
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
please see post below in response to DavidCrow's question. Thanks!!
[insert witty comment here]
bdiamond
|
|
|
|
|
You'll need to provide the relevant code for the GetAppState() method.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
in looking at the above message where I just declare the enum as 'MODE', here's what I have:
MODE CBugReporterApp::GetAppState(void)
{
return m_enumState;
}
and here's the line it's now crashing on in my UI handler for a menu button: pCmdUI->Enable(theApp.GetAppState() == CBugReporterApp::BROWSEMODE);
[insert witty comment here]
bdiamond
|
|
|
|
|
At the time the compiler encounters the MODE type, it does not know "who" it belongs to since the GetAppState() method is defined outside of the class declaration. So, you can either put the definition of the GetAppState() method inside of the class declaration, or you can qualify the MODE type by prefacing it with CBugReporterApp . Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes, that makes sense and I changed it and it works for that problem. However I'm still getting this message for the UI update function that I showed earlier:
error C2248: 'CBugReporterApp::GetAppState' : cannot access protected member declared in class 'CBugReporterApp'
As you can see from my class definition, the function is declared as public, so what the heck is it talking about? I don't mean to be a nuisance, but I've gone too long making band-aids for certain problems or just getting something to work and not knowing why.
[insert witty comment here]
bdiamond
|
|
|
|
|
bdiamond wrote:
However I'm still getting this message for the UI update function that I showed earlier:
Show me the whole function and I'll give it a look.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
here's the function:
void CMainFrame::OnUpdateMaintenance(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
pCmdUI->Enable(theApp.GetAppState() == theApp.BROWSEMODE);
}
I've also tried it with
int i = (int)theApp.GetAppState();
and I still get the same error
[insert witty comment here]
bdiamond
|
|
|
|
|
I think you would be better served my adding three "status" methods to your CBugReporterApp class. Something like:
class CBugReporterApp : public CWinApp
{
public:
bool IsNewMode( void ) { return NEWMODE == m_enumState; }
bool IsEditMode( void ) { return EDITMODE == m_enumState; }
bool IsBrowseMode( void ) { return BROWSEMODE == m_enumState; }
}; Does this help?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Even when I comment out the UI handler code I get the following errors:
error C2143: syntax error :missing ';'before 'CBugReporterApp::GetAppState'
error C2556: 'int CBugReporterApp::GetAppState(void)' : overloaded function differs only by return type from 'CBugReporterApp::MODE CBugReporterApp::GetAppState(void)'
error C2501: 'MODE' : missing storage-class or type specifiers
error C2371: 'CBugReporterApp::GetAppState' : redefinition; different basic types
[insert witty comment here]
bdiamond
|
|
|
|
|
Your header file seems fine. I think the problem is in the implementation of your GetAppState(); (your cpp file). If you dont believe me, try commenting the source within GetAppState(). you wont get any errors.
Try checking that function instead.
Regards,
Maha
|
|
|
|
|
The problem is, as the code is currently written, MODE is a member variable of type _MODE.
You are trying to use this member variable (MODE) instead of the type (_MODE) for parameters and other variables.
Either change the functions to use _MODE instead of MODE
or use a typedef like:
typedef _MODE MODE;
|
|
|
|
|
Never declare anything after using DECLARE_MESSAGE_MAP or DECLARE_DYN* (all the MFC macros) without resetting your access. They change the access setting of your class.
Place a new "public:" prior to the definition of SetAppState and GetAppState.
(Well, that and fixing the _MODE problem which you have already done.)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
OK, thanks. I will put this in my notekeeper for future reference.
[insert witty comment here]
bdiamond
|
|
|
|
|
My version information is stored in MyProject.rc under the VS_VERSION_INFO . I also have a defined variable with the version info as its value that I use for an about section of the program. Is there a short way (maybe only a few lines of code) to set the File's Properties Version Tab to the value of that variable (i.e. change FILEVERSION and PRODUCTVERSION in VS_VERSION_INFO)? Basically so I don't have to go into the VS_VERSION_INFO and change it each time myself. So on build it reads the variable's value and changes the VS_VERSION_INFO automatically...
|
|
|
|
|
Something like this, perhaps?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|