Notepad parameters?

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.
MikeABBAsked:
Who is Participating?
 
Tommy HuiEngineerCommented:
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
 
MirkwoodCommented:
I think that this is not possible, since Notepad is not an Automation Server. But maybe some expert knows a smart trick.
0
 
jjmartinCommented:
Have you considered creating your own notepad application?  This would allow you complete control over the output.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
MikeABBAuthor Commented:
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
 
polygonCommented:
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
 
cywhCommented:
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
 
MirkwoodCommented:
Please reject cywh answer, since he is not adding anything new...
0
 
MikeABBAuthor Commented:
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
 
MikeABBAuthor Commented:
thui,
i am finding the handle to the notepad window, but it seems that vb cannot find the "Page Setup" window?  any ideas?
0
 
Tommy HuiEngineerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.