Thread: Find and Print dialogs

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    Find and Print dialogs

    How do I use the Find and Print common dialogs in my program? and for these do would I have to write my only function that they call?

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    PrintDlg
    GetOpenFileName
    GetSaveFileName

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Do you know where I can find examples using them?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by lambs4
    Do you know where I can find examples using them?


    You could always STFW

    Try MSDN.....that carries full info on these APIs as well as examples

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Thanks to the code that you had posted in the past I have been able to print. In that code you used TextOut, instead I chose to use DrawText, but only 4 and half line of text will print. Do you know why?

    Code:
    void doPrint(HWND hwnd)
    {
    	PRINTDLG pd;
    
    	DOCINFO di = {
    	sizeof(DOCINFO),
    	"Fordy's Doc",
    	NULL
    	};//This gives details on doc...like its name when spooled
    
    	ZeroMemory(&pd,sizeof(PRINTDLG));//saves initiliasing to zero
    
    	pd.lStructSize = sizeof(PRINTDLG);
    	pd.hwndOwner = hwnd;
    	pd.Flags = PD_RETURNDC;//This gives DC to printer selected
    	pd.nCopies = 1;
    	if (PrintDlg(&pd)==TRUE) 
    	{
    		HWND hEdit = GetDlgItem(hwnd, IDC_MAIN_EDIT);
    		char buffer[80] = "";
    		RECT rcClient;
    		GetClientRect(hEdit, &rcClient);	
    		GetWindowText(hEdit, buffer, 80);
       	 // GDI calls to render output. 
    		if(StartDoc(pd.hDC,&di)>0 && StartPage(pd.hDC)>0){//new doc...new page
    		DrawText(pd.hDC,buffer, strlen(buffer), &rcClient, DT_WORDBREAK);
    		EndPage(pd.hDC);//end of page
    		EndDoc(pd.hDC); //end of doc
    		}
    	    // Delete DC when done.
    	    DeleteDC(pd.hDC);
    	}
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. it won't print the 0 if i enter 102
    By maybabier in forum C Programming
    Replies: 1
    Last Post: 04-17-2009, 02:13 AM
  2. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  3. tables...
    By peanut in forum C Programming
    Replies: 21
    Last Post: 10-17-2006, 03:06 PM
  4. Inheritance using Stack Class Problem
    By dld333 in forum C++ Programming
    Replies: 17
    Last Post: 12-06-2005, 11:14 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM