Solved

Printing of forms in Visual C++ .NET

Posted on 2004-08-11
6
269 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 500 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now