Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on TIP: Printing to other than default printer within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I was able to print my MapPoint control's map to any desired printer from VB6 with a common dialog control ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| TIP: Printing to other than default printer Use at your own risk, not the views of my company, blah, blah. Public Const WM_SETTINGCHANGE As Long = &H1A Public Const HWND_TOPMOST = -1 Public Declare Function GetProfileString Lib "kernel32" _ Alias "GetProfileStringA" _ (ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As String, _ ByVal nSize As Long) As Long Public Declare Function WriteProfileString Lib "kernel32" _ Alias "WriteProfileStringA" _ (ByVal lpszSection As String, _ ByVal lpszKeyName As String, _ ByVal lpszString As String) As Long Declare Function PostMessage Lib "user32" _ Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lparam As String) As Long '************************************* Private Sub PrintMapPointControl(asTitle As String, abIncludeLegend As Boolean, abIncludeOverview As Boolean, abFaxable As Boolean) Dim sDefaultPrinter As String Dim nSize As Long Dim lRet As Long 'save the original default printer nSize = 256 sDefaultPrinter = Space$(nSize) lRet = GetProfileString("windows", "device", "", sDefaultPrinter, nSize) sDefaultPrinter = Left$(sDefaultPrinter, lRet) '*** Use common dialog control to prompt user for desired printer CommonDialog1.PrinterDefault = True CommonDialog1.CancelError = True On Error GoTo PRINT_CANCEL CommonDialog1.ShowPrinter On Error GoTo 0 '*** tell the MapPoint control where to print to m_oMap.Application.ActivePrinter = Printer.DeviceName '*** print the current map On Error GoTo RESET_DEFAULT_PRINTER m_oMap.PrintOut , asTitle, CommonDialog1.Copies, geoPrintMap, geoPrintQualityPresentation, geoPrintAuto, False, abIncludeLegend, abIncludeOverview, abFaxable RESET_DEFAULT_PRINTER: '*** reset the original default printer WriteProfileString "windows", "device", sDefaultPrinter '*** flush any cached settings WriteProfileString vbNullString, vbNullString, vbNullString '*** tell other apps that default printer has changed lRet = PostMessage(HWND_TOPMOST, WM_SETTINGCHANGE, 0&, StrPtr("windows")) PRINT_CANCEL: '*** user pressed cancel on common dialog End Sub |
![]() |
| Tags |
| default, printer, printing, tip |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting MapPoint to recognize the new default printer | BobFromBoston | MapPoint 2006/2009 Discussion | 2 | 02-26-2006 05:30 AM |
| Trying to print detail maps on a strip printer | BobFromBoston | MapPoint 2006/2009 Discussion | 4 | 01-02-2006 03:52 AM |
| Default Value in Find | Anonymous | MapPoint 2006/2009 Discussion | 1 | 03-01-2004 12:25 PM |
| Printer Error with Trial Version | Anonymous | MapPoint 2006/2009 Discussion | 0 | 09-03-2003 09:24 PM |
| Change default country | Anonymous | MapPoint 2006/2009 Discussion | 1 | 12-30-2002 02:27 PM |