|
Well, you could do it like that, but you would have to do it:
pDC->EndPage();
pDC->StartPage();
OnPrepareDC(pDC);
.. rest of printing code.
What you really need to do is to set the CPrintInfo max_page value to the number of pages you want to print. In OnPreparePrinting() you need to call pInfo->SetMaxPage(x). Your OnPrint() procedure will then be called once for every page to be printed. You should check the value of pInfo->m_nCurPage to see which page of output you need to draw.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
Yes, I concur. I have written a series of applications which produce bills (mainly for solicitors, or for the non-UK reader, lawyers). As you might imagine, these can often (all too often) be multiple pages. Some of them are for claiming from the Legal Aid Board, so have a rigid format, while others are more free-form in content.
The way I do this is to generate a list of printing objects, each of which knows the page it is to be printed on (my base CPrintObject has a PageNum() member). I go through on OnPreparePrinting and generate this list, then the last object in the list has my final page number.
This can be used in SetMaxPage(), and then in OnPrint, I just go through the list and for each object where PageNum() == pInfo->m_nCurPage, I invoke the object's Print method.
This works fine, and allows you to honour page number selection from the print dialog and so on.
The only issue I found was that the preview looked terrible, presumably because the preview view was getting confused about the font selection/deselection that was taking place, so I output to a memory DC then blit the result, which tidied it up at the expense of taking longer.
Steve S
[This signature space available for rent]
|
|
|
|
|
I call the FindText SDK function to open a modeless "Find / Replace" dialog.
I have defined some keys with accelerators (like 'S', ...) in my application.
So, the problem is that the modeless "Find / Replace" dialog do not get this keys - the main application get the keys!
How to fix???
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Override the dialog PreTranslateMessage( ). If the accelerator keys are defined in the main accelerator table you could use this code inside PreTranslateMessage:
<br />
<br />
if ( pMsg->message == WM_KEYFIRST && pMsg->message <= WM_KEYLAST )<br />
{<br />
CWnd* pMainWnd = AfxGetMainWnd( );<br />
if ( pMainWnd != NULL )<br />
{<br />
HACCEL hAccel = static_cast< CFrameWnd* >( pMainWnd )->GetDefaultAccelerator( );<br />
if ( hAccel != NULL && ::TranslateAccelerator( pMainWnd->GetSafeHwnd( ), hAccel, pMsg ) )<br />
{<br />
return TRUE;<br />
}<br />
}<br />
}<br />
<br />
return CDialog::PreTranslateMessage( pMsg );<br />
<br />
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Thanks! I will try it!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi,
I'm trying to add bitmaps to the menu in my vc++6 app.
The problem is that my bitmaps have a purple background and this is displayed in the menu. How do i load a bitmap and set a color to transparency?
cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
You need to do a transparent blit into a bitmap-dc. W2K and up have a API-fkt doing this. Older Windows have to emulate that via several blits using a sequence of ROPs.
I found such a routine on codeguru*duck under the knife thrown*.
Alternatively, the function AfxLoadSysColorBitmap() might do what you want. It is in afxext.h .
|
|
|
|
|
Hi everybody,
A question with regards the above. How does one show the X-axis label and the Y-axis label? Not the axis values.
In other words the x-axis label could be something like:
Time (hours)
Thanks
Regards
Rui
|
|
|
|
|
I'm creating a MDI application which creates a context menu by re-using a menu from the parent frame. This works fine when the child frame is not maximised. But when the child frame is maximised I get the wrong menu. i.e instead of getting the 4th item in the menu, it gets the 5th when maximised. This is not really true, as I notice that an icon is inserted as the 0th item in the menu when maximised. ie
restore view:
MENU
0th = File, 1st = Edit, 2nd = View, 3rd = Model
maximised view
MENU
0th = ICON, 1st = File, 2nd = Edit, 3rd = View, 4th = Model
The code I've used for my context menu is shown below
CMDIFrameWnd *pMainFrame = GetMDIFrame();
CMenu *pMenu = pMainFrame->GetMenu();
pMenu = pMenu->GetSubMenu(3);
pMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON, point.x, point.y, this, NULL);
any please would be appreciated
|
|
|
|
|
You could use CMenu::GetMenuItemCount() to determine whether to get the 3rd or 4th submenu.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thx for the tip, the menu count method fix the problem. But I've decide the use the GetWindowPlacement() function to get the state of the child window, which is more general I think
CMDIFrameWnd *pMainFrame = GetMDIFrame();
CMenu *pMenu = pMainFrame->GetMenu();
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if (wp.showCmd == SW_SHOWMAXIMIZED)
pMenu = pMenu->GetSubMenu(4);
else
pMenu = pMenu->GetSubMenu(3);
pMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON, point.x, point.y, this, NULL);
|
|
|
|
|
If I have this decimal number (Base 10) where the maximum value is 256, and I want to convert that to a hexidecimal in unsigned char format.
<br />
data[0] = 154;
data[1] = 203;
data[2] = 15;
data[3] = 54;
data[4] = 248;
data[5] = 175;
and I want to change data(base 256) to Ctring which have format in base 16 character
<br />
unsigned char *m_data;<br />
<br />
and I want <br />
m_data = "9ACB0F38F8AF";<br />
Do you know how to do that?
|
|
|
|
|
Didn't you just ask this question earlier? You can use the CString Format() member function.
If you need an unsigned character array instead of a CString class you can simply use the (LPCTSTR) cast operator to retrieve the pointer and then cast it to an unsigned char * pointer.
I suspect your asking this question again because your using C and not C++. You really need to put more information in your questions, if you expect to get your question answered correctly. If your using C, then you would use the sprintf() function which has the same functionality of Format(). Get a C book or search for sprinf() on the web!
<br />
sprintf(m_data, "%2H%2H%2H..",data[0], data[1].......<br />
- Anatari
|
|
|
|
|
Anatari wrote:
suspect your asking this question again because your using C and not C++. You really need to put more information in your questions, if you expect to get your question answered correctly.
He he, I couldn't agree more. Probably these guys have never done any kind of useful bug reporting in their whole lives.
The bad thing is, it's my experience that trying to teach posters to better ask questions only made me have an insult in return...
Back to real work : D-25.
|
|
|
|
|
Not to mention the high probability that we're helping the kid do his homework...
Software Zen: delete this;
|
|
|
|
|
CString strOutput;
int nNumDataItems = 6;
for (int nData=0; (nData < nNumDataItems); nData++) {
CString strHex;
strHex.Format ("%0X", data[nData]);
strOutput += strHex;
}
or
char szOutput [256];
strcpy (szOutput, "");
int nNumDataItems = 6;
for (int nData=0; (nData < nNumDataItems); nData++) {
char szHex [4];
sprintf (szHex, "%0X", data[nData]);
strcat (szOutput, szHex};
}
Did we just do your homework for you?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have an application that working with files named like <name>.ext (ext is my extension)
I can run it this way: myapp.exe <file.ext>
But when I try to open this file from HTML page (<a href="a.ext">file</a> ) IE asks me about open or save. How can I have it to stop do this?
I've registered my MIME-type in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Accepted Documents
but it have no effect.
With the best regards, Vitaly.
|
|
|
|
|
|
I don't think you can force a user to open your file automatically from a web page. That would be a huge potential security risk. However, to set your own computer to open it automatically, just check the box "don't ask me again" when choosing open or save.
- Anatari
|
|
|
|
|
This haven't helped. This checkbox reappeared on next download.
And setting "Confirm open on download" in (Any Folder)->Tools menu->Folder Options->File Types->(My File)->Advanced haven't helped too.
Win2k, IE 6.0
With the best regards, Vitaly.
|
|
|
|
|
Hello,
I have dialog based application in VC++ 6.0. I need to copy a file to a user specified location. So I am making a button, when clicked by user, would just ask for the path that they want copy the file to. They don't need to specify the name of them file. It is a default database file. After they specify the path I need to copy the database file to that location.
I don't know how exactly I should implement it. I couldn't really find any function that will make a copy of a file to a specified location. What control and functions do I need to use.
Thanks for helping me with this basic problem.!!
I really appreciate it.
Sincerey,
Anjum.
|
|
|
|
|
For the dialog to select the Path you could use SHBrowseForFolder ,
or better look here at CP for a really useable replacement.
And what is wrong with ::CopyFile() /::CopyFileEx() ?
|
|
|
|
|
Thanks for your quick reply.
I couldn't really find the information on CopyFile()/""CopyFileEx(). Also Could you please tell me what SHBrowseForFolder is? .. I tried to search for both of these things that you suggested in the MSN VStudio Help but did't find anything .
Thanks !
Anjum.
|
|
|
|
|
|
use this:
::CopyFile(csOrigen,csDesti,TRUE)
where csOrigen is the source path (CString),
csDesti is the destination path (CString too),
and the last BOOL parameter is a flag that defines if you want the operation to fail if the file exists.
Take a look at the MSDN for further information...
|
|
|
|