|
The C++ symbol "::" is the scope-resolution operator. It tells the compiler to look for the item on the right of the operator inside the scope on the left.
There are two kinds of scopes in C++: classes and namespaces. Your first example uses scope resolution to call the base class's implementation of MyMethod(). When using scope-resolution in this way, it forces the compiler to statically choose the version of the function to call, rather than dynamically (which normally results in a recursive call with this idiom).
Namespaces allow related classes, functions and data to be given a related name. Instead of naming your classes:
mysqlcppapi_Connection
etc, you can name them
mysqlcppapi::Connection
So far, not much benefit. But you can use a shorter name with the using declaration:
using mysqlcppapi::Connection;<br />
<br />
Connection con;
If you decide to write using directives:
using namespace mysqlcppapi;<br />
using namespace myOtherNamespace;
and a Connection class is declared in both, you will have to revert to indicating which one you mean with the :: operator.
Namespaces have another advantage over using static class members; the declaration of a namespace can be re-opened, that is, you can add members to a namespace in multiple files.
--
Mike Dimmick
|
|
|
|
|
I use this code to send email with SMTP server but althuogh WSAGetLastError() return 0 always,there is no mail in the mailbox after these codes:
WSAStartup(0x0101,&wsa);
sendsocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
HOSTENT *hp1 = gethostbyname("mail.parsonline.net");
sendsin.sin_addr.s_addr=*((unsigned long*)hp1->h_addr);
sendsin.sin_family=AF_INET;
sendsin.sin_port=htons(25);
connect(sendsocket,(struct sockaddr*)&sendsin, sizeof(sendsin) );
char *buff = "HELLO server \r\n";
send(sendsocket,buff,strlen(buff),0);
char *buff1 = "MAIL FROM: <mazdakmansouri@mymail.net>\r\n";
send(sendsocket,buff1,strlen(buff1),0);
char *buff2 = "RCPT TO: <mazdakmansouri@mymail.net>\r\n";
send(sendsocket,buff2,strlen(buff2),0);
char *buff3 = "DATA \r\n";
send(sendsocket,buff3,strlen(buff3),0);
char *buff4 = "SUBJECT:LLLL\r\nBBBBBB.\r\n";
send(sendsocket,buff4,strlen(buff4),0);
send(sendsocket,"QUIT \r\n",strlen("QUIT \r\n"),0);
Any idea?
Mazy
No sig. available now.
|
|
|
|
|
It's not valid SMTP. You must always wait for a proper response (or error code) from server before sending commands or data to the server. The initial command must be "HELO", not "HELLO". The addresses are missing from "MAIL FROM" and "RCPT TO". The DATA isn't correctly terminated with a \r\n.\r\n .
|
|
|
|
|
Thanks.
Mazy
No sig. available now.
|
|
|
|
|
As markkuk says, it's not valid SMTP, and no server would ever save it.
You should take a closer look at http://faqs.org/rfcs/rfc2821.html[^]
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
thanks.
Mazy
No sig. available now.
|
|
|
|
|
I have a problem on using CopyFileEx().
I want to let Progress-Bar progress by using CopyFileEx() to show progress of copying files.
But Progress-Bar is not created.
On Debugging, CopyProgressRoutine() is not called.
There are no problem on compiling and copying files.
Please advise...
*******************************************************************************************
*******************************************************************************************
// Declaration of CopyProgressRoutine() in header file
static DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData );
*******************************************************************************************
*******************************************************************************************
// The part of using CopyFileEx() in source file
for (i = 0; i < tmpwd; i++)
{
sTmp3.Format("DepFile%d", i+1);
sTmp = sAppPath + "\\" + pApp->GetProfileString(sSection, sTmp3);
sTmp2 = sPrnDrvDir + sTmp.Mid(sTmp.ReverseFind('\\'));
CopyFileEx(sTmp, sTmp2, CopyProgressRoutine, NULL, &b_cancel, COPY_FILE_RESTARTABLE);
}
*******************************************************************************************
*******************************************************************************************
// Definition of CopyProgressRoutine()
DWORD CALLBACK CSetupDlg::CopyProgressRoutine( LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData )
{
AfxMessageBox("Is it called?");// MessageBox for knowing of CopyProgressRoutine() being called
// But MessageBox is not output.
// So CopyProgressRoutine() was not called.
CSetupDlg *pDlg = (CSetupDlg*)lpData;
pDlg->m_InstProgress.SetPos( (StreamBytesTransferred.QuadPart / pDlg->TotalSize) * 100 );
// pDlg->TotalSize : Total sizes of all files that will be copied;
return PROGRESS_CONTINUE;
}
|
|
|
|
|
Have you tried it with "large" files. I don't think it bothers with the progress stuff for small quick to copy files.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
hello
when i compile i meet a strange mistake and i havn't idea when it cam come:
Compiling...<br />
creatfoufou.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
foufou.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
OpenGlView.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
Generating Code...<br />
Error executing cl.exe.<br />
Creating browse info file...<br />
BSCMAKE: error BK1506 : cannot open file '.\Debug\creatfoufou.sbr': No such file or directory<br />
Error executing bscmake.exe.<br />
<br />
OpenGl.exe - 4 error(s), 0 warning(s)<br />
|
|
|
|
|
Everytime or occasionally?
I have seen this on my VC++6 two years ago when I was compiling a very large project. It might be VC++6 too busy... Just rebuild. You don't have to call Microsoft.
BuggyMax
|
|
|
|
|
I don't know anything about Open GL. But there are occations where templates can produce internal compiler errors.
Probably you find some help through Google. You are not the first do encounter this...
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I had this problem the other day. The debug build was OK, the release caused a Internal Compiler Error.
Try turning off all compiler optimizations and see if it build then. If it does, try enabling one at a time until you identify the one causing the problem.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
We saw something similar a few months ago and for us the solution was to apply the latest Visual Studio service pack, 6 I think. Good luck.
|
|
|
|
|
I want to trigger a function every 30 minutes. I understand that this can be done by using timers. But a timer object needs DispatchMessage() function for TimerProc() to get called.
Is it possible to provide a message loop in a windowless DLL? If yes, where should the message loop be defined?
(I tried providing a message loop in the DLL but the DLL started showing strange behavior. Is it at all possible?)
Windows ce does not support Timer Queues or Waitable timers. Is there any other option?
Any suggestions would be highly appreciated.
Thanks,
Ruchika
|
|
|
|
|
Instead of using a TimerProc() you might consider using a thread. Look up CreateThread() (Windows CE 1.01 and later) in the MSDN Library.
Oooh! Do not forget to look at the totorials on threading.
Trust in the code Luke. Yea right!
|
|
|
|
|
You can do something like this:
Init fcn:
{
...
theApp.m_sAlertParamStruct.hThread = ::CreateThread(NULL,0,BackgroundAlertThread,(LPVOID)&theApp.m_sAlertParamStruct,0,&dwThreadID);
...
}
DWORD WINAPI BackgroundAlertThread(LPVOID pParams)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
BACKGROUNDPARAMSTRUCT *pParamStruct = (BACKGROUNDPARAMSTRUCT *)pParams;
char caBuf[21];
if (pParamStruct->pApplication->GetUserTagValue("AlertBackgroundThreadRunFrequency",caBuf))
iRunFrequency = atoi(caBuf);
// check not more frequent than every 30 seconds..
if (iRunFrequency < 30)
iRunFrequency = 30;
int iSeconds = 0;
while (!pParamStruct->bTerminateThread)
{
iSeconds++;
if (iSeconds >= iRunFrequency)
{
// do your thing here......
iSeconds = 0;
}
Sleep(1000);
}
if (!pParamStruct->bTerminateThread)
pParamStruct->hThread = NULL;
return 0;
}
|
|
|
|
|
Thank you so much for the suggestions.
I am leaning more towards not adding a background thread mainly becz I already have three threads in my module. So, I am thinking of modifying one of the threads that I have to wait for RETRANSMIT_TIME, do the job and again wait.
Ruchika
|
|
|
|
|
Exactly what I had in mind!
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello,
I am working on a suite which needs to launch small file processing applications once a while. As my suite application spawns the small helper application, it losses the focus, and not regain it until the helper application complete and exit.
I wonder anyone knows how to launch an application (no UI) in background? I am using function ShellExecuteEx() right now.
Regards,
--jC
|
|
|
|
|
Search codeproject for ShellExecuteEx() and or CreateProcess(). There is an example around here some where, a similar example is out on the web [some where].
Also do the same search on the MSDN Library.
Sorry I could not be more helpful, but that is how I found imformation you are looking for last month.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello ,
Iam doing a MFC project.Iam displaying Animated GIFs with CDhtmlDialog class.This method works but the problem is that it works like a IE explorer.FOr example ,if i right click on the image a menu appears which is same as the IE right click menu .
Is there a way to get rid of this menu and similar such default IE message handlers??
|
|
|
|
|
I've never used VC++NET and I don't know if it is the same, but in a HTML Web page you can weite down this and the popup disappears...
<html><body oncontextmenu="return false"> ...
Hope this helps...
|
|
|
|
|
ACtually iam dispaling images here .ANyway i wil try ur suggestion .Thanks for it .
I solved it by getting the child window and disabling the user input to it !!!( Wnd->Enable Window(FALSE))
|
|
|
|
|
I'm having a little problem with trying to use one app to get two GDI+ windows up. I am using MFC.
I was origonally initializing GDI+ graphics as ::
Graphics graphics(::GetDC(m_hWnd));
And whenever two GDI+ screens overlapped, one would not reprint however, mouse movements on that window would still work). I changed the above to :::
CPaintDC dc(this);
Graphics graphics(dc.m_hDC);.
And right now, both screens are active, meaning if I move one over the next, both would reprint, however, they would not reprint on command, meaning that if I move my mouse over a button, it would internally change the variable to highlight, but the display would not get displayed.
Using method # 1, displays the graphics whenever possible, but using #2 only displays it on a window resize... I am putting the code inside the OnPaint function.
Any ideas? I have no idea why the behavior is different. Can one app have two GDI+ windows constantly repainting? I am using CS_OWNDC.
Thanks for the suggestions!
|
|
|
|
|
Hi All,
I need to integrate MapPoint software into my MFC database application. Basically what i want to acheive is to
get the data from the database and display it in the map. Application has to invoke the map and draw the route on it.
Any ideas will be appreciated.
Thanks,
John
|
|
|
|
|