Solved

Notepad parameters?

Posted on 1998-12-17
10
2,614 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

831 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