|
You should be able to calculate the number of pages inside OnBeginPrinting(). Call pDC->GetDeviceCaps(VERTSIZE) to find the vertical height of the paper in mm. You should then be able to calculate the number of pages from the number of lines, the font size and the page size. Here is what I do...
void CActionManView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
m_nHeight = 32; Font size
m_normalFont.CreateFont(m_nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,"Ariel");
pDC->SetMapMode(MM_LOMETRIC); // 0.1mm units
int height = pDC->GetDeviceCaps(VERTSIZE) * 10; // Get size of page in mm and scal to 0.1mm units
m_nItemsPerPage = height / m_nHeight; // Calculate items per page
m_nItemsPerPage -= 10; // Allow for header/footer
unsigned int nNumPages = (GetPrintableTaskCount() /m_nItemsPerPage)+ 1;
pInfo->SetMaxPage(nNumPages);
m_nPrintItemIndex = 0;
}
Hope this helps.
Tony
|
|
|
|
|
hi,
How to convert CString ...string to long value..do we have any c function..
Thanks in before..
James
-- modified at 13:05 Friday 30th June, 2006
|
|
|
|
|
|
i have used it..but compiler is giving error..i have taken CStringArray..i am getting element from the array..and trying to convert to long..using atol function...
thanks in before
james
-- modified at 13:14 Friday 30th June, 2006
|
|
|
|
|
|
cannot convert parameter 1 from 'class CString' to 'const char *'
|
|
|
|
|
use ttol.
CString str = _T("12345");
long l = ttol(str);
When UNICODE is defined, TCHAR (which is what CString uses) is defined as wchar_t (which is typedef'd as unsigned short). When it is not defined, TCHAR is defined as char. Make sure you use the t-methods when dealing with strings and UNICODE builds.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
If you are using CString, make sure you use the _ttol method. If you are building with UNICODE turned on, atol/atoi will give you conversion errors.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks for reply..yeah i have checked,when i build in debug mode i did not get that error,when i build in UNICODE,i got the error...
One more Error...
error C2664:'CollateNoCase' : cannot convert parameter 1 from 'char [5]' to 'const unsigned short *'
how to over come this error pls
thanks in before
james
|
|
|
|
|
Use the t-methods and TCHAR instead of the standard methods and char.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
RockyJames wrote: how to over come this error pls
If it's a string literal, precede it with an L , or use the _T() macro
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I want to change the visibility of a push button, such that given a certain condition, the button is not visible at all (I don't mean just greyed out, I mean completely gone). What method do I use to control this?
Thank you.
|
|
|
|
|
::ShowWindow(SW_SHOW/SW_HIDE) or CWnd::ShowWindow(SW_SHOW/SW_HIDE) depending on if you are using Win32 or MFC.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I have an SDI application that has inherited CFormView as the base class. When the application was created it disabled all print functionality. I would like to be able to add this functionality. I know that I can add virtual functions but I am confused on what to put in these functions. I would like to print the application as it looks. Is that even possible? Any help would be great.
thanks,
adam
|
|
|
|
|
link
That should at least get you started.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
there are a few things that I don't understand in this code example. one i don't know what the variable m_dib is and where it came from. I also don't understand GDIUtil::GrabDIB function call. I get an error that the compiler doesn't know that it exist. any help would be great.
thanks
|
|
|
|
|
The author of the article used someone else's code (the GDIUtil class/namespace). Click on the link he provides in the article for more information.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
I have a server application that runs on a Windows PC (4000 miles away) and I would like to be able to update the server s/w remotely. I guess one crude way would be to exit the app, copy over the new one and re-boot the PC, but the PC needs a login password.
I dont have any problems shutting down the server app, or copying over the new one, but has anyone any suggestions how I can restart the server app without restarting Windows?
TIA
Tony
|
|
|
|
|
Two things come to mind: RPC and REXEC.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am trying to create a GUI for a C++ application using Visual Studio 2005, which I am new to. The GUI has one main form and several minor forms that all need access to an object, not GUI related, that I created. What is the best way to make this object accessible to all forms? Should I pass a pointer to it in the constructor of each form? Should I create a global object that the forms can refer to? Or does Visual Studio have some built in mechanism to share that ressource?
I would appreciate any suggestions and help.
kialmur
|
|
|
|
|
You have been at this for two weeks now. You should be posting information about what you have tried along with how and why it did not work as expected.
Off by one thread error Last modified: Friday, June 30, 2006 10:22:50 AM -- posting error by user - led mike
|
|
|
|
|
The short answer is: You can pass it any way you want to.
The long answer is: There are some good ways, and some bad ways of doing this depending on what you are trying to do.
If you can be more specific about the architecture (e.g. are the forms/dialogs that need access to this object going to be writing to it, or just reading from it? are they only going to need part of the information for each dialog? etc), more details can be given about how you might want to implement it.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I basically used the standard Windows forms project to start off. The .cpp, with the main(), that Visual Studio automatically creates is used to run the thread that launches my main form. The main form allows me to modify and view the status of my object, which interacts with various hardware cards and other. From that form, I have one sub-layer of forms that allow me to modify specific aspects of the object. Each form, except the main one, typically modifies or views information about one portion of the object, such as a card it interacts with. So I need to both write and read from the object within both layers of forms.
To answer the post of the next person, I have already separated my application based on the Model-View-Controller pattern. I simply do not know how to give access to the object to each form, since each form is a class.
I hope this helps you in answering me. I am hoping you will be able to suggest one of the good ways to give access.
Thanks in advance.
kialmur
|
|
|
|
|
kialmur wrote: To answer the post of the next person, I have already separated my application based on the Model-View-Controller pattern. I simply do not know how to give access to the object to each form, since each form is a class.
So each form is a "view" in the design and uses the "controler" to send messages into the other isolated objects in the design.
kialmur wrote: So I need to both write and read from the object within both layers of forms.
Well not directly that is why you have the MVC design. The forms don't know about the object just the controller and events. So the forms call methods of the controller which results in the "write" operations. Some other object(s) should be performing the "read" operations which then results in an "event" that the forms can subscribe to. The event can contain the data directly or the data can be sent into the "model" in the design at "read" time and then when the form event handler fires it can access the data through the "model" object.
Does that help?
|
|
|
|