I am utilizing edit boxes to design a report from a simple database. I have three edit boxes that I am using. They are called NameFirst, NameMiddle and NameLast. I want all of the edit boxes to automatically set their own width. For example if I have an edit box that contains "Gloria" I would like that edit box to be only wide enough to display the text "Gloria" and not a pixel wider. Also the editbox called NameMiddle is located directly to the right of NameFirst. I would like the NameMiddle editbox to automatically calculate the size of NameFirst and place itself 2 pixels to the right of NameFirst. How can these things be accomplished? Thank you, Eric Sepich
esepich
Posts
-
Designing a report. -
Strange things with parameters.There is surely something I do not understand here. I would very much appreciate if someone could explain to me how I screwed this up. Thank you. --------------------Configuration: TCPIPwatch - Win32 Debug-------------------- Compiling... TCPIPwatchDlg.cpp C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\TCPIPwatch\TCPIPwatchDlg.cpp(235) : error C2664: 'bind' : cannot convert parameter 2 from 'struct CTCPIPwatchDlg::TCPIPWConnectSock::SOCKADDR_IN *' to 'const struct sockaddr *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe. TCPIPwatch.exe - 1 error(s), 0 warning(s) void CTCPIPwatchDlg::TCPIPWConnectSock(SOCKADDR_IN *dest, SOCKET &theTrgSock) { dest->sin_family = AF_INET; dest->sin_port = 80; if(dest->sin_port == INVALID_SOCKET) AfxMessageBox("Port is invalid.",MB_OK); theTrgSock = socket(AF_INET, SOCK_RAW, IPPROTO_IP); const char RCVTIMEO[50] = "5000"; setsockopt(theTrgSock, SOL_SOCKET, SO_RCVTIMEO, (RCVTIMEO), 4); bind(theTrgSock, (struct SOCKADDR_IN*) dest, sizeof(dest)); }
-
Socket returning as readable when it is not.I have used the select(); function in an attempt to program a [Timed out] message into my program. In this case the host I am working with is www.ebay.com. You will notice that if you open a command prompt in windows and ping www.ebay.com that you will get four [timed out] output messages sent to the screen. I would like to do the same thing with my program and have chosen to use the select(); function to accomplish this task. The problem is that select(); returns the socket connected to www.ebay.com as readable. How could this be? If I can't use select(); to discover that I have not gotten a reply, how then will I know that no echo reply has been sent back to me? Thank you, Eric Sepich
-
Question about "!".With regards to: ---> bReadible = !(nStatus == 0); What does this mean? I have never seen code written like this before. BOOL CRawPingDlg::IsSocketReadible(SOCKET socket, DWORD dwTimeout, BOOL& bReadible) { timeval timeout; timeout.tv_sec = dwTimeout / 1000; timeout.tv_usec = (dwTimeout % 1000) * 1000; fd_set fds; FD_ZERO(&fds); FD_SET(socket, &fds); int nStatus = select(0, &fds, NULL, NULL, &timeout); if (nStatus == SOCKET_ERROR) return FALSE; else { bReadible = !(nStatus == 0); return TRUE; } } Thank you
-
Output box.I am using a common edit control for the purpose of displaying output in text format in my application. Every time I need to write something to the screen I find that I need to put the contents of the edit box into a string put the new output into anothor string, concatenate these two strings togethor and then output this new longer string to the screen. For simplicities sake isn't there a way to just call a function similar to idcoutput->SetWindowText(); that will add text and not overwrite the box with the new text? Thank you, Eric Sepich
-
select() in conjunction with recvfrom()I am a little confused about how exactly these two functions can work with each other. I would like to make a call to select and then make a call to recvfrom() so as to allow for a timeout period. So if my socket does not recvfrom() anything within lets say four seconds then I need to send a "timed out" error to the output box. I have read the msdn reference on select() but I don't really understand. Thank you, Eric Sepich
-
I need to make this more compact.I like to write lines of code that are very short and very simple to understand. Is there a way that I can communicate this in a shorter more compact form? CEdit *idcinput = (CEdit *) GetDlgItem(IDC_INPUT); char cinput[255]; idcinput->GetWindowText(cinput, 255); CString sinput = cinput; Thank you, Eric Sepich
-
Killing program executionWhat is the simplest way to kill an MFC dialog based application?
-
One way works other doesn'tThe part under the (if aorh == 0) works great :). The part in the else{} brackets dosn't and causes a fatal error in my program when I run it as well as a WSAEPROTONOSUPPORT error :(. I don't understand. I must be doing something screwy. void CSSPingDlg::Ping(LPCSTR pstrHost, int aorh) { SOCKET rawSocket; LPHOSTENT lpHost; rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if (rawSocket == SOCKET_ERROR) { AfxMessageBox("Raw socket initialization failed.",MB_OK); return; } if (aorh == 0) { lpHost = gethostbyname(pstrHost); saDest.sin_addr.s_addr = *((u_long FAR *) (lpHost->h_addr)); saDest.sin_family = AF_INET; saDest.sin_port = 0; } else { lpHost = gethostbyaddr(pstrHost,4,AF_INET); saDest.sin_addr.s_addr = *((u_long FAR *) (lpHost->h_addr)); saDest.sin_family = AF_INET; saDest.sin_port = 0; }
-
Error C2679SOCKADDR_IN tempaddr; tempaddr.sin_addr = INADDR_ANY; I have seen code like this in many examples. I am not quite sure why the compiler would tell me that: error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'unsigned long' (or there is no acceptable conversion) I would have never gotten as far as I did with this program without all of your help. Thank you
-
sendto(); question.Feel free to correct me at any time as I am still trying my best to learn this API. I know that there is a SOCKADDR structure that is able to hold data and family type. I also know that there is a SOCKADDR_IN structure that is able to hold an address, a port number, data and a family type. I have a sendechorequest function set up like this int CSSPingDlg::SendEchoRequest(SOCKET s, SOCKADDR_IN lpstToAddr); Now comes the interesting part. Inside this SendEchoRequest function I make a call to the sendto() function. What I take issue with is the fifth parameter of sendto(); which requires a SOCKADDR * that is supposed to contain the address of the host to which to send the data. The problem is that my ping program requires that I use a SOCKADDR_IN structure which is able to hold important information like the IP address of the host. Is there a version of sendto(); that will allow me to pass a SOCKADDR_IN instead of a plain SOCKADDR? Could it be that I am just not using sendto(); correctly. All I know is that I want to send data to the host specified in the SOCKADDR_IN structure that I have passed to my sendechorequest function. How do I do that?
-
Syntactical blunder.I know that it's there, I just can't figure out why this error is occuring. Compiling resources... Compiling... StdAfx.cpp Compiling... SSPing.cpp SSPingDlg.cpp C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\SSPing\SSPingDlg.cpp(204) : error C2664: 'sendto' : cannot convert parameter 2 from 'struct tagECHOREQUEST' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Generating Code... Error executing cl.exe. SSPing.exe - 1 error(s), 0 warning(s) int CSSPingDlg::SendEchoRequest(SOCKET s, SOCKADDR_IN lpstToAddr) { static ECHOREQUEST echoReq; static nId = 1; static nSeq = 1; int nRet; echoReq.icmpHdr.icmp_type = ICMP_ECHOREQ; echoReq.icmpHdr.icmp_code = 0; echoReq.icmpHdr.icmp_cksum = 0; echoReq.icmpHdr.icmp_id = nId++; echoReq.icmpHdr.icmp_seq = nSeq++; for (nRet = 0; nRet < REQ_DATASIZE; nRet++) echoReq.cData[nRet] = ' '+nRet; echoReq.dwTime = GetTickCount(); echoReq.icmpHdr.icmp_cksum = checksum((u_short *)&echoReq, sizeof(ECHOREQUEST)); -----> nRet = sendto(s, echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN)); return 0; }
-
Character macro.Is there a macro that I can use to determine if any part of a string is an 'A-Z' character. Thank you
-
Checking if an edit control is empty.I am sorry for having to ask such a stupid question but how do I check if an edit control is empty? I have tried comparing the contents of the window to NULL but that does not work. I have also checked to see if the CEdit class has an IsEmpty() type function and I can't fine one. Does anyone know how to do this? Thank you all for your patience.
-
Stuffing four byte octets into a dword.I have four octets of an ip stored as follows. byte octet1,octet2,octet3,octet4 IPAddressCtrl.GetAddress(octet1,octet2,octet3,octet4); What I need to do is get those four bytes into a DWORD in the propor byte order so I can store that DWORD in an SOCKADDR_IN structure like this SOCKADDR_IN saDest; saDest.sin_addr.s_addr = /*Somehow stuff octet1,2,3,4 in*/ Does anyone know how this can be done? Thank you
-
CEdit and multiline.With regards to the CEdit control, what is the multiline proporty and how do I enable it utilizing VC++6? Thank you
-
New line character.I'm not quite sure on how to do that.
-
New line character.Now I get a double tick. ????
-
New line character.final = line1 + "\n" + line2 + "\n" + line3; The "\n"'s show up as little ticks in the edit box. What gives?
-
Platform SDKI have been trying for quite some time now to download the Platform SDK from the msdn website. The mickeysoft program that is supposed to handle the installation keeps crapping out with a "Server Error" message. I can't download the CAB files either because they are coming in corrupted. Is there another way to obtain the SDK? Thank you, Eric Sepich