Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Notepad parameters?

Posted on 1998-12-17
10
Medium Priority
?
2,659 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

610 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