|
I'm not sure, that I understood the question. Can you rephrase it somehow?
Just meanwhile, you can check FAQ and related stuff @ www.ndis.com[^]
|
|
|
|
|
I will explain more.
To build a mobile IP node, I have to tunell an IP packet. That means I have to add a new IP header before the original IP packet. It is called encapsulating. When the receiver gets the encapsulated packet, it will decapsulate to get the original IP packet. See the picture below
The original IP packet:
--------------------------------------------------------------------------
| Extra info | source IP addr | dest IP addr | Data
--------------------------------------------------------------------------
After encapsulating:
--------------------------------------------------------------------------
| New ex-info | New source addr | New dest addr | Extra infor | source IP..
--------------------------------------------------------------------------
\_________________________________________/ \_____________________________
^ ^
| |
| |
New IP header Original IP packet
That is why I need to get the IP packets and encapsulate them before transfer to higher or lower layer.
However, when I read an example source code in the article "NDIS Packet Alteration/Encapsulation Techniques" from http://www.ndis.com/code_snippets/default.html. I see that what the we can get in MPSendPacket is an Ethernet Frame (an IP packet which is added an Ethernet header). So I don't know how to add a new IP header in this case.
Do we have another way to get IP packets without Ethernet header?
|
|
|
|
|
Hm, I think, this is because NDIS sits between ethernet-layer2 and IP. Therefore you need to handle it somehow.
I downloaded the sample you mentioned - this is a sample of VPN tunnel - this is done on the ethernet level, so whole ethernet packet is encapsulated.
What I think you have to do is remove the ethernet frame from the packet, construct new ipinip packet and add an ethernet header again.
Don't know another place, where you can get & modify IP packets.
|
|
|
|
|
This is part of an assignment to make a cash register-like program. This function works counting the change to be returned, except the pennies. I can't figure out why the assignment to the penny (global) variable isn't working. Any idea's?
void makeChange(double cost, double payed) {<br />
double difference;<br />
<br />
difference = payed - cost;<br />
<br />
twenty = (int) difference / 20;<br />
difference = difference - (twenty * 20);<br />
<br />
ten = (int) difference / 10;<br />
difference = difference - (ten * 10);<br />
<br />
five = (int) difference / 5;<br />
difference = difference - (five * 5);<br />
<br />
one = (int) difference;<br />
difference = difference - one;<br />
<br />
quarter = ((int) (difference * 100)) / 25;<br />
difference = difference - (quarter * .25);<br />
<br />
dime = ((int) (difference * 100)) / 10;<br />
difference = difference - (dime * .1);<br />
<br />
nickel = ((int) (difference * 100)) / 5;<br />
difference = difference - (nickel * .05);<br />
<br />
cout << endl << "Difference before penny: " << difference << endl;<br />
cout << "Value of penny before: " << penny << endl;<br />
cout << "> penny = (int) (difference * 100); // Why isn't this line working?" << endl;<br />
cout << "> difference = difference - (penny * .01); // This \"should\" be 0 now." << endl;<br />
<br />
penny = (int) (difference * 100); <br />
difference = difference - (penny * .01);
<br />
cout << "Value of penny after: " << penny << endl;<br />
cout << "Difference after penny: " << difference << endl << endl;<br />
cout << "Flushing cout: " << cout.flush << " <-- Does this matter?" << endl << endl;<br />
}
|
|
|
|
|
You did not indicate what was not working about that statement. Do you get a compiler/linker error, a run-time error, or is the result just incorrect? What are the values of payed and cost ? What are the types of the other variables?
I know the solution to your problem, but I would rather show you how to get the right answer rather than just give you the answer outright.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for replying. I am not getting any errors, just a faulty answer. payed and cost are both entered by the user at run-time. All of the others are int's. Just to avoid confusion, here's the code in it's entirety: (I've included sample output at the end.)
<br />
<br />
#include <iostream><br />
#include <iomanip>
using namespace std;<br />
<br />
void makeChange(double, double);<br />
void displayChange();<br />
bool isNotCool(double,double);<br />
<br />
int twenty, ten, five, one, quarter, dime, nickel, penny;
<br />
int main() {<br />
double cost, payed;<br />
<br />
twenty = ten = five = one = quarter = dime = nickel = penny = 0;<br />
<br />
cout << fixed;
cin.precision(2);
cout.precision(2);<br />
<br />
cout << "This program takes in the cost of an item and the amount given to " <br />
<< endl<br />
<< "pay for it, and displays the change." << endl << endl;<br />
do {<br />
cout << "Enter the cost and the amount given " << endl<br />
<< "to pay for it separated by a space: ";<br />
cin >> cost >> payed;<br />
} while (isNotCool(cost,payed));<br />
<br />
makeChange(cost, payed);<br />
displayChange();<br />
<br />
cout << endl << "END PROGRAM" << endl;<br />
<br />
return 0;<br />
}<br />
<br />
bool isNotCool(double cost, double payed) {
if (cost > 0 && cost < 100)
if (payed > 0 && payed <= 100)
if (payed >= cost)
return false;
return true;
}<br />
<br />
void makeChange(double cost, double payed) {<br />
double difference;<br />
<br />
difference = payed - cost;<br />
<br />
twenty = (int) difference / 20;
difference = difference - (twenty * 20);
ten = (int) difference / 10;<br />
difference = difference - (ten * 10);<br />
<br />
five = (int) difference / 5;<br />
difference = difference - (five * 5);<br />
<br />
one = (int) difference;<br />
difference = difference - one;<br />
<br />
quarter = ((int) (difference * 100)) / 25;<br />
difference = difference - (quarter * .25);<br />
<br />
dime = ((int) (difference * 100)) / 10;<br />
difference = difference - (dime * .1);<br />
<br />
nickel = ((int) (difference * 100)) / 5;<br />
difference = difference - (nickel * .05);<br />
<br />
cout << endl << "Difference before penny: " << difference << endl;<br />
cout << "Value of penny before: " << penny << endl;<br />
cout << "> penny = (int) (difference * 100); // Why isn't this line working?" << endl;<br />
cout << "> difference = difference - (penny * .01); // This \"should\" be 0 now." << endl;<br />
<br />
penny = (int) (difference * 100);
difference = difference - (penny * .01);
<br />
cout << "Value of penny after: " << penny << endl;<br />
cout << "Difference after penny: " << difference << endl << endl;<br />
cout << "cout.flush = " << cout.flush << " <-- Does this matter?" << endl << endl;<br />
}<br />
<br />
void displayChange() {<br />
<br />
if (twenty) {<br />
cout << twenty << " twent";<br />
if (twenty != 1) {<br />
cout << "ies" << endl;<br />
} else {<br />
cout << "y" << endl;<br />
}<br />
}<br />
<br />
if (ten) {<br />
cout << ten << " ten";<br />
if (ten != 1) {<br />
cout << "s" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (five) {<br />
cout << five << " five";<br />
if (five != 1) {<br />
cout << "s" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (one) {<br />
cout << one << " one";<br />
if (one != 1) {<br />
cout << "s" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (quarter) {<br />
cout << quarter << " quarter";<br />
if (quarter != 1) {<br />
cout << "s" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (dime) {<br />
cout << dime << " dime";<br />
if (dime != 1) {<br />
cout << "s" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (nickel) {<br />
cout << nickel << " nickel";<br />
if (nickel != 1) {<br />
cout << "ies" << endl;<br />
} else {<br />
cout << endl;<br />
}<br />
}<br />
<br />
if (penny) {<br />
cout << penny << " penn";<br />
if (penny != 1) {<br />
cout << "ies" << endl;<br />
} else {<br />
cout << "y" << endl;<br />
}<br />
}<br />
}
This program takes in the cost of an item and the amount given to
pay for it, and displays the change.
Enter the cost and the amount given
to pay for it separated by a space: .79 1
Difference before penny: 0.01
Value of penny before: 0
> penny = (int) (difference * 100);
> difference = difference - (penny * .01);
Value of penny after: 0
Difference after penny: 0.01
cout.flush = 1 <-- Does this matter?
2 dimes
END PROGRAM
But it does what it's supposed to, under certain circumstances:
This program takes in the cost of an item and the amount given to
pay for it, and displays the change.
Enter the cost and the amount given
to pay for it separated by a space: 25.99 100
Difference before penny: 0.01
Value of penny before: 0
> penny = (int) (difference * 100);
> difference = difference - (penny * .01);
Value of penny after: 1
Difference after penny: 0.00
cout.flush = 1 <-- Does this matter?
3 twenties
1 ten
4 ones
1 penny
END PROGRAM
Thanks for your help.
|
|
|
|
|
In the isNotCool() function, you are comparing two different types: double with int eger constants. Also, I question the name you've given this function. It is an example of a "double negative" which you learned about in grammar class. I suggest naming it IsCool() , returning false if any of the conditions fail, true otherwise.
Adam Fowler wrote:
penny = (int) (difference * 100); // Why isn't this line working?
difference = difference - (penny * .01); // This "should" be 0 now.
At this point, all that's left are 0-4 pennies. Yes?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
That's correct. By the time it get's to the assignment for penny, there will be only 0-4 pennies.
|
|
|
|
|
Adam Fowler wrote:
By the time it get's to the assignment for penny, there will be only 0-4 pennies.
Exactly. The input you should have tried to uncover a pattern was 0.78/1.00, 0.77/1.00, and 0.76/1.00. Notice that it is off by 1 penny each time. What this tells you is that 0.01 is stored internally as 0.009, which is not a fully penny. By changing the last statement to penny = (int) ((difference + 0.005) * 100.0) , you should see a "difference" in the answer.
BTW, the quarter, dime, and nickel assignments can be simplified a bit, too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
That fixed it. Thanks alot, I probably wouldn't have found that on my own (yes, I did try .79/1, .78/1, .77/1, .76/1). I guess the
cout << fixed;<br />
cin.precision(2);<br />
cout.precision(2);
didn't do what I expected it to. Thank you for your help, I appreciate it.
|
|
|
|
|
OS:winxp professional 2002 SP2
IDE: .net 7.1
When I create new project (MFC Application or C# Application), then an error prompted.
Error dialog says: Automation server can’t create object. (Summary, my .net not English version)
And I reinstall .net and Office, but the error still occurs.
How can I do?
|
|
|
|
|
I have a dialog app, that also has three other modeless dialogs that I use for overlays on part of the main dialog.
Unless needed, the modeless guys are hidden and disabled. But they are still receiving messages from the main dialog. This is causing problems because when the main dialog is painting itself, it is causing the hidden and disabled dialogs to repaint as well. And the disabled windows seem to be losing their pointers to the main dialog (seems to go out of scope), hence resouce problems.
Is there any decent way to stop the messages reaching the modeless dialogs - they are defined as popups?
Thanx,
Rick
|
|
|
|
|
How does
I have read articles about Control Messages and that by default they are sent to and handle by the parent of the Control... For example, when a CListBox is placed on a CDialog, using classwzard and resource editor... The messages for CListBox are automatically generated in the message map of CDialog....
But what if i have something like this....
The CListBox is placed on a DockingControlBar and the DockingCOntrolBar is placed on a CMainFrame (i.e. on a MDI application)... I want the messages from CListBox be handled by CMainFrame... Is this possible? Can i put MESSAGES from CListBox in the MESSAGE MAP of CMainFrame manually (w/o ClassWizard)?
|
|
|
|
|
How does CListCtrl notifies its parent or one of CWnd derived objects that wants to handle an ITEM SELECTION either by clicking on that item or by programatically selecting the item...
What are the messages sent?
Here's my program scenario, I have a SDI application..
Its a picture viewer with a thumbnail.. The thumbnail is implemented as a listbox with image icons, (icons being the thumbnail of the image file).. The listbox is placed on a DockingControlBar... the DockingControlBar is owned by CMainFrame... I want the View to be updated each time the user cliks on the image files in the listbox... How do i do these?
I have read many articles and source codes related to this, but mostly it involved CListView.. I can't figure out how do I incorporate those source codes that i have read to the program that i am making..
|
|
|
|
|
The CListCtrl is just a control wrapper around a CListView. So to handle item selection you have to handle the LVN_ITEMCHANGED message.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I'm playing around with the UxTheme library to paint some custom controls and make them look XP-like.
I was painting a scrolling band, which I was doing as a big scrollbar basically, and I'm not sure what is the difference between SBP_LOWERTRACKHORZ and SBP_UPPERTRACKHORZ. They both look the same as the background on a scrollbar. Anybody knows?
Better yet, anybody knows where can I find a snapshot of a window with all the parts labeled?
Is not a big deal, as I say, they look exactly the same. But the curiosity is killing me!
Thanks,
-Luis
|
|
|
|
|
I'm using the CIconDialog (an excellent control) to select icons for my app, but am having problems storing them. Currently my app serializes it's data into a single file, and I have tried to store the icons using CImageList, but it never seems to work. What is the best way to locally store off an icon the user has selected.
So far, articles on storing icons have been pretty scarce in my hunting.
|
|
|
|
|
If you look at how Visual Studio behaves, you sure noticed that the layout and content of the GUI is context dependent.
For instance, while you compile some commands are not available. While you debug, the debug toolbar appears by magic and disappear again when you exit debugging. If during a debug session you open the "View Register" dialog, next time you debug the IDE will propose you the same dialog in the same screen position. If we are editing a dialog box resource, then some specific toolbox appear.
Depending on what you are doing, Visual Studio changes the set of toolbars, menu and views available to you. It also remember your preferences about screen positioning.
Does anybody have an idea about to write a Context Manager, which is also persistent (if you close and reopen VS, it will still remember your preferences).
Thanks
Regards,
Fabio
|
|
|
|
|
Most of the stuff your talking about is handled by the MainFrame in MFC. VS is making use of the Load/SaveBarState() functions, but passing through the DEBUG/NONE DEBUG profile names. When moving from one to the other, it calls SaveBarState(CURRENT) and then LoadBarState(TARGET).
This causes the ocrrect toolbars/windows to be shown. As long as all these context windows are floating/dockable windows, then they will saved/restored correctly.
If you vote me down, my score will only get lower
|
|
|
|
|
Roger,
thanks for your mail.
Beyond the technicality of how to execute the operation, I was interested in understanding the underlying architecture. I am looking for a generic algorithm/data structure that keeps track of when to switch from one context to another, and what each context should contain.
That's should also be dynamic, as like in VS, it my application is possible to load addins which may define their own context (tollbars, active commands, etc).
I think it must be a sort of variation of the Model View Controller design pattern, but I am failing to find relevant material.
Any suggestion of any sort is greatly appreciated (even if you know a forum specialised in GUI architectures or in design patterns might help).
Thanks
Regards,
Fabio
|
|
|
|
|
Hello,
Can somebody help me with the following?
I have a dialog based application with a CRichEditCtrl. I read some text in the CRichEditCtrl. When I right mouse click in theCRichEditCtrl, I want the caret to move to the cursor position. I've created a handler for the right mouse click. Any suggestions on how to move the caret?
Thanks,
dlarkin77
|
|
|
|
|
void MyClass::RightClickHandler(CPoint point)
{
CPoint pt(point); //Get current mouse coordinates
ClientToScreen(&pt); //Convert to screen coordinates
// Get the dimensions of the richeditctrl
CRect rectRichEdit;
m_myrichedit.GetWindowRect(&rectRichEdit);
// Calculate the offset of the mouse into the richeditctrl
CPoint NewPoint(pt.x-rectRichEdit.left, pt.y-rectRichEdit.top);
// Get the char index at the new point
int nCharIndex = m_myrichedit.CharFromPos(NewPoint);
// Put the caret at that index
m_myrichedit.SetSel(nCharIndex, nCharIndex);
}
-Hope this helps
|
|
|
|
|
Can anyone tell me how to change the background color of a edit box , when the edit box is dialog form in a MFC application based program.
Can anyone please help me regarding this matter.
Philip
|
|
|
|
|
You can change the background color of an edit control in a dialog by handling the WM_CTLCOLOR message in the dialog:
class MyDialog : public CDialog {
COLORREF _BkgColor;
HBRUSH _BkgBrush;
};
BOOL MyDialog::OnInitDialog()
{
_BkgColor = RGB(0,255,0);
_BkgBrush = ::CreateSolidBrush(_BkgColor);
}
HBRUSH MyDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
{
hbr = CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
if (pWnd()->GetDlgCtrlId() == IDC_MY_EDIT_CONTROL) {
pDC->SetBkColor(_BkgColor);
hbr = _BkgBrush;
}
return hbr;
} In the OnInitDialog() handler for the dialog, we initialize the background color value and create a brush in that color. The WM_CTLCOLOR handler is called OnCtlColor . The edit control for which we want to change the color has the resource ID IDC_MY_EDIT_CONTROL . We set the text background to our background color using SetBkColor() , and the overall background for the control by returning the brush we created.
Software Zen: delete this;
|
|
|
|
|
Hello!
I have several password edit controls in my application. I wanted to rebuild the look of the Windows XP login dialog (so with the nice black dots).
I am currently using this:
TCHAR tchDot = (TCHAR)(_T('z') + 27);
m_pEditPw.SetPasswordChar(tchDot);
This works very fine on Win98, but on Win2000 and WinXP there are spaces between the dots, so it doesn't look like ***, but like * * *.
Any ideas how to fix this?
Thanks and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|