|
ULONG ulP = inet_addr(szIPAddress );
|
|
|
|
|
i dont get, please explain.
i am using this code but it makes the mfc application crash.
len = strlen(fff);
if(strlen(fff) > 0 && strcmp(fff, "\n") != 0)
{
while(fff[i] != '.')
{
c[j] = fff[i];
j++;
i++;
}
m1 = atoi(c);
j = 0;
i++;
ZeroMemory(c, 3);
while(fff[i] != '.')
{
c[j] = fff[i];
j++;
i++;
}
m2 = atoi(c);
j = 0;
i++;
ZeroMemory(c, 3);
while(fff[i] != '.')
{
c[j] = fff[i];
j++;
i++;
}
m3 = atoi(c);
j = 0;
i++;
ZeroMemory(c, 3);
while(len > i)
{
c[j] = fff[i];
j++;
i++;
}
m4 = atoi(c);
j = 0;
i++;
ZeroMemory(c, 3);
ipAdd.SetAddress(m1, m2, m3, m4);
}
|
|
|
|
|
You may be over complicating the conversion of the 4 number parts of the IP address.
Try this instead:
int m1,m2,m3,m4;
sscanf(fff,"%d.%d.%d.%d",&m1,&m2,&m3,&m4);
ipAdd.SetAddress(m1,m2,m3,m4);
Of course, you'll need to validate the IP address is in the proper format.
|
|
|
|
|
this method shows wrong ip in the ip address control.
|
|
|
|
|
The variable fff must be a string only containing a valid IP address.
try this:
LPSTR lpIPAddress = _T("127.0.0.1");
int m1, m2, m3, m4;
sscanf(lpIPAddress,"%d.%d.%d.%d",&m1,&m2,&m3,&m4);
ipAdd.SetAddress(m1,m2,m3,m4);
Make sure you're passing in just the IP address in the sscanf function.
|
|
|
|
|
it is working now. since i am using
fileh.ReadString((LPTSTR)fff , 100);
therefore i have to use the following code for the correct result ---
swscanf((LPCTSTR)fff,_T("%d.%d.%d.%d"),&m1,&m2,&m3,&m4);
thanks for the help.
|
|
|
|
|
You're welcome! Glad you got it working.
|
|
|
|
|
I assume you are talking about CIPAddressCtrl .
The method CIPAddressCtrl::SetAddress take 4 BYTE parameters (see : doc on MSDN[^])
So, you will need to extract each "part" from the string and convert each substring to a BYTE. (manually or int_addr[^])
This signature was proudly tested on animals.
|
|
|
|
|
Hello,
I have a program that has a dialog box - call this 'box1' on top of another dialog.
I want to create a 'box2' that will have some of the same buttons as 'box1' and perform the same actions - don't ask why i need to do this!
What i think is that making box2 a 'child' / derived class of box1 will be the best idea.
What i want to do is tell the program, when button 'my buttonbox2' is clicked in box2 it just goes to the 'mybuttonbox1' in box1 and carries out that process.
I understand all the class and derived class things in C++, and I understand all the OnBtnClicked stuff etc... i'm just having a hard time with my limited knowledge to connect standard C++ with MFC!
If anyone can help I would be very grateful. Thankyou.
|
|
|
|
|
You wan to relay events from your second message box to the first one? So for example if you click a button on your second dialog you want the first dialog class' instance to handle it?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Pretty much, yes.
Basically my 1st box has for example:
void Cbox1dlg::onbtnplay
{
// box 1 onbtnplay process information
}
I want my second box void Cbox2dlg::onbtnplay to just point back to box1 and do 'box1 onbtnplay process'
Thanks
|
|
|
|
|
If it is only a few buttons AND in your second dialog you know the handle of the first one (for example it is its parent) then you can try simply relaying all the command messages to the first dialog, if this suits your needs or not i can't tell of course.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks for that,
I think that would be right for my needs,
the problem is, i have not been able to work out the actual code to relay back to the 1st dialog, I could do this in standard C++, but with MFC macros I'm sure how to go about actually coding it...
Could you (or anyone else reading this) give me an example code to relay the buttonclick back to the 1st dialog button click?
Sorry, i'm quite new to MFC, and i'm not sure quite how to treat the macros in it as opposed to standard 'int's' or something.
Thankyou very much for your help. (and yes, its only a few buttons - probably 3or 4).
|
|
|
|
|
Does your second dialog know of the first dialog? Is it its parent for example? Then you could try overwriting the OnCommand[^] method of the second dialog's class (it doesn't even have to be a subclass of the original dialog's class). So something like this:
BOOL CMySecondDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
GetParent()->SendMessage(WM_COMMAND, wParam, lParam);
return TRUE;
} Of course this carries some risks...a more safer aproach is maybe adding message handlers to your buttons and then relaying the events from there. Since we are talking about a few buttons only, it should be easy:
BEGIN_MESSAGE_MAP(CMySecondDialog, CDialog)
ON_COMMAND(IDC_FIRSTBUTTON, OnFirstButton)
ON_COMMAND(IDC_SECONDBUTTON, OnSecondButton)
...
END_MESSAGE_MAP()
void CMySecondDialog::RelayCommand(UINT nID)
{
GetParent()->SendMessage(WM_COMMAND, nID, 0);
}
void CMySecondDialog::OnFirstButton()
{
RelayCommand(IDC_FIRSTBUTTON);
}
void CMySecondDialog::OnSecondButton()
{
RelayCommand(IDC_SECONDBUTTON);
}
I am not completely sure i understood your situation correctly though...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thats really great, thanks... I think you've understood what i want to do, that looks reasonable to me.
I didn't know about the RelayCommand, so thats really helped!
Thankyou very much.
Penfold.
|
|
|
|
|
1. Write a C program to read a list of books from a file and create a linked list to store them. The purpose of this program is to keep track of the books kept in a shelf. The shelf is a three-tier shelf and each tier can store up to 4500 pages maximum. The books are kept in alphabetical order (ascending).
do u all know about this question ?pls help
|
|
|
|
|
we don't do the homeworks or assignments. we are way past from that stage.
If you can start and are stuck somewhere, someone may help you.
On another note - Can I politely ask you to read the forum guidelines/rules?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
funjoke88 wrote: do u all know about this question ?
I do now.
|
|
|
|
|
Please read the posting guidelines here[^]. Pay special attention to points 2,3 and 10.
|
|
|
|
|
It's called "homework". It seems to me that if you were given that assignment, then the instructor probably gave you everything you need to implement a solution. That's what I know about it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi experts,
can i get some help on how to disable and enable cd/dvd drive in windows XP-64 bit. the application needs to isolate the user from using the cd/dvd drives. how can i go ahead writing a
i am developing the application in VC++ 9.
some code examples will be of great help and much of appreciation.
thankyou.
|
|
|
|
|
|
i am through all the things mentioned in that posts.
my issue is my application has to run for windows XP-64 bit.
and the registry stuff is not working. i have tried all the stuffs mentioned.
any other feasible ideas???
thankyou.
|
|
|
|
|
if u want to run ur stuff in 64, there few things that should be taken care.
if u want to make 64 bit application run on 64 bit environment, firstly compile it as 64 bit. And build it, and some API in 32 bit wont work. Definitely you can use registry APIs in 64 application, using which you can modify registry.
If want to port your 32 bit application to 64 bit then
1. Build using vs 2008(64 bit support enabled) is must.
|
|
|
|
|
yes.it's been done the same way in which u are saying.
do u have any ideas or any means to disable the cd/dvd rom in windows xp proffessional 64 bit??
i am following all the pre-requisites for 64 bit development.
hope to get a feasible solution this time..
thankyou.
|
|
|
|