Solved

Fax printer DC

Posted on 2014-03-21
11
511 Views
Last Modified: 2014-03-31
Microsoft docs say I can obtain fax device context using FaxStartPrintJob(), then StartPage(), write data to the DC, EndPage() and EndDoc() to send the fax. This doesn't work at all. Each of these functions returns 'success'. Windows Fax and Scan will fax a TIFF file (MS docs say ANY file type, but not true). The fax printer shows no errors. I'm using Windows 7 and VS-2010. Has anyone ever made this work?
0
Comment
Question by:PacificaResearch
[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
  • 7
  • 4
11 Comments
 
LVL 12

Expert Comment

by:satsumo
ID: 39947634
Does FaxStartPrintJob return a DC in the FAX_CONTEXT_INFO structure?
0
 

Author Comment

by:PacificaResearch
ID: 39947781
Yes, FaxStartPrintJob returns a DC which I've used in StartPage, EndPage and EndDoc. These functions give no errors with that DC, but no results either.
0
 

Author Comment

by:PacificaResearch
ID: 39947784
Of course, I put test data, using TextOut(), between the StartPage and EndPage.
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 12

Expert Comment

by:satsumo
ID: 39947786
So when you say no results, how are you seeing the results? Do you get a blank fax document?
0
 

Author Comment

by:PacificaResearch
ID: 39947851
No blank fax document. If I open the Windows fax printer (devices and printers->see what's printing), I get a window with Inbox, Outbox, Sent Items, etc. In the Sent Items is a list of faxes I sent using the Windows Fax and Scan dialog box, which seems to work. But only with TIFF files.
I would expect to see my efforts with StartPage, EndPage, EndDoc appear in this Sent Items list. I would also expect my fax modem to light up and dial. Nothing happens.
0
 
LVL 12

Expert Comment

by:satsumo
ID: 39947887
Then my next line of thinking would be the FAX_PRINT_INFO structure. How are you initialising it?

I suspect TIFF's work because they already contain fax compressed data. Maybe you need to give it monochrome 1 bit files. Please try the two files I've attached. What other types have you tried?
bumpsf.bmp
jello.tif
0
 

Author Comment

by:PacificaResearch
ID: 39951250
I used windows Fax and Scan to fax the two files. The .bmp file gives this error:

"The file C:\temp\bumpsf.bmp cannot be attached to your fax"
"Message. Click on help to find out more about Attaching Files."

The .tif file appeared to fax (no errors, fax modem showed data going out), but after 8 minutes no fax was received at the other end. When I canceled, 1/2 page was received.

Here is a simple Win32 console app that should send a fax, but fails in the same way that my program fails. It's compiled in Visual Studio 2010 and executed on Windows 7.


#include "stdafx.h"
#include "winfax.h"


int _tmain(int argc, _TCHAR* argv[])
{
short s;
FAX_PRINT_INFO fpi;
FAX_CONTEXT_INFO fci;
DWORD jobID;
HDC faxDC;
char scr[1000];

      memset(&fpi,0,sizeof(fpi));
      fpi.SizeOfStruct = sizeof(FAX_PRINT_INFO);
      fpi.SenderName = "Pacifica Research";
      fpi.RecipientNumber = "17603448952";
      fpi.RecipientName = "Pacifica Research";
      fci.SizeOfStruct = sizeof(FAX_CONTEXT_INFO);
      s = FaxStartPrintJob(NULL,&fpi,&jobID,&fci);
      faxDC = fci.hDC;
      s=StartPage(faxDC);
      strcpy(scr,"You can print a report with parameters set to a range where the record should be included.");
      strcat(scr,"\rPrint the report to the screen, find the record in the report and click to drill-down");
      strcat(scr,"\rto the record. You can use the report writer to design reports with drill-downs just");
      strcat(scr,"\rso it's simple to list the records that you want to see.");
      s=TextOut(faxDC,20,20,scr,strlen(scr));
      s=EndPage(faxDC);
      s=EndDoc(faxDC);
      s=DeleteDC(faxDC);
      return 0;
}

Every function executes successfully, but the fax modem doesn't respond and no fax is sent. Nothing appears in Fax and Scan.
0
 
LVL 12

Expert Comment

by:satsumo
ID: 39951447
Looks OK to me, try specifying a DocName. I know that some of the Windows APIs are very picky about data in structures. They often refuse to do anything if you don't give them all the information. If you attach a phone to the fax line and dial the number exactly as shown, does it reach a fax machine? The code shown doesn't select a font into the DC before calling TextOut, so I guess it would use a default font and the default mapping mode.
0
 

Author Comment

by:PacificaResearch
ID: 39951650
The fax machine answers when I dial the exact number manually.

I added a DocName ("Fax Report"). It made no difference.
0
 

Accepted Solution

by:
PacificaResearch earned 0 total points
ID: 39956641
I installed a different brand of modem in a different machine with Windows 8. The FaxStartPrintJob function blows up with a GP fault deep in windows. I reformatted the machine and installed Windows 7. Now Fax & Scan and FaxStartPrintJob, StartPage, EndPage and EndDoc all work perfectly (on the new machine only). Original machine still doesn't work. I'll try a different brand of modem to see if it makes any difference.
0
 

Author Closing Comment

by:PacificaResearch
ID: 39966119
Wasn't really a solution. Some machines work, some don't. That appears to be a weakness/defect in Fax & Scan or related functions in Windows.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Make the most of your online learning experience.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

696 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