|
OK, before everyone gets the sh*ts and ignores me I have moved further along than last time I posted about this.
I have read Chris Maunder's article and Knowledge Base Q133275, and have text printing in the middle of the page. Problem is I want to be able to have headers, footers and formatting.
I assume \n and \t will give me newlines and tabs but how do I set the tab stops?
I created an empty SDI application to look at how the printing is done. Looking at the message maps in the View, I found CView::OnFilePrint being called. This is not a member function of the SDI application nor could I find it in MSDN. What is it and what does it do?
How do I build the page in memory with formatting before printing?
How do I get Print Preview in my appliaiton?
My application is dialog based, the data to print is being retrieved from a database and in about 43 hours I have to demonstrate this functionality.
All help greatly appreciated.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
how do I set the tab stops?
You need to use ::DrawTextEx if you want to set tab stops. Note that there's no MFC wrapper for this function. You'll have to pass GetSafeHdc() as 1st arg.
I found CView::OnFilePrint being called. This is not a member function of the SDI application nor could I find it in MSDN.
CView::OnFilePrint is the place where MFC doc/view printing is implemented. It shows the print dialog and has the main print output loop. Overridable CView functions are called from CView::OnFilePrint.
How do I build the page in memory with formatting before printing?
I think you shouldn't 'build the page in memory'. What you should do is:
1) calculate number of pages,
2) call CDC::StartDoc,
3) for each page: CDC::StartPage, page contents printed with various CDC methods, CDC::EndPage.
4) call CDC::EndDoc
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I would like to know if we could use the case method with more than 1 expression. For example, i want to do the same thing for case 1 to 10, another thing for case 11 to 15...
Is it possible?
thanks in advance
gerald
|
|
|
|
|
Yes.
switch(expression)
{
case 1:
makesomething()
break;
case 2:
case 3:
case 4:
makesomething2();
break;
case 5:
.
.
.
}
Cheers!!!
Carlos Antollini.
|
|
|
|
|
I have created a window inherited from CFrameWnd using the create function and I use WS_VSCROLL to stick a vertical scroll bar on the right edge. I want to be able to code the movements of the user clicking on the scroll bar etc and the movement shown withing the bar, my problem is what is the scrollbar called so I can call member functions such as GetScrollPos() etc. I have tried the method OnVScroll and used the pScrollBar parameter but this only comes up with a run time error as if it were null which I think it is.
cheers in advance
Nick
|
|
|
|
|
The pScrollBar is null if the scrollbar is not a control but belongs to a window. Simply use the CWnd::GetScrollPos member function.
void CMainFrame::SomeFunc()
{
...
int pos = GetScrollPos(SB_VERT);
...
}
Oliver
|
|
|
|
|
Hi,,
I like to know how can I name sub-menu's dynamically.
I mean, its name has to be chaged in different stages of the program,,
Any ideas???
thanks
Ehsan Behboudi
|
|
|
|
|
Hi All,
I have a NT Service.I want to shut down the service without the interpretation of SCM.So, I calling CServiceModule::Handler() with opcode "SERVICE_CONTROL_STOP" and the service to shutdown.But, my service is shutting down at the same time it's giving error "Error :2140 An Internal error occured" .
How can I rectify the problem.I would like to know what happens after I say service shutdown.
Thanx in advance for the help.
Regards,
yamini
|
|
|
|
|
Try this:
http://support.microsoft.com/support/kb/articles/Q115/8/29.asp
Kind regards,
Martin
|
|
|
|
|
Hi,
Thanx for the idea.But, I am using ATL Service.I ahve a function CServiceModule::ServiceShutDown() & the function code goes as below.
void CServieModule::ServiceShutDown()
{
SetServiceStatus(SERVICE_STOPPED);
PostQuitMessage(dwThreadID,WM_QUIT,0,0);
}
I am calling this function from CServiceModule::Run() before the Loop and I put a MessageBox in CServiceModule::Handler() case SERVICE_CONTROL_STOP to indicate that the service is stopped.When I try to start the service thro' SCM I am getting MessageBox and also error that "Error :2140 An internal Error occured>".
How can I update the SCM UI and notify that the Service has terminated(When the service terminates instead of Error I need to notify that Service cannot be started ).I mean, how can I terminate the service without such errors as I am using ATL generated Code & I want to achieve the service termination with this ATL Generated Code only.
Thanx.
|
|
|
|
|
SCM shows error 2140 in a case, when your service terminates with 'process return value' equal to 0. You have to find a way, how to return proper value (!= 0) when service process terminates. However, I cannot help you with ATL service class, because I have never used it - sorry.
|
|
|
|
|
I had the same problem.
I made this.
I saw that the problem was that the service didn't stop normally.
You have a thread that is dowing the service but the service didn't know that.
I put saome global variables for that.
For example when I recive the SEVICE_CONTROL_STOP I update a variable like
bRuning = FALSE;
In the Run I always Ask about this variable, I if I find that this variable is FALSE, I go out. (Kill all process like threads, etc, and go out from Run.)
Sometimes the problem is an error in the code that you in debug mode don't see.
I work with trace file and with the Event log for test my Release version. Sometimes I have a mistake.
I hope to Help!!!!
Regards
Carlos Antollini.
|
|
|
|
|
the tree control sends a notify message. How do I extract the TVN_SELCHANGED message from the message? I need somethin like this:
case WM_NOTIFY:
switch (LOWORD(lParam))
{
case IDC_MYTREE:
{
if (HIWORD(lParam) == TVN_SELCHANGED)
dostuff();
break;
}
}
Should be kinda simple, but couldn't find it anywhere in a sample or in the help files
thanks,
WAVK
|
|
|
|
|
lParam points to a NMHDR structure, or a structure that contains NMHDR as a first member. NMHDR has a member named 'code', containing the notification code. Expression that tests the notification code looks like this:
((NMHDR)lParam)->code
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
the NMHDR has to be LPNMHDR in my case, but perfect!
|
|
|
|
|
the NMHDR has to be LPNMHDR in my case
Sure! I've forgot to include '*' in the cast expression. LPNMHDR is just a typedef for 'NMHDR *'.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have list control and its operation is just like the explorer
But when I sorting this list control the directory and files and mixed.
How can I sort it separately like explorer
|
|
|
|
|
Hi,
I'd like to know how can I fill region
with 50% OPACITY white color ?
I need it for hiliting .
Probably the answer is alpha channel functions ( Win2k ) or
OpenGL , but I want to be as simple as possible and working
under Win95 and higher.
Thanks !
|
|
|
|
|
The current issue of WDJ has an article on how to get ahold of the bits of a bitmap and iterate through them, it shows some simple filters. Next month my article on an alphablend function for W95 will be published, but it basically uses the techniques shown by the tech tip in question - copy your bitmap to a DIBSection, iterate through the bits to modify and copy back.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Actually , I don't wanna deal with copying bitmaps back and forth.
I need smth like
FillRgn(
HDC hdc, // handle to device context
HRGN hrgn, // handle to region to be filled
HBRUSH hbr // handle to brush used to fill the region
)
function modified sucha way that it will be able to draw x% opacity
color.
|
|
|
|
|
The region thing may be interesting, but the point of what I said is it is buried in a function, so all you have to do is pass in the HDC that holds the bitmap.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
I have created a dlgbox with combo box. In the style properties of it i have selected option drop list. But when i run the dlgbox, i could select the data only when i write the first letter of it and after i could choose other thanks to the keyboard.So, my problem is that i couldn't select the data directly with the combobox, e.g, when i click on the combobox it doesn't show all the data we could choose. WHY?
thanks in advance
gerald
|
|
|
|
|
You need to change the dropdown height. In the dialog editor, click on the combo's arrow button and drag the resize handles to increase the height.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All,
We've developed a fair sized application in Visual C++ 6.0. The App is supposed to run on all Windows (NT, 9x, 2000) platforms. Primarily we developed the App on Windows NT and it runs just fine. But when we run it on Windows 98, strange things happen. The system font i.e. the font in all Windows gets changed and strange messages, which are in the resource file from the past but we don't use, appear. We are deleting all GDI objects that we create in the App. We'll highly appreciate any idea about the reasons or pointers to any helpful articles.
Thanks,
Asif
|
|
|
|
|
We are deleting all GDI objects that we create in the App.
This is not enough. Probably your objects are selected into some device context when you're deleting them. MFC objects are freed, but their GDI counterparts are not. The result is GDI resource leak.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|