|
First, you need a printer DC, which you can then use with GetDeviceCaps to determine (approximate) page size. From there, you select in the font you want to use. Then use GetTextMetrics to fill in a TEXTMETRIC, (specifically for tm.tmHeight) and then divide the page height by the line height. This will give you nLines, although you might want to adjust for your own margins etc.
Many moons ago I produced a series of "Print Object" classes, each of which represented some kind of output, and was capable of measuring and rendering to a DC based on their content, so I could do things like create a text print object with a specified width (in logical units), and it would then tell me how tall it needed to be (including any line wraps etc).
For things like print/print preview this is quite useful, as I could generate a complete set representing the data in my apps. In that way, knowing the number of pages and the exact layout becomes much simpler, even for relatively complex documents. I used it as the print-engine component for a series of billing applications, for instance.
Steve S
Developer for hire
|
|
|
|
|
hello friends,
I want to perform some task if user does click on web page submit button from vc++ prog.
How will i find that user has clicked on button.
If anybody has idea then please reply.
Thanks
Harish.
|
|
|
|
|
Hello !
I need to add menu bar to child MDI window derived from CMDIChildWindowImpl<cmychildframe, caxwindow="">
I tried to initialize CMDICommandBarCtrl m_CmdBar member of CMyChildFrame in OnCreate method, but it changes menu in MainFrame...
Please help me
Thanks.
sash
|
|
|
|
|
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.
|
|
|
|