Solved

Notepad parameters?

Posted on 1998-12-17
10
2,603 Views
Last Modified: 2012-08-14
I need to be able to give notepad a header and footer for printing purposes.  I need to do this with code.  Any ideas?

Thanks in advance.
0
Comment
Question by:MikeABB
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1450943
I think that this is not possible, since Notepad is not an Automation Server. But maybe some expert knows a smart trick.
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1450944
Have you considered creating your own notepad application?  This would allow you complete control over the output.
0
 

Author Comment

by:MikeABB
ID: 1450945
It is not worth it to create my own notepad application.  I am displaying a report that is created with VC++, and I need to add a footer to the report for informational purposes.  We are in the middle of our beta release, and there is just no time for creating a notepad app when one already exists on NT.
0
 
LVL 2

Expert Comment

by:polygon
ID: 1450946
you may try the tricky SendKeys command. You start Notepad, and then use sendkey to open a file, then move to the end, add the footer and so on.

But if want to program and not play with VB, I wouldn't suggest using Sendkeys, it will cause I lot of troubles I think.
0
 

Expert Comment

by:cywh
ID: 1450947
Notepad is does not have the possibility to handle footers/headers in the way you want. Either you use som other "ready to use object" or write your own code to format the output text.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:Mirkwood
ID: 1450948
Please reject cywh answer, since he is not adding anything new...
0
 

Author Comment

by:MikeABB
ID: 1450949
Notepad does support headers and footers.  If you don't beleive me, click File..Print.  A dialog will come up with boxes for headers and footers.
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1450950
What you can do is use the Windows API to do this.

  HWND notepadHwnd = FindWindow(NULL, "Notepad");
  if (IsWindow(notepadHwnd))
  {
    // bring up the page setup dialog
    SendMessage(notepadHwnd, WM_COMMAND, 0x32, 0);

    HWND setupHwnd = FindWindow(NULL, "Page Setup");
    if (IsWindow(setupHwnd))
    {
      HWND headerHwnd = GetDlgItem(setupHwnd, 0x1E);
      HWND footerHwnd = GetDlgItem(setupHwnd, 0x1F);

      SetWindowText(headerHwnd, "New Header");
      SetWindowText(footerHwnd, "New Footer");
    }
  }
 
You'll need to translate this into VB or you can make a DLL in C++ and have your VB code call into it.
0
 

Author Comment

by:MikeABB
ID: 1450951
thui,
i am finding the handle to the notepad window, but it seems that vb cannot find the "Page Setup" window?  any ideas?
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1450952
Do you see the page setup window on the screen? If not, make sure you have sent the WM_COMMAND first. Another thing to check is to make sure you have typed the caption correctly in the FindWindow statement.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

19 Experts available now in Live!

Get 1:1 Help Now