|
Show the code in which you send the data.
|
|
|
|
|
Part of the code, link is at the bottom.
LRESULT CChildView::OnSerialMsg (WPARAM wParam, LPARAM /*lParam*/)
{
CSerial::EEvent eEvent = CSerial::EEvent(LOWORD(wParam));
CSerial::EError eError = CSerial::EError(HIWORD(wParam));
if (eError)
DisplayEvent(_T("An internal error occurred."));
.
.
. //many if statements
.
.
if (eEvent & CSerial::EEventRecv)
{
// Create a clean buffer
DWORD dwRead;
char szData[101];
const int nBuflen = sizeof(szData)-1;
// Obtain the data from the serial port
do
{
m_serial.Read(szData,nBuflen,&dwRead);
szData[dwRead] = '\0';
// Scan the string for unwanted characters
for (DWORD dwChar=0; dwChar
|
|
|
|
|
Hi group
Can anybody help me out
I want to change the background color of the header(column tab)in the ListControl
Actually i am doing a project in VC++
I am able to change the background color of the CListCtrl but i failed to change the color of the header tab,
so can anybody help me out
VC++
vcforums@gmail.com
|
|
|
|
|
Hi,
you need to owner-draw the complete headercontrol to do so, which means:
- subclass the header control that is a child of the listcontrol in its PreSubclassWIndow handler
- for every button in the headercontrol set the HDF-OWNERDRAW flag
- draw the button in the DrawItem handler
takes only some 100 lines of code...
dirk
|
|
|
|
|
Hi,
I have created a CWnd in a CPropertyPage. I want to display some drawing inside the CWnd. How can this be achieved?
I tried the following approaches but did not succeed:
1) Tried creating CWnd object in the CPropertyPage class and then override the OnInit function to draw . I used the GetDC() to get the CDC and then the GetSafeHandle() function to get the HDC. I used this handle to render my drawing. The CWnd was created but the drawing is not displayed.
2) According to a suggestion from a colleague, I tried creating separate class for the CWnd object. This was to let me override the OnPaint function of the CWnd object.
My code in OnPaint function is as follows:
PAINTSTRUCT ps;
CDC * dc = this->BeginPaint(&ps);
//draw function takes in the CDC * dc obtained in fuction above
draw();
this->EndPaint( &ps );
Then I created a object of this class in CPropertyPage class. I tried calling the create function in the constructor and OnCreate function of the property page. Here again I could at the most get my window displayed but no drawing.
Any suggestions on how to achieve this?
Also, does MFC basically support GDI in CWnd objects when created as child window of a dialog or property page?
P.S. to make sure that the code to draw is working correctly, I tried testin that by having the rendering in a document using the view class. It works correctly i.e. I can get the display in a document window but cannot get it in dialog window or to be precise CWnd instance.
Thanks in advance for your help.
Regards,
Abhijit Deshmukh
|
|
|
|
|
Hi everyone.
I have an application with a photo realistic interface and i want to use a non standard LCD type font. Is there some way i can include this inside the app like a resource, or do i really need to install it onto the users machine with the program? I cant seem to find any information on how to do this?
Any pointers would be appreciated
M
|
|
|
|
|
|
I have been writing and testing my code on win xp, and today when I tested it on win 98 it allways fails at binding the socket. WSAGetLast error is returning 0 so i don't know what is wrong. Anyone had similar problems?
[CODE]
WSADATA wsaData3;
sockaddr_in service;
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(1336);
char recvbufer[1000];
int bytes;
int err = WSAStartup( MAKEWORD(1,0), &wsaData3 );
if(err)
MessageBox(NULL, "couldnt start", "err", 0);
SOCKET m_socket3 = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( bind( m_socket3, (SOCKADDR*) &service, sizeof(service) ) == SOCKET_ERROR ) {
MessageBox(hwnd, "Error starting up. Is another server running on this port?\n", "Error", MB_ICONSTOP);
err = WSAGetLastError();
sprintf(recvbufer, "%i", err);
MessageBox(NULL, recvbufer, recvbufer, 0);
PostQuitMessage(0);
}
if ( listen( m_socket3, 1 ) == SOCKET_ERROR ){
MessageBox(hwnd, "Error listening on socket.\n", "Error", MB_ICONSTOP);
PostQuitMessage(0);
}
[/CODE]
|
|
|
|
|
Hi friends
Please help me!
I have opened a new project in Visual Studio,and have selected "Visual C++ Project ----> MFC" from "Project Type" OK?
I want to create a simple windows service,
Now
1) which item I shude select from "Templates" ?
2) Please tel me: "what shude I do then?"
Step By Step Please ( Such as a wizard )
Excuse me! I do not know English very well
|
|
|
|
|
Moj_Far wrote:
I want to create a simple windows service,
Seems like you want to create service in MFC? But i would like to let you know Visual Studio 6.0 don't provide any Wizard Support for Services in MFC.
Though there are some free third party service framework available in market that can help you create a service skeleton, here is some links :-
http://www.codeproject.com/system/cntservice.asp[^]
http://www.codeproject.com/tools/servicewizard.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
hello,
i m developed a simple client-server application.
now i want that in my server i don't accept connections from a list of IP addresses. how do i accomplish it. After accept() call i tried to check the IP of the connecting client and then used closesocket() to close the connection. But the problem is that the client gets connected as the connect() call from the client side works. i don't want that to happen. i want that the server should not accept connection from the list of IPs rather than accepting and then breaking. how do i achieve it?
thanx in advance
|
|
|
|
|
Not possible if you use socket api. What you have to do is to detect the first SYN packet from client IP's and filter on that.
1. Use a firewall (external to your prog).
2. Code raw sockets... i.e be prepared to write your own TCP protocol
|
|
|
|
|
can u provide me with some working example on raw socket? any links?
thanks in advance
|
|
|
|
|
Raw sockets: look at ping.c sample in MSDN..
Raw packet capture library: http://www.winpcap.org
The above two will help you detect a SYN pkt from clients.
But you'll be wasting your time trying to code a conventional client-server prog using the above two methods.. you'll have to write the the entire TCP protocol suite yourself at the server end. Why dont you simply use a packet filter firewall at the server?
|
|
|
|
|
I suppose that you have a good level on networking programming
then do this if not just forget about, sorry
Normaly with Socket API it is not possible, because while calling accept() the client get connect.
For that you need to use some firewall in your program for packet filter
here is am easy way to do that:
INTERFACE_HANDLE hInterface; // interface
PFFORWARD_ACTION defaultAction=PF_ACTION_DROP;
// create the interface
// I create the interface. Predefined acctions, forward all.
DWORD errorCode = PfCreateInterface(0,defaultAction,defaultAction,FALSE,TRUE,&hInterface);
if(errorCode != NO_ERROR)
{
return -1;
}
// Bind the Ip Address with the interface
PBYTE lIp = (PBYTE)&ip; //the ip address of your card
errorCode = PfBindInterfaceToIPAddress(hInterface, PF_IPV4, lIp);
if(errorCode != NO_ERROR)
{
PfDeleteInterface(hInterface);
hInterface = NULL;
return -1;
}
/////////////////////////////////////////////////////
now here do with the code
{
DWORD result;
PIP_ADAPTER_INFO pAdapterInfo = NULL, aux;
IP_ADDR_STRING *localIp;
unsigned long len = 0;
GetAdaptersInfo(pAdapterInfo, &len);
pAdapterInfo = (PIP_ADAPTER_INFO) malloc (len);
result = GetAdaptersInfo(pAdapterInfo, &len);
if(result != ERROR_SUCCESS)
{
AfxMessageBox("Error getting adapters info.");
return;
}
// Fill the real filter struct
PF_FILTER_DESCRIPTOR ipFlt;
ipFlt.dwFilterFlags = FD_FLAGS_NOSYN;
ipFlt.dwRule = 0;
ipFlt.pfatType = PF_IPV4;
ipFlt.dwProtocol = protocol; // value is : TCP =6;UDP=17 or ICMP=1
ipFlt.fLateBound = 0;
ipFlt.wSrcPort = srcPort; // source port
ipFlt.wSrcPortHighRange = srcPort; // source port range
ipFlt.wDstPort = dstPort; // destination port
ipFlt.wDstPortHighRange = dstPort; // destination port range
unsigned long lIpSrc = CharToIp(srcIp); //chartoIP convert (*.*.*.*) to long
unsigned long lIpDst = CharToIp(dstIp);
unsigned long lMaskSrc = CharToIp(srcMask);
unsigned long lMaskDst = CharToIp(dstMask);
ipFlt.SrcAddr = (PBYTE) &lIpSrc;
ipFlt.SrcMask = (PBYTE) &lMaskSrc;
ipFlt.DstAddr = (PBYTE) &lIpDst;
ipFlt.DstMask = (PBYTE) &lMaskDst;
DWORD errorCode;
// I add the filter
if(direction == IN_DIRECTION || direction == ANY_DIRECTION)
errorCode = PfAddFiltersToInterface(hInterface,1,&ipFlt,0,NULL,NULL);
if(direction == OUT_DIRECTION || direction == ANY_DIRECTION)
errorCode = PfAddFiltersToInterface(hInterface,0,NULL,1,&ipFlt,NULL);
}
Not that when stopping your server
call PfDeleteInterface(hInterface); to delete your interface
Pierre kande
For serving you
|
|
|
|
|
Hello every one~
I want to get E-Mail account infomation of OutLook( express , XP, 2003... )
for example,
Incomming E-Mail Address( POP3 ) : mail.codeproject.com
Outgoing E-Mail Address( SMTP ) : mail.codeproject.com
User Name : bluebird
E-Mail Address : bluebird@codeproject.com
User ID : bluebird
User PassWd : ********
How to get this Infomation?
I have been saw about MAPI.
but I can't get Information that I want
Help me please.
and sorry for my little English
|
|
|
|
|
Blue-Bird wrote:
I have been saw about MAPI.
but I can't get Information that I want
What about Extended MAPI? Since you are interacting with Outlook, there's also CDO.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I asked about this several times in the C# forum and got no reply. Is there a way to use C# to impliment the solution you're suggesting ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Is there a way to use C# to impliment the solution you're suggesting ?
Yeah I know one interface which enumerate Email,LDAP and news group Account for Outlook Express and that is IImnAccount and IImnAccountManager interface
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Christian Graus wrote:
Is there a way to use C# to impliment the solution you're suggesting ?
I do not know. I've never used C# before.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
um...
Do you give me more informations and sample source and URL?
thanks in advance
|
|
|
|
|
Try these links:
http://www.wischik.com/lu/programmer/mapi_utils.html
http://www.dimastr.com/outspy/default.htm
http://support.microsoft.com/kb/
http://www.softlookup.com/tutorial/vc++/vcu35fi.asp
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thanks a lot!
Have a good job~
|
|
|
|
|
Wassup pal.. writing a trojan??
Want the code in C ??
|
|
|
|
|
no...
I make a Spam Mail Filter.
I want to get it for user's convenience
|
|
|
|