|
Thanks for repsonding.
I did call it right after it had returned:
memset( &pd, 0, sizeof(PRINTDLG) );
// other init stuff
//then
if( !PrintDlg(&pd)) return 1;
// then I had here that code here...
// landscape mode .. etc
Joe,
|
|
|
|
|
The next thing is does the printer support landscape printing, and if it does, is the DM_ORIENTATION bit flag of the dmFields member set?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I did check this: pDevMode->dmOrientation, and its value is =2 which is the value of DMORIENT_LANDSCAPE.
I know that pd.hDevMode is local but this is why I had this line:
pd.hDevMode = pDevMode;
Joe,
|
|
|
|
|
Anonymous wrote:
pd.hDevMode = pDevMode;
I think that is your problem, remove that line. You are assigning a pointer to a handle and that does not work.
If removing that line does not help, then post the entire code for the function. The initialization of the PRINTDLG structure, the call to PrintDlg, your changing the orientation, and how you access the PRINTDLG structure when you do the actual printing. Somewhere in there you are making a mistake, and I can not figure it out with the limited information you have given so far.
ps. I have to go, so it will be several hours before I will get back to this. Others feel free to help;)
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Here is the code:
static LPDEVMODE pDevMode;
static PRINTDLG pd; // for PrintDlg()
static DOCINFO di;
// Set Up PRINTDLG Structure For PrintDlg()
memset( &pd, 0, sizeof(PRINTDLG) ); // Clear It
pd.lStructSize = sizeof(PRINTDLG); // Size
pd.hwndOwner = this->GetSafeHwnd();
pd.nFromPage = 1;
pd.nToPage = 1000;
pd.nMinPage = 1;
pd.nMaxPage = 1000;
pd.Flags = PD_RETURNDC | PD_PAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
if( !PrintDlg(&pd)) return 1;
// landscape mode
pDevMode=NULL;
pDevMode = (LPDEVMODE)::GlobalLock(pd.hDevMode);
// set orientation to landscape
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
//pd.hDevMode = pDevMode;//Not needed
// Here is code for stuff to print...
// At end is the clean-up
::GlobalUnlock(pd.hDevMode);
Maybe the problem is that pDevMode is local variable, maybe I need to change some global variable, I just do not know what or how.
By the way I commented that line and it had no effect.
Thanks.
Joe,
|
|
|
|
|
Anonymous wrote:
// Here is code for stuff to print...
Ok, that's cool, but this doesn't help me any.
How are you applying your changes to the printer device context? You are using the PD_RETURNDC flag, so I am assuming that you are using the hDC member of the PRINTDLG structure as your printer DC. After you change the orientation, are you calling ::ResetDC(pd.hDC, pDevMode); ? If so, what is the return value, does ResetDC succeed?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Call pDC->ResetDC(pDevMode) after pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
Lisoft
|
|
|
|
|
I added: dc.ResetDC(pDevMode);
and it still prints portrait instead of landscape.
Joe,
|
|
|
|
|
The ResetDC() will not run properly on Windows 98 or lower version of windows
try Windows 2000 or later.
|
|
|
|
|
I have Window xp. VC++ 7.0.
Joe,
|
|
|
|
|
Tye to use the following code to set printer default:
PRINTDLG m_pd;
if (AfxGetApp()->GetPrinterDeviceDefaults(&m_pd))
{
LPDEVMODE pDevMode = (LPDEVMODE)::GlobalLock(m_pd.hDevMode);
pDevMode->dmOrientation=DMORIENT_LANDSCAPE;
::GlobalUnlock(hDevMode);
}
Lisoft
|
|
|
|
|
I tried this code, but it still prints portrait. I then added: dc.ResetDC(pDevMode);
just after: pDevMode->dmOrientation=DMORIENT_LANDSCAPE;
and it still not printing landscape.
Are there some library files that I have to include?
Never got any warning during compilation.
Joe,
|
|
|
|
|
When I compile any of mine projects with MS Visual C++ 6.0 there is alot of trash inside .exe file. Its looking like debug information although I'm building a release version (there are lots paths and filenames inside executable clearly viewable). How to remove it all, to reduce .exe size ? Why is it there ?
|
|
|
|
|
Exactly how are you viewing the .exe? with a hex viewer? I know that you can still usually find strings in most .exe's using the Win32 disassembler, (I think that's how some people find a message like "you have entered an invalid code" and use a hex viewer to change the 'jmp' statement to a 'nop'... or so I hear ).
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Yup I view it with hexviewer, but i bet it is visible with notepad too
Yea you can crack programs by hexviewers, but disassemblers / hexview+dissaembler (like HIEW or DN) are better, trust me.
But anyhow, question is how to compile without the trash ? Now anyone can see my developement directories, and it grows my .exe too much. Is there some compiler switch or something ?
|
|
|
|
|
Yes, you need to disable the inclusion of the information for the PDB files.
Go to the Project menu and select settings.
A tabbed dialog called 'Project Settings' appears.
Make sure, on the left, the 'settings for' is set to something like "Win32 Release".
Go to tab marked 'Link'.
In 'Category' drop list box select 'Debug'.
Under 'Debug Info' group, make sure the 'Debug Info' check box is NOT checked.
Go to the 'C/C++' tab.
In 'Category' drop list box select 'Preprocessor'.
In the edit field 'Preprocessor definitions' make sure you see NDEBUG. If it is missing, then add it to end of list of other options. If you see DEBUG or _DEBUG in the list of items, then remove it.
That should help.
|
|
|
|
|
Thank you, but actually it didnt, because all those things were like that from the start, those are default Release settings.
|
|
|
|
|
I forgot to mention one more that might be different.
On the Project Settings : C/C++ with the drop down list box set to "General"
There is a 'debug info' drop down list box and that should be set to 'None'.
Since you said that it seems all the file paths are in your EXE, maybe this is set to 'Program Database' for your project.
I can't really think of another reason all the source paths are in your EXE unless someone has put something like
static char s_FilePath[] = __FILE__;
in all of your source files, which would automatically cause them all to be included.
|
|
|
|
|
Yup 'debug info' was set to 'none'
Of course im not using "static char s_FilePath[] = __FILE__;" that would be pretty dumb why would I need absolute path to my project in the proggy generally absolute paths are bad thing.
Uh oh then ...
|
|
|
|
|
Take most C++ files generated by MFC AppWizards and you will find code similar to this at top of every source file...
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
So.... Why would you want to do that?
These are the only reasons I could locate...
#define TRACE ::AfxTrace
#define THIS_FILE __FILE__
#define ASSERT(f) \
do \
{ \
if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
AfxDebugBreak(); \
} while (0) \
#define VERIFY(f) ASSERT(f)
#define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
#define DEBUG_ONLY(f) (f)
// Memory tracking allocation
void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
#define DEBUG_NEW new(THIS_FILE, __LINE__)
#if _MSC_VER >= 1200
void AFX_CDECL operator delete(void* p, LPCSTR lpszFileName, int nLine);
#endif
#ifdef _DEBUG
#define DAO_CHECK(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) AfxDaoTrace(f, #f, THIS_FILE, __LINE__)
#else
#define DAO_CHECK(f) AfxDaoCheck(f, NULL, NULL, 0)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, NULL, NULL, 0, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) f
#endif
Anyways, I mentioned it in case you had included a macro in some header file that had something similar to a statement such as that, so your full file path was ending up as a static variable in every source file.
|
|
|
|
|
Thank you ...
Im not using Dao so I hope that last part of code does not apply to me. And I though that all asserts are turned off in Release version (through #ifdef _DEBUG) ... sigh, so looks like its hopeless
|
|
|
|
|
Hi I have a database..application..
I used CDatabase and CRecordSet to minipulate database.
the db has memo fields and i have no problem inserting the data using sql statement into db.. but when I try to get back.. by using while loop and recordset.movenext()to
get the data back.. I got the error message which is
"Data truncate".
example
<br />
while(!records->IsEOF())<br />
{<br />
..<br />
..<br />
records->MoveNext(); <----- get error on reading the record that has long string data. but indeed it was only 356words in it.<br />
}<br />
}
If I delete that data or shorten the data length.. I got no error..
why am i having error when I get the data back from database and why there is no error when inserting the same data?
|
|
|
|
|
Goto your CRecordset::DoFieldExchange member function.
Enlarge the buffer for text field exchange like:
RFX_Text(pFX, _T("[REMARK]"), m_REMARK,1000);
adjust the numer "1000" to your max characters of the corresponding field.
I remember the default max length for text field is 255, you would get the truncate error message if data length exceed it.
|
|
|
|
|
Anyone, help pls !!! Can I use a .dll file if I don't have the .h file ?
I saw some discutions on this subject, where it says that it is possible to generate the .lib file from a given .dll. OK, but then how could I know what are the parameters of the functions exported by that .dll ?
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B131313[^]
I seem to remember steps for doing this being available at the SQLite web site also, may wanna check that place out in the FAQ or something...I just quickly looked and couldn't find it, but i'm sure something is there about how to do this...however i'm not sure about the header file...
HTH
I wonder if there are any animals that actually have to think in order to breathe? It would really suck to be them!!!
|
|
|
|