|
Simple things first - try changing the network cable.
This could be caused by a poor connection affecting the magnetics - remember there is no such thing as ditigal electronics merely badly distorted analogue!
Elaine (quantised fluffy tigress)
|
|
|
|
|
Trollslayer wrote: there is no such thing as digital electronics merely badly distorted analogue!
Eww. I just had a nasty flashback to my Control Systems class in college.
Z-transforms, blech .
Software Zen: delete this;
|
|
|
|
|
I'm interested in a tutorial on how to build Vc++ apps with windows, buttons, etc. With examples, and (hope) free. Maybe, downloadable.
|
|
|
|
|
Other than just jumping in and getting your feet wet, do you have access to a bookstore, or perhaps a library?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
|
For a beginer isn't easy...
|
|
|
|
|
See Here[^] maybe it is some helpful to you
|
|
|
|
|
|
I think the simplest way to start with visual program building is to create a new project with VC6. VC7 and VC8 complicate matters a little, but the steps are basically the same. The following description is for VC6.
Start by creating a new MFC application (exe) project named "MFCTest" and select a dialog based application. Leave all the defaults if you are unsure what they mean. After VC6 has created your project build it. You should see 0 errors and 0 warnings. Run it and you should see a simple dialog.
Start by going to the resource view and display the "IDD_MFCTEST_DIALOG" dialog. Add an edit bot to it by selecting it in the tool bar ("ab|") and draw it inside the dialog. A box with the word "Edit" appears. Open its properties (RMB->properties or ALT+ENTER) and change the ID from "IDC_EDIT1" to "IDC_NAME". Add another one and change its ID from "IDC_EDIT2" to "IDC_ADDRESS". We will now setup these boxes when the dialog opens.
The definition of the dialog is in the file "MFCTestDlg.cpp". In line 91 you find the function "BOOL CMFCTestDlg::OnInitDialog()" which is the function called during the creation of the dialog and where you may setup items, like values in edit boxes and populate lists. This function starts by setting up the menu and the icons and then has a "TODO:" section where you add your code.
Add the line "CEdit* np=(CEdit*)GetDlgItem(IDC_NAME);" after the "TODO:" to tell the program to find the edit box with the identifier IDC_NAME and put its address in "np". Then add the line "np->SetWindowText("Abracadabra");" to set the text in the edit box. Do the same to the address box by adding the lines "CEdit* ap=(CEdit*)GetDlgItem(IDC_ADDRESS);" and "ap->SetWindowText("Mars");".
Now compile and run the program and you will have the edit controls setup by the time the dialog opens. Now, to get text when the user types it, we have to add a handler to be called when the text changes.
Go to the resource view and select the "IDD_MFCTEST_DIALOG" dialog. Then select the IDC_NAME box. Press CTRL+W (to invoke the wizard) and verify that the project is "MFCTest", the class name is "MFCTestDlg", and that the selected object ID is "IDC_NAME". Then select "EN_CHANGE" in the "messages:" box. The "Add Function" button will become available and you may select it and accept the proposed function name. The "EN_CHANGE" becomes bold, and the "Edit Code" becomes the default button. Click it and you will go to line 177 of "MFCTestDlg.cpp".
The created function "void CMFCTestDlg::OnChangeName()" will be called when the text in the IDC_NAME box changes. For this example we will get whatever text the user types here and put a reversed version in the IDC_ADDRESS box. insert the following lines in the function:
CEdit* np=(CEdit*)GetDlgItem(IDC_NAME);
CEdit* ap=(CEdit*)GetDlgItem(IDC_ADDRESS);
CString s;
np->GetWindowText(s);
s.MakeReverse();
ap->SetWindowText(s);
First the edit boxes are found. Then a new string is created and filled with the contents of the name edit box. Then we reverse it and put the result in the address box. Note that setting the text in the address box would invoke its EN_CHANGE message, and so if you did the same in the handler for the address (if we had any) as we are doing in the name you would end up with an infinite loop of one handler invoking the other indefinitely.
If you want to add variables to the dialog class you can have the wizard do that for you or you can go to the "MFCTestDlg.h" file and add them yourself. The "main()" equivalent is found in "MFCTest.cpp" - the dialog creation is found in line 57 and it's invocation (open) is done with "int nResponse = dlg.DoModal();". Note that this call only returns when the dialog is closed.
I hope this quick start guide helps you. This is how I started it and works for me. The rest of the variations (like diferent controls and such) you can learn as you go along. MFC functions will always respond to the F1 key for help.
Rogério
|
|
|
|
|
I would like to create a base class that forms a template for inherited classes, in order to use similar names for different implementations.
How is this possible in C++?
Jon
|
|
|
|
|
Do you mean create an abstract base template class?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Any easy way to convert "0xFF" to 0xff? I have hex value sent as strings, but I need to manipulate them as ints. ANy ideas?
-C
|
|
|
|
|
Use strtol(..., 16) or strtoul(..., 16) .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ahh.. Thanks. It worked perfectly!
|
|
|
|
|
You could use a function such as this:
BYTE HexToByte(LPCSTR cpHex)
{
BYTE cRetVal;
if (*cpHex < 58)
cRetVal = *cpHex - '0';
else
cRetVal = *cpHex - '7';
cRetVal <<= 4;
cpHex++;
if (*cpHex < 58)
cRetVal += *cpHex - '0';
else
cRetVal += *cpHex - '7';
return cRetVal;
}
onwards and upwards...
|
|
|
|
|
strtol(..., 16) or sscanf(str, "%X", &myInt)
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi All,
I have successfully automated MSWord with VC++. Now what I need to do is open an *.doc file and perform searching of some particular words in that file .How I can perform it in my programme .
Please Help me
Thanks in Advance
George K Jolly
-- modified at 12:16 Wednesday 2nd August, 2006
|
|
|
|
|
Post the code you've used to automate word.
|
|
|
|
|
For Automation Just see the link
http://support.microsoft.com/kb/178749/E-US/
|
|
|
|
|
DWORD retval;
LPWSTR domaincontroller = NULL;
LPUSER_INFO_3 buffer = NULL;
NET_API_STATUS nStatus;
WCHAR *uni_domain = NULL;
WCHAR *uni_username = NULL;
uni_domain=L"Elko";
uni_username=L"richardb";
ofstream outValues;
outValues.open("ValidUserName.txt",ios::out);
outValues << uni_domain << endl;
outValues << uni_username << endl;
// This nStatus returns a true. But if I comment this part out.....
nStatus = NetGetDCName(NULL, uni_domain, (LPBYTE *)&domaincontroller);
if(nStatus != NERR_Success){
retval = NULL;
return false;
}else{
return true;
}
if(domaincontroller == NULL){
retval = NULL;
return false;
}else{
return true;
}
.... the "second" nStatus returns false. The NetUserGetInfo funtion is giving me alot of problems.....
nStatus = NetUserGetInfo(domaincontroller, uni_username, 3, (LPBYTE*)&buffer);
if(nStatus != NERR_Success){
retval = NULL;
return false;
}else{
return true;
}
.... can anyone plz help
Thanx in advance
Regards
Programm3r
|
|
|
|
|
Programm3r wrote: .... the "second" nStatus returns false.
So what's the problem? If NetUserGetInfo() is returning 0 , then it was successful.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have 3 Questions.
1. Why a size of an empty class is 1 byte?
2. if this code executes, again the size of class is 1 byte (padding not occuring even padding size is 4)
class MyClass
{
char i;
};
MyClass m;
printf("%d",sizeof(m));
3. for this code it will print 8 bytes as size (default padding 4 bytes)
class MyClass
{
int i;
char i;
};
MyClass m;
printf("%d",sizeof(m));
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
Sarath. wrote: 1. Why a size of an empty class is 1 byte?
Because the standard requires it to be so. Basically, it is so you avoid problems where you try to allocate 0 bytes of memory (ever try to do int* pi = new int[0] ?). If an empty class is always at least 1 byte, then you can't have that problem.
Sarath. wrote: 2. if this code executes, again the size of class is 1 byte (padding not occuring even padding size is 4)
The padding for characters is 1 byte. If that is all that is in your class, then it won't bother padding it since it is almost guaranteed to be placed on a byte boundary.
Sarath. wrote: 3. for this code it will print 8 bytes as size (default padding 4 bytes)
This actually occurs because the compiler packs extra characters for you (if you use pragma pack, you avoid this). Since you have more than just your character now, it places enough memory for your class to end on a double word boundary. This makes it more efficient if you declare an array of these objects since the integer values will be guaranteed to be on the proper boundaries in memory.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks alot for your reply. it was quite informative.
one more question which has been raised when I read your answer
int* p1 = new int[0];
*p1 = 10;
printf("%d",*p);
delete p1;
In the above code, printing of the above code will work fine. but delete fails.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|