Solved

Notepad parameters?

Posted on 1998-12-17
10
2,637 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
Technology Partners: 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!

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

Industry Leaders: 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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

689 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