|
hi,i met a problem to convert an unix timestamp to date.
how to work with this problem in c/c++ (not MFC).
e.g.
as to a given second number 123998001,what can i do to convert it to the date format like "day/month/year --:--:--"
|
|
|
|
|
If it's a time_t (i.e. seconds since Jan 1st 1970, IIRC), then you want to use one of localtime or gmtime to get a structure containing deconstructed time and date information followed by sprintf to get the string you want.
|
|
|
|
|
thank you,that's what i want. i have seen this type before, but didnt pay much attention.
|
|
|
|
|
I am using VC2003 and working on a mfc project that includes ALT(i'm a beginer in ATL) and I encountered the folowing problem :
I have defined some properties
interface IATLDisplay : IDispatch{
// ..... more properties
// the next line is the one with the problem
[propget, id(2), helpstring("property GetLastChangeTime")] HRESULT GetLastChangeTime([out, retval] COleDateTime* pVal);
};
Upon compiling i get the folowing error message :
error MIDL2025 : syntax error : expecting a type specification near "COleDateTime" - error related to the above presented line
Any ideea why this apears ? do i need to import some aditional .idl file ?
Thanks for any help .
|
|
|
|
|
COleDateTime is a MFC\ATL class and cannot be used in a idl file, you need to use DATE*.
|
|
|
|
|
Hi ,
I am working on a C++ allocator class in shared memory(UNIX).
I can see that the allocator creates space for the object being pushed in the shared memory but the vector skeleton resides in the usual process address space(I mean in stack or in heap).
When i fork ,I get a copy of the vector and the shared segment in the child process . But any updations made by the child is now no longer visible to the parent process.
The psedo code is as follows:
if (fork()==0)
{
push new elements to the vector //child
}
else
{
shmdt(shared segment);
getchar();
shmat(sharedid);
Iterate vector in parent
}
In the above pseudo code , If i iterate in the parent I am not
able to see the changes in the parent.
Please suggest a solution to make the parent visible of whatever changes i make in the child.
Thanks in advance
|
|
|
|
|
psbasha wrote: I am working on a C++ allocator class in shared memory(UNIX).
I don't mean to discourage you, but such an allocator already exists and is freely available. It was originally published at C/C++ Users Journal - if you look around, I am sure you'll be able to find the code.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Namanja is correct; implementations already exist. One such implementation is called Shmem and comes with the Boost librarys. Here are some links.
Shmem docs[^]
Boost[^]
It's free and multiplatform.
Steve
|
|
|
|
|
hi,
i have implemented a COM object in ATL. the string values are BSTR data types. i have been able to implement CString in DCOM by including the <afxwin.h> and <afxdisp.h> in the StdAfx.h file. i did the same in my COM server and i get an error : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
meanwhile, i have not included any windows.h file.
BSTR is more complex to handle than CString. isn't it possible to use CString in COM. why does it work in my DCOM and fail in my COM. be most grateful to find a way out of this.
Already this questioned was answered in expertsexchange.com but we need to pay to see the answer. Please can any one let me know the solution.
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20776014.html"
Thanks
Masthan
-- modified at 9:22 Thursday 27th April, 2006
|
|
|
|
|
What version of VS are you using? Because since 7.0 CString was changed to a templated class. So it became possible to use the CString in MFC (which will give you the above problems, if using VS6), and ATL.
For ATL specific project, use the CAtlString class. CString is virtually derived from that, but you can used it in your ATL project.
I Dream of Absolute Zero
|
|
|
|
|
Hi,
Thanks for your response. I am using VS6. I am trying to build ATL COM Service and hence in the AppWizard I am not able to add support from MFC to my workspace. If I want to add MFC to my project how can I do that?
Regards
-- modified at 7:06 Friday 28th April, 2006
|
|
|
|
|
Hi,
I'm creating an ATL Exe Server that wraps an ActiveX(OCX) control inside the exe server. All the methods and events of the ActiveX are mapped to the Exe servers methods and events. I'm having a problem with one of the events fired from the ActiveX control to the Server Exe back to the Client. When I fire the event via the Invoke command it returns an error CO_E_NOTINITIALIZED. The other events fire without any problems. The only thing I can think of, is the event in the ActiveX control that is firing the event is on a seperate thread. Any ideas?
Thanks
|
|
|
|
|
CO_E_NOTINITIALIZED means that CoInitialize , CoInitializeEx or OleInitialize hasn't been called for the thread.
Steve
|
|
|
|
|
Hi Steve,
Do I need to call the CoInitialize in the ActiveX(OCX) thread for that event. I tried that too, I then get the following error.
RPC_E_WRONG_THREAD which translates to "The application called an interface that was marshalled for a different thread." I don't know what to do next. Any ideas?
Thanks
|
|
|
|
|
I suspect you're passing interface pointers between threads without marshalling. In general this can't work as COM has to take the difference in the threading models into account and it does this by setting by proxies and stubs when an interface is marshaled. Threading is complicated.
Steve
|
|
|
|
|
Hi Steve,
Do you know how I can do this between the ActiveX(OCX) and the ATL Exe Server?
Regards,
|
|
|
|
|
how to programming for allow users drag & drop spliter to adjust
control position?
just like windows explorer.
you can adjust position of both left directory tree and right file
details.
and I need add this function in Standard VC++ 6.0 (can't using MFC).
because I need add this in my ATL control.
thanks in advance.
|
|
|
|
|
|
to Mike,
Thanks for your reply. I have read your acticle your provided. this is a class under MFC. can you using it in my ATL (not support MFC)?
Thanks in advance.
|
|
|
|
|
No, it's not an MFC class. The article however is targeted at MFC developers, making the WTL learning curve less steep.
|
|
|
|
|
CSplitterWindow is a WTL class, not MFC, you'll have no trouble using it in an ATL project as long as you add the right WTL includes. See Part 1 and 2 of the series for details on how to set up a WTL project.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thank you very much, I will try it later, Now I am coding for other important functions in my project.
|
|
|
|
|
Hi Mike,
I am writing code for add a splitter now.
I downloaded WTL7.1 and setuped it. then add this includes into vc directories.
But, there are many errores happened when I add two include(atlapp.h and atlsplit.h) only.
the following text is error messages
--
D:\WTL71\INCLUDE\atlapp.h(397) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(398) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(596) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(600) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(601) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(604) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlapp.h(845) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(57) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(82) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(205) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atluser.h(490) : see reference to class template instantiation 'WTL::CMenuT<t_bmanaged>' being compiled
D:\WTL71\INCLUDE\atlgdi.h(78) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(86) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(88) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(528) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlgdi.h(682) : see reference to class template instantiation 'WTL::CBitmapT<t_bmanaged>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(824) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(852) : see reference to class template instantiation 'WTL::CSplitterWindowImpl<t,t_bvertical,tbase,twintraits>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(823) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(863) : see reference to class template instantiation 'WTL::CSplitterWindowT<t_bvertical>' being compiled
D:\WTL71\INCLUDE\atlsplit.h(823) : error C2872: 'ATL' : ambiguous symbol
D:\WTL71\INCLUDE\atlsplit.h(863) : see reference to class template instantiation 'WTL::CSplitterWindowT<t_bvertical>' being compiled
E:\Workspace_synviz\SynViz1.1\SynVizRGGantt\StdAfx.cpp(8) : error C2856: #pragma hdrstop cannot be inside an #if block
E:\Workspace_synviz\SynViz1.1\SynVizRGGantt\StdAfx.cpp(9) : error C2856: #pragma hdrstop cannot be inside an #if block
Error executing cl.exe.
--
ATL + WTL these confuse me deeply.
Thanks in advance.
|
|
|
|
|
Just a thought, have you tried Build->Rebuild All? That seems to fix some problems I've had in the past...
[EDIT]Are you including these files in stdafx.h?[/EDIT]
- S
50 cups of coffee and you know it's on!
-- modified at 2:23 Thursday 27th April, 2006
|
|
|
|
|
Hi Steve Echols,
Thanks for your reply.
Steve Echols wrote: Just a thought, have you tried Build->Rebuild All? That seems to fix some problems I've had in the past...
--
I alway press F7 key from building my project. F7 is short key for ‘Rebuild ALL’.
Steve Echols wrote: Are you including these files in stdafx.h?
--
yes. I add these include in 'stdafx.h' file.
|
|
|
|