Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing of forms in Visual C++ .NET

Posted on 2004-08-11
6
Medium Priority
?
318 Views
Last Modified: 2010-04-24
How can forms be printed in Visual C++ .NET (managed)? Thanks in advance.

P.S. Some time ago I asked a similar question regarding VB.NET and got two excellent solutions:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21074886.html
0
Comment
Question by:judico
  • 3
  • 2
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 11773580
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 11773637
I beleive this translation is staightforward, the only problem may be PInvoke call. See this example of PInvoke call from managed C++:

http://www.codeproject.com/managedcpp/pinvoke.asp
0
 

Author Comment

by:judico
ID: 11776554
I don’t know how to translate the code for printing a form from VB.NET into Visual C++ .NET. In VB.NET part of the code resides in Module1 while another part in, say, Form1. What is the analog of Module1 in Visual C++ .NET? Can someone help me in this translation?


P.S. I am taking the chance to ask another question which appears related to the main question here. I remember reading somewhere in this site an explanation how to hide the buttons from being printed when printing a form. It had something to do with changing properties of the button, if I remember correctly. I can’t find where I read that and would appreciate it if someone could tell me exactly what property of the button is to be changed to render it invisible when printing the form. Thanks in advance.
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 

Author Comment

by:judico
ID: 11777998
Sorry, I got mixed up. For some reason I thought you meant VB.NET. Nevertheless, I'm still having problems translating the C# code in to managed C++ and would appreciate it if someone could help me in that.

As for the question in the P.S. part of my previous posting, I guess, I should post it as a separate question. I just saw that the policies of this site discourage asking a question within question. Sorry about that.

judico
0
 
LVL 3

Accepted Solution

by:
Statick001 earned 2000 total points
ID: 11841149
most C# can easily be converted to C++

the first main diference is the use of the . symbol between namespace/class names, instead of :: for static references and -> for isntance references

so whenever you see something like system.windows.forms.messagebox.show() that needs to be recoded as system::windows::forms::messagebox::show() as its static

and when you see this.Button1.Text that needs to become this->Button1->Text as its referring to an instance of a class

c# doesnt differentiate between the two (well, it does, but they are accessed in exactly the same way), and this is the first major difference between c# and c++

next is of course, the lack of any pointer references.

in c++ you would define an instance of a class like this

SomeClass * thing = new SomeClass;

because 'thing' is a pointer to SomeClass, we use the pointer-to symbol *
this is removed in c#, the above code would simply read 'SomeClass thing = new SomeClass'

so whenever you see a 'new' statement in c#, most cases it will require a pointer * in the code before it will compile in c++. i say most cases, because there are some cases where the pointer is not required (for structures rather than classes)

by simply making the 2 changes i have described, most c# code can be converted directly to c++. of course there is always one or two lines of code that require something else - but 99% of the work is done like above
0
 

Author Comment

by:judico
ID: 11844442
Thank you for your excellent explanation. I have posted a separate question to that effect and I already have it wotking:

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21094351.html

I take the opportunity to thank again also drichards who has provided oustanding help on several occasions. All the best.

judico
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question