|
int getCurrentYear()
{
time_t t;
time(&t);
tm* pTM = localtime(&t);
return pTM->tm_year + 1900;
}
This should do it, although I haven't compiled or much less tested it.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
How do I obtain the return value inside my code? Like if I wanted to take that value and subtract a number from it.
|
|
|
|
|
I don't have MSDN now but I can remember GetTime() or GetCurrentTime() do this.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
can anyone give the equivalent of converting the integer to a string using the shlwapi.h
????????????????
|
|
|
|
|
I'm curious to why you want to use ShellFunctions for converting an integer to a string. Why can't you use itoa or one for the ?printf functions, or even CString::Format?
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
just wanted to know ?
can you help out ?
|
|
|
|
|
A look through MSDN doesn't show any such function apart from wvnsprintf. You'd be better of sticking the the C Runtime versions though, as there are security warnings plastered all over this function.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
well i too did'nt get any function from MSDN and also after looking at the .h file. it might be containing the function but since all the functions are not documented i am not able to figure out the actual one.
anyway thanks
|
|
|
|
|
i am doing a project in which i am using CRgn variables to create a rgn, after creating a region i using the function
pDC->FrameRgn(&rgn,*brush,1,1);
this function frames the boder of the region in rgn
the problem is i see a framed region of 1 pixels thickness on the monitor but when it comes to printing the width of the lines is taken as 10 pixels and i get a different output when i take a print out
i am not able to under stand what is the problem ?
can any one can solve the problem and help me.
sri
|
|
|
|
|
hi
i like to implement tables in my vc++ application like
msword->Insert->Table option. Please help me how can i implement this.
thank you in advance
from
venugopal
|
|
|
|
|
Hi,
I am trying to modify some ISAPI code. for getting the domain name I use the GetServerVariable() call and pass "HTTP_HOST" and then parse the string(the host name). The problem is that for our internal environment, people type things like
"http://internal1"
This will take them to the correct URL.
Unfortunately the GetServerVariable with "HTTP_HOST" is returning "internal1" as the name. Its not giving the fully qualified domain name. Is there any way I can get the fully qualified name (eg: http://internal1.somedomain.com)?
Or do I need to use some WinSock functions? if yes which one?
Thanks in advance..
Madhu
|
|
|
|
|
I'm trying to build 2 apps in VC++6: one that writes character strings to a serial port (COM2) and one that reads them on another port (COM1). I'm running both apps at the same time, have the two serial ports connected with a NULL modem serial cable. Each app works fine by itself when I link the PC to a separate device through the serial cable.When I link COM1 and COM2, the writer app writes characters to COM2, but the reader app fails to read them on COM1. I'm not using any flow control. What am I doing wrong?
Any help is greatly appreciated.
|
|
|
|
|
For starters, make sure you have hardware flow control turned off in Hyperterminal. Unless you're sure that your cable is wired correctly to make that work, turning off all flow control will at least take that out of the equation.
|
|
|
|
|
Maybe you must use overlapped I/O.
Try this @ home. (B&B)
|
|
|
|
|
This is some standard code I use with serial ports:
DWORD dwNumBytesRead ;
DWORD dwNumBytesWritten ;
SECURITY_ATTRIBUTES sa ;
char szInputBuffer[2] ;
char szString[80] ;
int iStringIndex = 0 ;
int lamp_warming_timer ;
int lamp_on_timer ;
CString text ;
sa.nLength = sizeof(SECURITY_ATTRIBUTES) ;
sa.lpSecurityDescriptor = NULL ;
sa.bInheritHandle = true ;
m_hSerialPortHandle = CreateFile((LPCTSTR)m_csCommPortName,
GENERIC_READ | GENERIC_WRITE,
0,
&sa,
OPEN_EXISTING,
0,
0) ;
if (m_hSerialPortHandle != INVALID_HANDLE_VALUE)
{
m_bOpen = true ;
if (!GetCommState(m_hSerialPortHandle, &m_DCB))
{
text = "Serial port DCB failure." ;
::SendMessage(m_hwndParent, UWM_UC_STATUS, (LONG)(LPCTSTR)text, 0) ;
}
else
{
m_DCB.BaudRate = CBR_9600 ;
m_DCB.ByteSize = 8 ;
m_DCB.Parity = NOPARITY ;
m_DCB.fParity = false ;
m_DCB.StopBits = ONESTOPBIT ;
m_DCB.fDtrControl = DTR_CONTROL_DISABLE ;
m_DCB.fOutxCtsFlow = false ;
m_DCB.fDsrSensitivity = false ;
m_DCB.fTXContinueOnXoff = true ;
m_DCB.fOutX = false ;
m_DCB.fRtsControl = RTS_CONTROL_DISABLE ;
m_DCB.fAbortOnError = false ;
if (!SetCommState(m_hSerialPortHandle, &m_DCB))
{
text = "Serial port set com status failure." ;
::SendMessage(m_hwndParent, UWM_UC_STATUS, (LONG)(LPCTSTR)text, 0) ;
}
if (!SetCommMask(m_hSerialPortHandle, EV_RXCHAR))
{
text = "Serial port set com mask failure." ;
::SendMessage(m_hwndParent, UWM_UC_STATUS, (LONG)(LPCTSTR)text, 0) ;
}
COMMTIMEOUTS timeouts ;
timeouts.ReadIntervalTimeout = MAXDWORD ;
timeouts.ReadTotalTimeoutConstant = 0 ;
timeouts.ReadTotalTimeoutMultiplier = 0 ;
timeouts.WriteTotalTimeoutConstant = 0 ;
timeouts.WriteTotalTimeoutMultiplier = 0 ;
SetCommTimeouts(m_hSerialPortHandle, &timeouts) ;
}
}
else
{
text = "Unable to open serial port \"" + m_csCommPortName + "\"" ;
::SendMessage(m_hwndParent, UWM_UC_STATUS, (LONG)(LPCTSTR)text, 0) ;
m_bThreadDead = true ;
return ;
}
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
|
I am using the CSizingControlBar class in my application and I don't know how to change the width of the control. I tried SetWindowPos, but that didn't work. How do I change its width?
-- Steve
|
|
|
|
|
Have you tried here[^], it contains most of the info' on that subject.
Cheers
Kannan
|
|
|
|
|
Good luck ...
I've been trying to do this myself, and I can't really do it; there's a post in the archive section of the datamekanix ( see other answer ) that tells you to do something like :
void CMyBar::SetWidth(const int nWidth)
{
if (IsFloating())
m_szFloat.cx = nWidth;
else if (IsHorzDocked())
m_szHorz.cx = nWidth;
else
m_szVert.cx = nWidth;
m_pDockSite->DelayRecalcLayout();
}
but I was never able to make it work
|
|
|
|
|
hello everybody
I need some help with declering an pointer to my clss
my class of CFromView in there i have a function class LoadImages
<br />
class CTestView : public CFormView<br />
and i have a different class and object some where else and i want to point to this class where i double click my control
and load my images
<br />
CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();<br />
I new at this MFC Visual C++ program
can any one please help me
thanks...........
|
|
|
|
|
I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*.
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
|
|
|
|
|
|
CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd();
pMain->GetActiveView();
Sorry, I abandoned MFC a long time ago.
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
|
|
|
|
|
It's ok thanks for trying
in my program the is no GetActiveView() i keep getting an error.
maybe i'm putting this in the wrong way
this is what i have
CTestView * pView= (CTestView*)AfxGetMainWnd();
and lets say i want to call and function or an object like
this
pView->m_cThumbFrame.Add("picture.bmp");
but this dosen't work ((
|
|
|
|
|
E3 wrote:
in my program the is no GetActiveView() i keep getting an error.
After the cast ? Compiles fine here.
E3 wrote:
CTestView * pView= (CTestView*)AfxGetMainWnd();
Won't work. You'll get the CMainFrame class, which when cast has a GetActiveView() method.
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
|
|
|
|