Solved

Printing of forms in Visual C++ .NET

Posted on 2004-08-11
6
286 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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