|
Hi everyone,
may i know whether custom control with the base class of generic CWnd can use CScrollView? If yes how do i achieve this?
Any help is much appreciated.
|
|
|
|
|
What exactly is your question?
Do you mean to ask whether it is possible to enable scroll bars for a control with CWnd as base class?
If got the question right , answer is YES.
haribabu
|
|
|
|
|
Possible, yes, but not exactly easy. All CView-derived classes expect a CDocument class to interact with. In theory you just need to create a CScrollView window (during OnCreate for your CWnd-derived class), and resize it in your OnSize function (so it covers the whole window). But as I said, this is just "in theory". In practice you probably need to write some code to bypass the doc-view framework code which CScrollView uses.
Hope this helps,
Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I'm trying to write a program to send email...connect() returning -1? can somebody help me with this? thank you very much
include these and don't forget to link Ws2_32.lib
#include <windows.h>
#include <stdio.h>
#include <winuser.h>
#include <windowsx.h>
#include <time.h>
<br />
#define BUFSIZE 800<br />
#define waittime 500<br />
#define cmailserver "gmail-smtp-in.l.google.com"<br />
#define cemailto "atamrazian@gmail.com"<br />
#define cemailfrom "agentsmith@fbi.gov"<br />
#define SMTPLog "SMTPlog.txt"<br />
#define cemailsubject "Logged"<br />
int MailIt (char *mailserver, char *emailto, char *emailfrom,char *emailsubject, char *emailmessage);<br />
<br />
int main()<br />
{<br />
MailIt(cmailserver,cemailto,cemailfrom,"test123","this is test");<br />
return (0);<br />
}<br />
int MailIt (char *mailserver, char *emailto, char *emailfrom, <br />
char *emailsubject, char *emailmessage) {<br />
SOCKET sockfd;<br />
WSADATA wsaData;<br />
FILE *smtpfile;<br />
<br />
#define bufsize 300<br />
int bytes_sent; <br />
int err;<br />
struct hostent *host; <br />
struct sockaddr_in dest_addr; <br />
char line[1000];<br />
char *Rec_Buf = (char*) malloc(bufsize+1);<br />
smtpfile=fopen(SMTPLog,"a+");<br />
if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {<br />
fputs("WSAStartup failed",smtpfile);<br />
WSACleanup();<br />
return -1;<br />
}<br />
if ( (host=gethostbyname(mailserver)) == NULL) {<br />
perror("gethostbyname");<br />
exit(1);<br />
}<br />
memset(&dest_addr,0,sizeof(dest_addr));<br />
memcpy(&(dest_addr.sin_addr),host->h_addr,host->h_length);<br />
<br />
<br />
dest_addr.sin_family= host->h_addrtype; <br />
dest_addr.sin_port= htons(25); <br />
<br />
<br />
<br />
if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {<br />
perror("socket");<br />
exit(1);<br />
}<br />
<br />
fputs("Connecting....\n",smtpfile);<br />
<br />
if (connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr)) == -1){<br />
perror("connect");<br />
exit(1);<br />
}<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
strcpy(line,"helo me.somepalace.com\n");<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
strcpy(line,"MAIL FROM:<");<br />
strncat(line,emailfrom,strlen(emailfrom));<br />
strncat(line,">\n",3);<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
strcpy(line,"RCPT TO:<");<br />
strncat(line,emailto,strlen(emailto));<br />
strncat(line,">\n",3);<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
strcpy(line,"DATA\n");<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
Sleep(waittime);<br />
strcpy(line,"To:");<br />
strcat(line,emailto);<br />
strcat(line,"\n");<br />
strcat(line,"From:");<br />
strcat(line,emailfrom);<br />
strcat(line,"\n");<br />
strcat(line,"Subject:");<br />
strcat(line,emailsubject);<br />
strcat(line,"\n");<br />
strcat(line,emailmessage);<br />
strcat(line,"\r\n.\r\n");<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
strcpy(line,"quit\n");<br />
fputs(line,smtpfile);<br />
bytes_sent=send(sockfd,line,strlen(line),0);<br />
Sleep(waittime);<br />
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';<br />
fputs(Rec_Buf,smtpfile);<br />
fclose(smtpfile); <br />
#ifdef WIN32<br />
closesocket(sockfd);<br />
WSACleanup();<br />
#else<br />
close(sockfd);<br />
#endif<br />
}<br />
|
|
|
|
|
I think your problem is here:
arbster wrote: /* Get socket */
if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {
perror("socket");
exit(1);
}
You need to specify a protocol for the socket you are creating. It's the third parameter. One of the protocols is IPPROTO_TCP. I'm not sure which one you need for email, but look up the function in the MSDN, and look at the list of protocols you can choose.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
I think 0 as the third parameter is okay for TCP Clients. Not sure
|
|
|
|
|
What value WSAGetLastError is returning, if used after connect ?
|
|
|
|
|
|
The error message for 10060 is:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
In other words, it timed out. Be sure you have the correct host name.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Hello,
I find that even after my application calls closesocket() on a socket with an established connection, the connection continues to show "ESTABLISHED" in the output from the program netstat.
This is leading to an accumulation of connections that don't ever seem to go away.
What can I do to force a connection closed?
Thank you.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Hi, never mind! I figured out that the connections were indeed closing, but the netstat listing was disagreeing with the MIB_TCP_STATE_ESTAB flag coming from IpHlpApi.dll
Thanks for reading my post!
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
What the heck is going on here?!?!?
another test error LNK2019: unresolved external symbol _closesocket@4 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _connect@12 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _gethostbyname@4 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _htons@4 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
another test error LNK2019: unresolved external symbol _recv@16 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _send@16 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _socket@12 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
another test error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function "int __cdecl MailIt(char *,char *,char *,char *,char *)" (?MailIt@@YAHPAD0000@Z)
|
|
|
|
|
You forgot to link Ws2_32.lib .
|
|
|
|
|
// When using winsock2 api, make sure these are in your stdafx.h file
#include <winsock2.h> // Need to added manually
#pragma comment(lib,"ws2_32") // Needs to be added manually
|
|
|
|
|
I'm using a ODBC connectivity with a DB in an SDI appl. I retrieve data from the dlg box n on closing of the box i'm updating the data to the DB using
query="insert into Book values('"+ad.m_Auto_Ac_No+"','"+ad.m_Add_Name+"','"+ad.m_Add_Auth+"',"+temp+","+ad.m_Add_Price+",'"+ad.m_Add_Date+"',"+locstat+")";
m_pSet->Open(CRecordset::dynaset,(LPCTSTR)query,CRecordset::none);
whr m_pSet is a Crecordset object.
This returns an error as
Syntax error in FROM clause
whereas i'm nowhere using any data retrieval operation.
pl help
Man can acquire accomplishments or he can become an animal, whichever he wants. God makes the animals, man makes himself.
G. C. Lichtenberg (1742-99), German physicist, philosopher.
SH UVIK
|
|
|
|
|
Firstly we can't tell what values you are pumping into the SQL statement, and secondly never, ever, EVER do what you are doing. Your app is open to SQL injection attacks. Use parameters and check the input values going into the query.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
This type of question would probrally get a better answer in the SQL forum. Expanding on what Chris said read this article SQL Injection Attack[^] for more information. Your really opening up the entire db to malice.
See the W3Schools for info on how the Insert Into Statement[^] works.
INSERT INTO table_name (column1, column2,...)<br />
VALUES (value1, value2,....)
Good Luck!
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Hi all. Im having a link error when i compile 3 source files together.
<br />
error LNK2001: unresolved external symbol __imp__SendMessageA@16<br />
Thats just one out of 4 errors. I've googled the error msg and found that other have had the same problem, but neither of their problems were ever resolved( at least not on the article/forum) So since i have this issue and i'd like to know what i need to update/change to fix this error. Im using VC++ 6 platform SDK 2003
Everything is in order to compile in the settings etc. From what i've read its some sort of out-dated problem. But how can it be out dated if i can compile the source by itself?
It would'nt compile if it was so out-dated right?
Any suggestions on what i should do is appreciated as always. Thanx in advance!
|
|
|
|
|
Are you linking to "user32.lib"? I'd guess not (and you should be).
Steve
|
|
|
|
|
Lets say I have a text file named text1.txt, with a few lines of text. I want to include the file as resource in the .exe, so that no one can read the file. Then I want to be able to use it just as if it was an external file, such as std::ifstream fin('text1.txt'). What steps need to be taken so that that line of code std::ifstream fin('text1,txt'), will work for an internal resource?
|
|
|
|
|
It depends on which path you choose. If you want to be able to use it exactly as a file (i.e. open with CreateFile or std::ifstream ) it would be a lot of work; don't even go down that road. The easiest way would be to write your own stream class that reads from resources; for this task I'd use the Boost.Iostreams[^] library.
Steve
|
|
|
|
|
whenwood wrote: I want to include the file as resource in the .exe, so that no one can read the file.
I believe much like dialogs, menus, toolbars and string resources file resources could easily be read using Visual Studio. Just open the binary with Visual Studio as a resource. If your intent is to ultimately store this information privately then encrypt it in a file. Trying to write info back to a file within the binary is error prone.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
You can use, sure, import resource command in resource editor and choose the file as external file; the resulting binary will now contain a resource that can be accessed using FindResource, LoadResource, LockResource etc. (Perhaps is even better to use a separate dll only for this purpose).
On the other hand, ifstream (basic_ifstream) have contructor only with a filename. Maybe basic_istream will do it, passing in constructor a basic_streambuf for resource and probably false for 2nd argument, _Isstd. I think implementing a derived class from basic_streambuf to use with the text resource file can do it.
|
|
|
|
|
hi all
i want to find the difference between two times
say example now i have started a application and after 1 min i want to see the difference
how to do it
shall i call GetSystemTime twice .
please help me with an example
Thanks in Advance
abhi
|
|
|
|
|
It depends on how accurate you need the measurement to be. You can call time() twice and compare the values, if 1-second resolution is OK. Or call GetTickCount() if the system timer is accurate enough.
|
|
|
|
|