|
If all you need to do is transfer a numeric value, use InterlockedExchange() which allows you to set a LONG as an atomic operation. (See help for explanation of Interlocked calls--if you do multithreading you should understand these.)
|
|
|
|
|
dianazheng wrote:
// Get the current time
CTime curTime = CTime::GetCurrentTime();
//Get the current date
CTime curDate = CTime::GetCurrentTime();
What is the point of this ? Both these objects are the same.
dianazheng wrote:
//Display the current date
m_sDate = curDate.Format("%b / %d / %y");
// Display the current time
m_sTime = curDate.Format("%H:%M:%S");
MSDN does not document these methods, have you tried using GetMonth/GetYear/GetDay instead ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
// Display the current time
m_sTime = curDate.Format("%H:%M:%S");
MSDN does not document these methods, have you tried using GetMonth/GetYear/GetDay instead ?
Actually, I have this one in my MSDN, so I guess that's why dianzheng wrote that "it works for time". Anyway, Chris is right, GetMonth/Year/Day is the best way to do it.
~RaGE();
|
|
|
|
|
i have try the get month get day and get year but it still can't work that why i change it to tis way. Using this way i can get the time but i coulsn't get the date..
pls help....thanks
|
|
|
|
|
dianazheng wrote:
i have try the get month get day and get year
... ... What's wrong ? Could you post your code again ? I'll give it a try inbetween.
~RaGE();
|
|
|
|
|
Ok, this runs perfectly :
COleDateTime dTime;
dTime = COleDateTime::GetCurrentTime();
int d=dTime.GetDay();
int m=dTime.GetMonth();
int y=dTime.GetYear();
m_sDate.Format("%i / %i / %i",d,m,y);
~RaGE();
|
|
|
|
|
Really thanks for your help,i can display the date and time directly from the computer but now i have face with another problem hope you can help me also...Thanks
I have this two error
C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\DLGDATA.CPP(170) : error C2065: '_countof' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\DLGDATA.CPP(181) : error C2065: 'AfxSetWindowText' : undeclared identifier
which i really don't know what are they but they come from the function below...Hope you can help...
AFX_STATIC void AFX_CDECL _Afx_DDX_TextWithFormat(CDataExchange* pDX, int nIDC,
LPCTSTR lpszFormat, UINT nIDPrompt, ...)
// only supports windows output formats - no floating point
{
va_list pData;
va_start(pData, nIDPrompt);
HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
TCHAR szT[32];
if (pDX->m_bSaveAndValidate)
{
// the following works for %d, %u, %ld, %lu
::GetWindowText(hWndCtrl, szT, _countof(szT));
if (!_AfxSimpleScanf(szT, lpszFormat, pData))
{
AfxMessageBox(nIDPrompt);
pDX->Fail(); // throws exception
}
}
else
{
wvsprintf(szT, lpszFormat, pData);
// does not support floating point numbers - see dlgfloat.cpp
AfxSetWindowText(hWndCtrl, szT);
}
va_end(pData);
}
|
|
|
|
|
I have a CStatic element on my dialog.
I use the following code to show different bitmaps:
<br />
myStatic.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)) );<br />
...<br />
myStatic.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2)) );<br />
...<br />
myStatic.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP3)) );<br />
One question: Must I call DeleteObject(...) when changing the bitmap or at the end of the dialog or does the CStatic this automaticly?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I'd say the fact that SetBitmap returns the previous bitmap means you need to delete them
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Thanks Christian!
One question: When do you sleep?
When I take a look on the CP forums, there is no question you don't post an answer!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
What's sleep ? I have young children.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You must free it...
<br />
HBITMAP hOld = myStatic.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)) );<br />
<br />
if (hOld)<br />
{<br />
DeleteObject(hOld);<br />
}<br />
Hope this helps...
|
|
|
|
|
Thanks!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello Folks,
I Have a problem of painting the border window that appears when a tool-bar is in floating state.
How can i achieve this ?. I tried by creating an object of CTOOLBAR derived class.,so there's no need of subclassing.
And in the MainFrame Class ,i processed the wm_paint message where i checked the myToolBarobj.isfloating() ..and performed the futher operation. .its working ... but what if i need to trap the paint message or I need to change the Wndproc ?
Pl help if any solution of any kind is availabe.
|
|
|
|
|
Hi,
Please tell me how to open browser in VC6.0..? I am displaying one url in my application I want that if I click that url it should open browser with the specified url...How to do that..Please help me.
Thanks in advance
|
|
|
|
|
ShellExecute a URL and the default browser will start.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
ShellExecute a URL and the default browser will start.
Exactly. If you need to handle your browser a little bit better, just use CreateProcess() . You may take a look at Mike's FAQ.
~RaGE();
|
|
|
|
|
ShellExecute worked...Thanks very much for the reply.
Prateeti
|
|
|
|
|
I want to draw on the ActiveX Control in Design Mode i.e
I placed a ActiveX control on the DialogBox, now i want to draw something on the control . How can i do this ?
Any help...
Thank you.
|
|
|
|
|
I think (not sure) it is not possible to draw on Antivex Control at design time. You can only draw on it after getting its Device Context through Coding.
|
|
|
|
|
Hi,
I'm unable to export a template class from an MFC based dll !
any ideas of how I can do it ?
Ciao
- Nilesh
|
|
|
|
|
Template classes are generated by their template arguments, they are in fact a little class factory. So I reckon you'll have trouble.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You can export a template class as long as you force the compiler to create an instance of the class that you are trying to export. That is because a template is a compile time feature.
You can force the compiler to generate the code for a particular type of object by simply declaring a global variable of that particular type. But for each type you declare the size of your DLL will grow.
There is no way to export a template from a DLL, an retain the power that a template provides.
Would it simply be possible for you to distribute the header file with the template class in it instead?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I once did what you are trying to do (for export to a non-C++ project), but as Paul mentioned, the benefits of templates are lost. One way is to create a non-templatised wrapper class, and wrap every single method so that it calls the template version. Make sure you inline everything to avoid extra call overhead. If you forget to wrap any methods, the compiler will not generate them at all. Of course, you will have to declare one specific type to be used with the exported class, hence the class will no longer be generic. You can create separate wrapper classes for different types, though your DLL will get rather large.
Cheers
|
|
|
|
|
Hi,
How can I get the position and dimension of my client area inside of my CFrameWnd without including the area of docked tool bars or status bars?
Thanks
|
|
|
|