|
I have already explained what I am getting.
There is still an assertion when I am setting the EditControl->EnableWindow(FALSE) values.
Please anybody has any idea how to do this, fist read the entire problem then answer please.
Thanks
The Phantom is Tracking Bullets.
|
|
|
|
|
Finally I have got the solution.
The answer to this problem is, to add an OnInitDialog(...) for the PropertyPage dervied class. And call the GetDlgItem(...)->EnableWindow(FALSE) in the OnInitDialog(...).
Thanks God for saving the day
The Phantom is Tracking the Bullets.
|
|
|
|
|
busisoft wrote:
Thanks God for saving the day
Not God, Microsoft. Easy mistake to make though
|
|
|
|
|
busisoft wrote:
I have already explained what I am getting.
There is still an assertion when I am setting the EditControl->EnableWindow(FALSE) values.
It seems like you are missing the point of ASSERTions. When your code ASSERTs it is usually because you are not using the MFC classes in the way in which they are intended.
I'm betting that the assertion that caused your code to crash was:
ASSERT(m_hWnd != NULL);
This line of code causes an Assertion when whichever window has not been created, so just by looking at this line of code in the debugger (when you get an Assertion, run your program in the debugger, then click on "Retry" - the debugger will jump to the Assertion in the MFC source (unless, of course you have your opwn ASSERTions in place - quite a good idea)) you will be able to see what is wrong.
Once you've debugged a few of these you will know what each one means and be able to fix the problem in a matter of minutes.
-Alex
|
|
|
|
|
I am in trouble. I am trying hard to send my tcp packet on the network but the packet is not going. I am using this strategy to do it.
1. create tcp packet using tcp structure.
2. Send the Packet using "Send to" method.
Posting the complete Code for Console application
#include "ip.h"
#define PORT 25
int main (void)
{
WSADATA wsd;
char datagram[4096];
int bOpt = 64;
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
{
printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}
// Create a raw socket
SOCKET s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (s == INVALID_SOCKET)
{
printf("WSASocket() failed: %d\n", WSAGetLastError());
return -1;
}
struct ipheader *iph = (struct ipheader *) datagram;
struct tcpheader *tcph = (struct tcpheader *) datagram + sizeof (struct ipheader);
struct sockaddr_in sin;
PS_HDR pseudo_header;
sin.sin_family = AF_INET;
sin.sin_port = htons (PORT);
sin.sin_addr.s_addr = inet_addr ("192.168.2.64");
memset (datagram, 0, 4096); /* zero out the buffer */
iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = 0;
iph->ip_len = sizeof (struct ipheader) + sizeof (struct tcpheader);
iph->ip_id = 1;
iph->ip_off = 0;
iph->ip_ttl = 255;
iph->ip_p = 6;
iph->ip_sum = 0;
iph->ip_src = inet_addr ("192.168.2.61");
iph->ip_dst = sin.sin_addr.s_addr;
tcph->th_sport = htons (1234);
tcph->th_dport = htons (PORT);
tcph->th_seq = rand();
tcph->th_ack = 0;
tcph->th_x2 = 0;
tcph->th_off = 0;
tcph->th_flags = 2; // SYN
tcph->th_win = htons(65535);
tcph->th_sum = 0;
tcph->th_urp = 0;
// Build the Psuedo Header
pseudo_header.source_address = inet_addr ("192.168.2.61");
pseudo_header.dest_address = sin.sin_addr.s_addr;
pseudo_header.placeholder = 0;
pseudo_header.protocol = IPPROTO_TCP;
pseudo_header.tcp_length = htons(sizeof(tcpheader));
// Calculate Checksum
tcph->th_sum = checksum((unsigned short *)&pseudo_header, sizeof(pseudo_header));
iph->ip_sum = checksum((unsigned short *)&iph, sizeof(ipheader));
// ENABLE IPHDRINCL
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(int)) == SOCKET_ERROR)
{
printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
return -1;
}
// Send The Packet
if (sendto(s, datagram, sizeof(datagram), 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
printf("message sent");
return 0;
}
/*********************** ip.h header file *************************/
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <stdio.h>
struct tcpheader {
unsigned short int th_sport;
unsigned short int th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_x2:4, th_off:4;
unsigned char th_flags;
unsigned short int th_win;
unsigned short int th_sum;
unsigned short int th_urp;
}; /* total tcp header length: 20 bytes (=160 bits) */
struct ipheader {
unsigned char ip_hl:4, ip_v:4; /* this means that each member is 4 bits */
unsigned char ip_tos;
unsigned short int ip_len;
unsigned short int ip_id;
unsigned short int ip_off;
unsigned char ip_ttl;
unsigned char ip_p;
unsigned short int ip_sum;
unsigned int ip_src;
unsigned int ip_dst;
}; /* total ip header length: 20 bytes (=160 bits) */
// Psuedo Header
typedef struct ps_hdr
{
unsigned int source_address; // Source Address => 4 Bytes
unsigned int dest_address; // Destination Address => 4 Bytes
unsigned char placeholder; // Place Holder => 1 Bytes
unsigned char protocol; // Protocol => 1 Bytes
unsigned short tcp_length; // TCP Length => + 2 Bytes
// = 12 Bytes
struct tcpheader tcp;
}PS_HDR;
// IP/TCP/UDP Checksum Function
USHORT checksum(USHORT *buffer, int size)
{
unsigned long cksum=0;
while (size > 1)
{
cksum += *buffer++;
size -= sizeof(USHORT);
}
if (size)
{
cksum += *(UCHAR*)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (USHORT)(~cksum);
}
/*********************** ip.h header file *************************/
//The code is executing perfectly but the packet does not reach its destination.
//plz help me
Reply me soon
|
|
|
|
|
Hi ,
I want to do an Encyption Program. I got a sample code from MSDN site. When I am compling that Program some varibles & Functions showing error as Undeclared identifier. HCRYPTPROV, HCRYPTKEY, CryptAcquireContext() etc....
I have already included the "Wincypt.h"
Can anyone help me to sove this error?
Thanks in Advance
SAN
|
|
|
|
|
Hi ,
I want to do an Encyption Progrma. I got a sample code from MSDN site. When I am compling that Program some varibles & Functions showing error as Undeclared identifier. HCRYPTPROV, HCRYPTKEY, CryptAcquireContext() etc....
I have included the "Wincypt.h"
Can anyone help me to sove this error?
Thanks in Advance
SAN
|
|
|
|
|
Try this:
#define _WIN32_WINNT 0x0500
--
karl
|
|
|
|
|
Hey everyone!
I put myself a string class in C++ together, and now I want an easy way to initialize it with some string. One thing is the constructor that takes a LPCTSTR-type as an argument, in the fashion of cString (LPCTSTR somestring). Now I'd like to be able to do something like:
cString *bunchachars = new cString ();
bunchachars = "Now here comes the filling";
I did a little of research on the internet, and two terms I came across (that I could imagine being applied here) were the = operand and the cast-constructor. Can anyone give a little detail on this, or just tip me into the right direction?
cheers
tilli
|
|
|
|
|
tilli again wrote:
Can anyone give a little detail on this, or just tip me into the right direction?
You should REALLY read the code of the std::string class (and its definition http://www.sgi.com/tech/stl/)as well as the CString -code from MFC.
There is no point in reinventing the wheel - at least interface-wise.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Well, I'm writing my own Win32 API wrapper, just for not having to use MFC (personal choice and just a fun thing). I don't wanna end up having to use any of these huge libraries. Still, it might make sense to see how it was done in the std::string class, thanks for the hint!
|
|
|
|
|
From the looks of it, you're coming from some garbage-collected language such as Java or C#. In C++ you can allocate objects on the stack just like ints and longs. So you can do this:
cString str;
str = "whatever";
or
cString str = "whatever";
cString str("whatever");
If you have a pointer, like in your example, you must "dereference" it:
cString *bunchachars = new cString;
*bunchachars = "Now here comes the filling";
Regards,
Alvaro
There are no stupid questions, but there are a lot of inquisitive idiots. -- despair.com
|
|
|
|
|
I've successfully use GetCursorPos() and WindowFromPoint() to get the window handle. Then I use SendMessage() to send "WM_COPY" to that application, so that I can copy the selected text to the clipboard for my application. This method success in notepad. But when I try this method in openoffice, it failed.
Openoffice seems doesn't accept the message "WM_COPY". Does anyone know how can I get the selected text from openoffice? Thanks a lot.
|
|
|
|
|
What about other application like MS IE and outlook express?
|
|
|
|
|
MS IE and Netscape failed using this method.
But MS Word is okay.
|
|
|
|
|
Please let me know if you have any tool like grpof (in linux) on windows, which gives the detailed timing analysis.
Also need some tool which gives the detailed timing analysis in VC++ code.
|
|
|
|
|
|
Visual Studio has its own profiler - you can enable it by changing the project settings
|
|
|
|
|
But it isn't available in all VC++ 6.0 flavours; I have MSDN Enterprise, but I don't think it's available in the "Learning" or Personal edition, whatever it's called.
Steve
Steve S
[This signature space available for rent]
|
|
|
|
|
I am using ShellExecute() function to open MSPaint from my MFC application. This opnes paint successfully,but gives
debug assetion failure error to my application.
this happnes with ShellExecute(),Winexec() & CreateProcerss()
What is going wrong?
My PC configuration is
OS->win98
RAM 128MB
VC6.0
PIII processor 533
.
|
|
|
|
|
Youre string operation seems to be buggy. Try: GetBuffer and GetLength operations.
The first thing should be start the app without params, than build the more complex thing.
What replies GetLastError() and haven´t you set all the flags of the command right?
Try this @ home. (B&B)
|
|
|
|
|
Run the debug build in the debugger, press Retry at the Assert and then you will see what the complaint is about and should be able to fix it.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Pleae tell me which one of the following programs is most efficient,thanks.
1.
#include <iostream.h>
class A
{
public:
int x ;
A(int i) { x=i ; }
} ;
void main()
{
int i;
cout <<"Enter i " ;
cin>>i ;
A a(i);
cout << "a.x=" << a.x << endl ;
}
2.
#include <iostream.h>
class A
{
public:
int x ;
A(int i) : x(i) {}
} ;
void main()
{
int i;
cout <<"Enter i " ;
cin>>i ;
A a(i);
cout << "a.x=" << a.x << endl ;
}
3.
#include <iostream.h>
class A
{
public:
int x ;
} ;
void main()
{
int i;
cout <<"Enter i " ;
cin>>i ;
A a ;
a.x=i ;
cout << "a.x=" << a.x << endl ;
}
|
|
|
|
|
None of them are standard C++, because they either won't compile, or you included iostream.h, which is not part of standard C++. Inclide iostream instead, and put using std::cout;, etc. for the bits you want to use.
Also, void main is not valid C++, main must return int.
I doubt any of them is more efficient in any real terms.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
dear all,
how can i get the Last Modification Date Of any File (Not the Creation date) using API.
thanx
|
|
|
|