Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 7th, 2006, 1:44 PM   #1
boraciner
Programmer
 
boraciner's Avatar
 
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4 boraciner is on a distinguished road
I can't use my usb printer to print any data

Hi.. I have to learn how to print "hello world " to a paper.. but examples which I found works with dialog box .. I have to make a dos program.. please help me!
thanx.
boraciner is offline   Reply With Quote
Old May 8th, 2006, 8:59 AM   #2
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Not sure if there is an easier way, but you could write the text to a file and print the file.

 system("print path-to-printer path-to-file"); 
 
// example for a default network printer
 
system("print /d:\\\\server1\\printer1 C:\\helloworld.txt");

-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Old May 8th, 2006, 9:27 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
By 'dos', do you mean a console/command-line program?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 8th, 2006, 11:49 AM   #4
boraciner
Programmer
 
boraciner's Avatar
 
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4 boraciner is on a distinguished road
yes.. I tried to tell command-line program...

they don't work .

#include<iostream>
main()
{system("print path-to-printer path-to-file");

// example for a default network printer

system("print /d:\\\\server1\\printer1 C:\\helloworld.txt");

}


I'm using visual 2003

what can I do??
boraciner is offline   Reply With Quote
Old May 8th, 2006, 3:26 PM   #5
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
* Sigh *

Never copy/paste code. Understand its meaning, look at it again, digest it, and you will see what you're doing wrong.
Polyphemus_ is offline   Reply With Quote
Old May 8th, 2006, 4:39 PM   #6
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Also please post in code tags. Read the "How to post a question" thread at the top of the forum.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old May 8th, 2006, 6:29 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I am going to copy and paste pseudo-code, no matter what you say. When it doesn't woik, I'm going to sue your ass off. Rejoice. You will wind up with my money and I'll wind up buying scotch for my lawyers, to no avail.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 9th, 2006, 11:16 AM   #8
boraciner
Programmer
 
boraciner's Avatar
 
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4 boraciner is on a distinguished road
I could do this..

#include <windows.h>

HDC hDC;
SIZE Size;
int y;

void YaziciAc()
{
  PRINTDLG pd;
  DOCINFO di;
  memset(&pd, 0, sizeof(pd));
  pd.lStructSize = sizeof(pd);
  pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
  memset( &di, 0, sizeof(di));
    di.cbSize = sizeof(di);
    di.lpszDocName = "My Document";
  PrintDlg(&pd);
  hDC = pd.hDC;
    StartDoc(pd.hDC, &di);
  GetTextExtentPoint32(pd.hDC, "A", 1, &Size);
  y = 0;
}

void Yazdir(LPCTSTR yazi)
{
  if (y==0)
  {
    EndPage(hDC);
    StartPage(hDC);
  }

  TextOut(hDC,0, y, yazi, strlen(yazi));
  y += Size.cy;
}

void YaziciKapat()
{
  EndPage(hDC);
  EndDoc(hDC);
  DeleteDC(hDC);
}

int main(int argc, char* argv[])
{
  YaziciAc();

  Yazdir("SATIR 1");
  Yazdir("SATIR 2");

    /* Yeni sayfa */
  y = 0;
  Yazdir("SATIR 3");
  Yazdir("SATIR 4");

  YaziciKapat();

  return 0;
}
boraciner is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC