|
A text report I print from my MFC program is different in Print Preview versus hard copy.
In fact zooming in and out in Print Preview changes what's displayed.
Example: one column in my report might be:
My dog has fleas.
But in Print Preview, this might show as:
My dog has fl
Given Microsoft Word also shows these sorts of anomalies in Print Preview, I've always assumed it's a difference between rendering on the screen versus rendering on the printer.
So, a sanity check please: should I worry about a bug in my program or not?
(PS I've spent an hour checking the web for something that says "print preview is only an approximation and may never be an accurate representation of the printed output" - but haven't found any such statement.)
Russell Robinson (russellr@rootsoftware.com)
Author of TTMaker (Advanced Timetabling Software)
http://www.rootsoftware.com
|
|
|
|
|
print preview is only an approximation and may never be an accurate representation of the printed output.
print preview does a whole lot of scaling to do what it does. sometimes it totally messes up font sizes (which may be why your text is being chopped - font didn't scale along with a clip box around it). the real test is the printer. if it works on the printer, i usually ignore whatever PP is doing.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
if you have Acrobat Distiller or PDFWriter, print to that and see if the PDF that comes up has the same problem... if it does, go into Acrobat and explore through all the objects (text boxes, white filled rectangle boxes) that are there, see if something is getting printed over the text or if the textbox for the text is too small to fit the entire text (maybe miscalculated the width of the text)
- Roman -
|
|
|
|
|
In my app, I have the ability to create a text box in the view. The text box dialog has an Edit box in it that allows for multiple lines to be entered and allows for carriage returns. When I get the text back from the edit box, though, the carriage returns are supplemented with two characters -- newline and carriage return. I want to display the text from this edit box in exactly the same way as it is entered but when the text box shows up in the view, it has two strange box looking characters in it where the newline and carriage return should be and everything is on one with no line breaks. Any thoughts on how I can get this to change so that I can have the text box show up properly in the view.
|
|
|
|
|
how are you drawing the text in the view?
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Here is the code that displays the text in the view:
pDC->SetTextColor(Color);
pOldFont = pDC->SelectObject(&m_TextFont);
pDC->TextOut(m_StartPoint.x, m_StartPoint.y, m_String);
pDC->SelectObject(pOldFont);
If this gives you any idea of what I'm doing wrong...
|
|
|
|
|
try using pDC->DrawText
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
make sure the destination text box (the one in your view, right?) also has the ES_MULTILINE window style (its also multi-line)
- Roman -
|
|
|
|
|
Stew wrote:
two strange box looking characters
These are actually a '\n' followed by a '\r'. If you switch it, i.e. make the '\r' followed by a '\n', it will be correctly displayed.
Check this link.
Anyway, could you post the code you use ? Because if you retrieve your text in a CString and redisplay it, it should not be any display problem.
~RaGE();
|
|
|
|
|
here is the code if it helps:
pDC->SetTextColor(Color);
pOldFont = pDC->SelectObject(&m_TextFont);
pDC->TextOut(m_StartPoint.x, m_StartPoint.y, m_String);
pDC->SelectObject(pOldFont);
|
|
|
|
|
My question is, does anyone have an example of code that would mimic the group selection functionality of the Power Point type applications using DrawDragRect or some other function?
I'm trying to use the DrawDragRect() function in my app for group selection purposes much like in Power Point, etc... I want to be able to traw the rectangle and stretch it to enclose certain objects in my view. I'm using the function and I'm using the Halftone brush. I understand how that works with the background and foreground colors and all. My question, though, is in regards to the brush used when drawing the rectangle. When I start to draw the rectangle, the view is shown completely in the halftone brush format (Dithered) and the inside of the rectangle is drawn transparent only when it is dragged from the bottom right of the screen to the top left of the screen.
|
|
|
|
|
I already know how to do windows programing using only the win 32 api. Now I am learing Visual C++ .NET. How easy is it to mix the two?
For instance could I create a dialog box class with VC++ and then use it in a win 32 api program?
Are there any potential problem of which I should be aware?
Would it be better to create the dialog box as a dll?
|
|
|
|
|
|
Actually I am more interested in calling MFC from a win 32 api application.
For example if I wrote a game, I would want to use win 32 api for everything except the dialog boxes which would be done with MFC.
Can I just add the files that define dialog boxes to my win 32 project and then use them the same as I would from MFC?
Or would I have to create a MFC project and then use the win 32 api calls to create the main window?
Would creating the MFC Dialog as a DLL help?
|
|
|
|
|
You're confusing several things. Visual C++ is not a language, it's the development environment. When you make a dialog with the VC resource editor, it doesn't restrict you to any particular flavor of C++, whether it's straight APIs, MC++, etc.
.NET and MFC are class libraries. .NET (from my second-hand knowledge of it) is pretty much a complete abstraction layer away from the Win32 API, whereas with MFC you can (and will!) use a lot of your API knowledge.
As for mixing, you can freely mix straight APIs, ATL, WTL, and (with the right compiler settings) MFC. You can also mix managed and normal code with VC.NET, although you can use .NET only in managed code.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I understand that Visual C++ is a collection of classes (MFC) and Wizzard that automate the construction of those classes. And I know that you can use the win 32 api functions from MFC.
What I didn't know till now is whether I can take a win 32 api project and then inport MFC classes as needed.
For example if I write a game I would want it to be a win 32 api application because MFC is too inefficient and inflexible for serious game programing. (Plus I hear it doesn't play nice with Direct X and possible Open GL). But I would like to use MFC for setting and what not.
What compiler setting would I need to add an MFC dialog box to a win 32 api application?
|
|
|
|
|
Hi all,
I'm looking for a training project that can help me to learn C++ more easily and also efficiently.
Please let me know if you have any good training project in mind or any website that I can find C++ training project. Thanks in advance.
|
|
|
|
|
beginner-beginner level: simple console application to print out say, the fibonacci sequence
intermediate-beginner level: a console app to apply simple encryption to a raw data stream from a binary file ("somefile.dat") and output it to ("outfile.dat") then revert it back
expert-beginner level: a console app to parse a mathematical function expression string (e.g. "sqrt(9) + 5 ^ x * 2.1 + 1") and print out the result
just some suggestions
- Roman -
|
|
|
|
|
Hi all,
I'm looking for a training project that can help me to learn C++ more easily and also efficiently.
|
|
|
|
|
Personally I like the Teach Yourself ... in 21 Day Books when learning a new language or skill, hopefully one available at the local libray. After each lesson it suggests execises that you can do on your own.
(Then I usually purchase a reference manual and read that cover to cover.)
If you looking for something a larger more complex then you really should dream something up yourself.
I usually keep a notebook where I write down ideas for projects as they occur to me. Usually the projects fall into these categories.
1) Projects that Apply recently learned knowledge, but are otherwise useless. I recently wrote a win 32 api application that uses a dilog box to get parameters and then draws various 2d Primatives. Why, because I just finished Reading "Windows 98 Programming From the Ground Up" and am studying graphic algorithms form "Computer Graphics Principles And Practice". I try to do at least one project for each book I read.
2) Small Utilities and Tool for personal use. I am brushing up on my typing and the program I am using allows me to import my own text, but always starts at the beginning. So I am writing a program that breaks a text file into numbered files of the desired length to use when I practice typing. Any busy work you find yourself doing repeatedy on your computer is a good.
3) Improvements on existing programs. Sometimes a program I am using just doesn't work the way I want it to. For instance I recently downloaded a bunch of vocalubary tutouring programs and all of them had serious flaws. So now one of my potential projects is to write a my own vocabulary program.
4) Games. Games always make fun projects. VC++ is not the ideal environment for hard core game programming, but there is no reason why you could not make a decent 2d game. Plus games are about the only projects that will impress your non-programmer friends. Same goes with screen savers.
Pick something that interest you that is within or slightly beyond your capabilities.
Everyone should read Code Complete by Steve McConnell. Reading this book has easily doubled the quality of my code.
|
|
|
|
|
Hi, all
In Atl project ,how can I return the user define type?
For example , I have define a Struct ,and I want to return the Struct type in a function, and I plan to utilize the return Struct type in VB through the com. What should I do ? I have try some ways ,but failed.
Another similar problem. I have two ATL Object in my Atl
project , Teacher and Student . And student is a private property of Teacher ,now I want to construct a function in Teacher to return the Student property .How should I do ?
Sincerely ask for help. Who can tell me how to do , or give me some similar source code which resovle the above problems .
I'll appreciate it .
Regards.
|
|
|
|
|
In the IDL file do the following:
typedef struct
{
int x;
int y;
} POINT;
interface IMyInterface : IUnknown
{
[propget, helpstring("property Point")] HRESULT Point([out, retval] POINT *pVal);
Note that the iterface inherits from IUnknown (Custom interface) and not from IDispatch (Dual interface).
Goodluck,
Dudi
|
|
|
|
|
And how can I construct the CStudent object in CTeacher.
Details as follows.
In the construction function of the CTeacher :
CTeacher()
{
IStudent * m_student =new CStudent();
return;
}
There are some compiler errors. It says that the CStudent cannot instantiate abstract class due to following members:QueryInterface,AddRef,Release.
How should I do to resolve the problem.
thx.
Regards.
|
|
|
|
|
You cannot create a com object by using new.
Use CComObject instead:
CComObject<CStudent> *m_student;
HRESULT hr = CComObject<CStudent>::CreateInstance(&m_student);
|
|
|
|
|
Hi, all
Some problems about ATL Com:
1.I have create two ATL Object: CStudent and CTeacher .
The simple source code listed as follow: (some code auto generated by ATL have been skiped)
class CStudent
{
private:
long m_age;
public:
CStudent():m_age(10)
{
}
//...other code auto generated by ATL
};
class CTeacher
{
private:
IStudent* m_aStudent;
public:
CTeacher()
{
//create an instance of the com
CoCreateInstance(CLSID_Student,NULL,CLSCTX_ALL,IID_IStudent, (void**)&m_aStudent);
}
//...other code auto generated by ATL
}
2.Then I add a "IStudent * OneStudent" property for ITeacher ,to access the m_aStudent.
The implemention of the property are listed as below:
STDMETHODIMP CTeacher::get_OneStudent(IStudent *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = * m_aStudent;
return S_OK;
}
STDMETHODIMP CTeacher::put_OneStudent(IStudent *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*m_aStudent = *newVal ;
return S_OK;
}
3.Now I type some VB code to test the com ,but some compiler errors occurrs.
VB Code:
Dim s As Student
Dim t As New Teacher
s = t.OneStudent
the last sentence "s = t.OneStudent" have compiler errors.
Errors:function or interface marked as restricted ,or the function use an Automation type not supported in Visual Basic
I guess the errors caused by the type dismatch between IStudnet and CStudent.But I did not know how to resolve it .
So who can tell me how to return the m_aStudent that can be supproted in vb??
thx.
Regards.
|
|
|
|