|
I don't know.....maybe you have to get the printer first, then do the font....or.....
but I do everything in one procedure and just call this procedure and print....:
/*
** get the default printer
*/
CPrintDialog dlg(FALSE);
dlg.GetDefaults();
// Get a handle to the printer device context (DC).
HDC hdcPrinter = dlg.GetPrinterDC();
/*
** create a CDC and attach it to the default printer
*/
CDC dcPrinter;
dcPrinter.Attach(hdcPrinter);
//print as landscape
LPDEVMODE pDevMode;
pDevMode = dlg.GetDevMode();
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
dcPrinter.ResetDC(pDevMode);
// call StartDoc() to begin printing <=======================did you do this part?
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("CDC::StartDoc() Code Fragment");
// if it fails, complain and exit gracefully
if (dcPrinter.StartDoc(&docinfo) < 0)
{
AfxMessageBox("Printer wouldn't initalize");
}
else
{
//start a page
if (dcPrinter.StartPage() < 0)
{
AfxMessageBox("Could not start page");
dcPrinter.AbortDoc();
}
else
{
// Print everything on the screen
CGdiObject* pOldFont = dcPrinter.SelectStockObject(SYSTEM_FONT);
/*
** print caption
*/
//set the font first - Courier New
CFont* m_pFntCaption = new CFont;
ASSERT(m_pFntCaption);
m_pFntCaption->CreateFont(...);
CFont* pFont = dcPrinter.SelectObject(m_pFntCaption);
ASSERT(pFont);
// Print some text...just liked OnDraw
dcPrinter.TextOut(0, 0, CaptionString);
//finished <=======================did you do this part?
dcPrinter.EndPage();
dcPrinter.EndDoc();
dcPrinter.SelectObject(pOldFont);
delete m_pFntCaption; //delete the font
I think you might miss out the StartPage and EndPage...etc....It is exactly what i did in printing...everything in a procedure only...that's it...
|
|
|
|
|
Sorry, may be i made it unclear - i'm not trying to print. I'm trying to
monitor the printer.
|
|
|
|
|
Hi,
Does anyone know how to do the following things when launching the MFC program?
First, start with a Dialog with no title bar, no menu, no button....nothing.....just a picture on it.
Second, hold this dialog for awhile.....let say 5 seconds.
Third, close automatically.
Finally, start the MFC program.
I know how to pop the dialog (DoModal()) and how to wait for 5 seconds...but i don't know how to close the dialog, and how to do it before the program start.
It just likes Internet Explorer...when we launch IE, then it pop a little box...."Internet Explorer 5.0...." then start IE...right?
Thanks.
|
|
|
|
|
EndDialog(IDOK)www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
EndDialog(IDOK)www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
Still don't know how to do...because when i use DoModal() to pop up the dialog, it waits for the user to click "OK or...." but now i won't use button in here and want to use code to make it close.......now my code is:
CxxxDlg xxdlg;
xxdlg.DoModal();
xxxx //make 10 seconds wait...
xxdlg.EndDialog(IDOK);
seems doesn't work....how to fix it?
|
|
|
|
|
Just put up a timer
SetTimer(1, 7000, NULL);
and when WM_TIMER (after 7sec) is called by the framework, just set your
void MyDialog::OnTimer(UINT nIDEvent)<br> {<br> if(nIDEvent == 1)<br> {<br> KillTimer(1);<br> MyDlg.EndDialog(IDOK);<br> }<br> }
I guess, that's what you wanted to know...
Manfred
---
Programming is knowing...
|
|
|
|
|
Do the following:
CYourApp::InitInstance()
{
.
.
.
// Call your first dialog
FirstDialog::DoModal();
// Call your main dialog
MainDialog::DoModal();
.
.
.
}
CFirstDialog::OnInitInstance()
{
// Do initialization stuff
// Set timer
SetTimer(1, 10000, NULL);
return TRUE;
}
CFirstDialog::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 1)
{
KillTimer(1);
EndDialog(IDOK);
}
}
This should display your splash screen for ten seconds before it loads the main dialog.
|
|
|
|
|
as alex said ... what you are describing is a splash screen
pj has a good implementation on this site somewhere
go check it out
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
How do I pass a string array to a dll to be used and modified
then be able to use that modified array from the calling program
I've try to the pass a variant array to the dll, the export function is a so;
long _stdcall GetList(LPSTR pszName, VARIANT FAR* vNumbers)
vNumbers is passed in by a VB app as first declared as a variant then as a string
I can read the array that I passed in, modify it and read the modification that were made.
after the function is done and I'm back in the calling program (mine is VB)
the function I passed in emtpy, (VB say that the array is out of memory)
(although if I put the array in a messagebox it can be read...I don't know why)
Now, I know that VB handles BSTR differently If a DLL procedure expects an LPSTR (a pointer to a null-terminated string) as an argument, pass the BSTR by value. Because a pointer to a BSTR is a pointer to the first data byte of a null-terminated string, it looks like an LPSTR to the DLL procedure.
Is there another way to pass a array of string to a dll ?
thanks
|
|
|
|
|
Hi,
I've got a problem here (but then again, don't we all?). The situation is as such:
We have developped a very large application which can create very large vector based images. In building it, we never thought about printing over multiple pages, because our customers have extremely large printers and plotters, so that paper size would not be a problem...
Now we want to exploit the program to home users who do not have plotters at home and do want to print the images in true scale. This CAN be done by printing over multiple pages, but then again, the program wasn't build to do this and re-aranging the comlete code will take weeks and could even take months...
So my question actually is:
'Is there a possibility to print over multiple pages, without having to alter the drawing code itsself. Are there, for example, possibilities to let the Device Context class devide the image in A4-parts??'
I hope someone can help me at least a bit. Right now every input is welcome!
|
|
|
|
|
I've been working on adding a system tray icon into my program. The icon is created fine, the icon's popup menu works as well, but I can't figure out one thing. When the program is minimized, I want it to disappear off the Windows taskbar, so you can only restore it via the tray icon (the way a program like ICQ works). I can't seem to figure out how to make the program remove itself from the taskbar, though...could anyone point me to some information on that? Thanks a lot.
|
|
|
|
|
Hi,
I asked for a solution to open Access2000 mdb file from VC6 since VC 6 was not able to open the latest version of Access db. Peter Zajac gave me the solution, to include this line of code:
AfxGetModuleState()->m_dwVersion = 0x0601;
It works. But to find more info, I tried MSDN. But, to my surprise, there isnt any documentation available for this API.
In addition, MSDN mentions AFX_MODULE_STATE but there is no detail about this structure either. How can I find the information about these?
Also m_dwVersion is the version of what?
Ammar
|
|
|
|
|
Continuing on with my insignificant do nothing dialog application that implements many controls just for the sake of seeing how they work.
I have added a Progress Control that starts filling when the Start button is clicked, at the same time the button label changes to Stop. As you may have guessed I want the Progress Control to go up and down until such times as the Stop button is clicked. Can't figure out how to do this, initial thought is to use a thread to run the Progress Control and stop the thread when the Stop button is clicked. After reading Using User-Interface Threads by Joseph M Newcomer I am none the wiser, if the answer is in any of my Win32 and MFC programing books I can't find it.
Anyone have an answer for me.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
G'day Michael,
You could create a timer for the dialog window when the 'Start' button is clicked, then add a WM_TIMER handler to update the progress control on WM_TIMER events, and then kill the timer then the 'Stop' button is clicked.
Check out the CWnd::SetTimer() and CWnd::KillTimer() functions in the docs.
HTH,
Steve
|
|
|
|
|
Hi,
In Visual C++, if you create a file using CFile, is there any way to tell whether this file is a file or a folder? In Java, you can use "isDirectory()" to do this. Is there a
similar way in Visual C++? Thanks. Or is there any other way to create a file? Any suggestion or comment is appreciated.
Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? Thanks.
|
|
|
|
|
Try CFileFind::IsDirectory
By the way, Doesn't CFile always create a file?
I have never tried creating a folder. Can CFile do that?
Ammar
|
|
|
|
|
Sorry if I asked not good question. I am relatively new to Visual C++.
I tried the CfileFind class. It seems that this the right one. But I still have some problems. The following is the code I tried. It works ok to find the specific file or directory. But when I tried to test whether this is a directory or not, it gives an "assertion failure". I have no idea how it happenes. Can you tell me what went wrong? Also, if possible, can you give me a little example (several lines) of how this may work? Thanks a lot.
CFileFind finder;
BOOL bWorking = finder.FindFile(filename);
if(bWorking) {
if(finder.IsDirectory()) {
...............
|
|
|
|
|
Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up?
CFileDialog is not meant to do this. The folder-selection dialog is done with the SHBrowseForFolder() API.
--Mike--
http://home.inreach.com/mdunn/
All your base are belong to ME~!
|
|
|
|
|
Hi,
First let me thank codeproject.com for these excellent forums.
I have an MFC-based control which uses PreCreateWindow to specify the class for the new controls window. Job is accomplished in 2 lines of code. I'm hoping that it is that easy in ATL. I've been learning as I go and perhaps (hopefully) it is easy. Any pointers or code samples would be appreciated.
|
|
|
|
|
In your CWindowImpl-derived class, use the DECLARE_WND_CLASS macro to set the window class name. Eg:
class CMyControl : public CWindowImpl<CMyControl>
{
...
DECLARE_WND_CLASS("MyATLControl")
};
--Mike--
http://home.inreach.com/mdunn/
All your base are belong to ME~!
|
|
|
|
|
I don't think this is correct. DECLARE_WND_CLASS gives the name of the new class. I want something more like DECLARE_WND_SUPERCLASS(), which seems to provide a mechanism for having both my class and the base class get messages. But I haven't found a real (meaning complete) example of using this. My ATL Wizard generated code has nothing like "class CMyControl : public CWindowImpl<cmycontrol> " in it.
|
|
|
|
|
I think I'm following this thread correctly. Have you tried using my CWindowImpl ATL Object Wizard? By setting a few items on the custom property page for the wizard you can get the desired effect I think you are looking for.
http://www.codeproject.com/atl/RBCWindowImpl.asp
Cheers,
-Erik
|
|
|
|
|
Hi Erik,
I saw your wizard while perusing codeproject.com . It looks applicable but I haven't had an opportunity to try it out yet. Thanks.
|
|
|
|
|
Hello. I have a derived CEdit control on my app which captures the Enter key. I can't figure out how to prevent that beeping noise whenever I press Enter. It's not in a dialog box btw. If anyone can give me any suggestions I'd appreciate it, thanks
Anthony
|
|
|
|