Results 1 to 8 of 8

Thread: TO: WebBrowser Gurus.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    Dear VB Gurus,

    I'm done with an App that uses WebBrowser which is working fine.
    The only problem is:

    How can I Dim Disable these 2 options in the Browser Print Dialog by code ?

    Print all linked documents
    Print table of links

    I've searched for help on that issue and the best article i found was:
    http://msdn.microsoft.com/workshop/browser/wb_print.asp
    which didn't help !!

    I would really appreciate any help.

    Thanx.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226

    Unhappy

    Is it that hard ?

  3. #3
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Hi Lyla,

    I'm not 100% that this is what you want but, i found this code sample on VB API under MENUS

    Before running this example, use the Menu Editor utility to create a small menu system on Form1. It doesn't matter what the menus look like, but some sort of menus are necessary.

    Code:
    ' Declarations and such needed for the example:
    ' (Copy them to the (declarations) section of a module.)
    Public Declare Function GetMenu Lib "user32.dll" (ByVal hWnd As Long) As Long
    Public Declare Function GetMenuItemCount Lib "user32.dll" (ByVal hMenu As Long) As Long
    Public Type MENUITEMINFO
    	cbSize As Long
    	fMask As Long
    	fType As Long
    	fState As Long
    	wID As Long
    	hSubMenu As Long
    	hbmpChecked As Long
    	hbmpUnchecked As Long
    	dwItemData As Long
    	dwTypeData As String
    	cch As Long
    End Type
    Public Const MIIM_STATE = &H1
    Public Const MIIM_SUBMENU = &H4
    Public Const MIIM_TYPE = &H10
    Public Const MFT_SEPARATOR = &H800
    Public Const MFS_CHECKED = &H8
    Public Declare Function GetMenuItemInfo Lib "user32.dll" Alias "GetMenuItemInfoA" (ByVal _
    	hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As _
    	MENUITEMINFO) As Long
    
    ' When button Command1 is pressed, output the structure of the entire menu system
    ' of Form1 to the Debug window.  The entire menu heirarchy is displayed, and any items
    ' that are checked are identified.  A recursive subroutine is used to output the contents
    ' of each individual menu, calling itself whenever a submenu is found.
    
    ' *** Place the following code inside a module. ***
    ' This function performs the recursive output of the menu structure.
    Public Sub IterateThroughItems(ByVal hMenu As Long, ByVal level As Long)
    	' hMenu is a handle to the menu to output
    	' level is the level of recursion, used to indent submenu items
    	Dim itemcount As Long    ' the number of items in the specified menu
    	Dim c As Long            ' loop counter variable
    	Dim mii As MENUITEMINFO  ' receives information about each item
    	Dim retval As Long       ' return value
    	
    	' Count the number of items in the menu passed to this subroutine.
    	itemcount = GetMenuItemCount(hMenu)
    	
    	' Loop through the items, getting information about each one.	
    	With mii
    		.cbSize = Len(mii)
    		.fMask = MIIM_STATE Or MIIM_TYPE Or MIIM_SUBMENU
    		For c = 0 To itemcount - 1
    			' Make room in the string buffer.
    			.dwTypeData = Space(256)
    			.cch = 256
    			' Get information about the item.
    			retval = GetMenuItemInfo(hMenu, c, 1, mii)
    			' Output a line of information about this item.
    			If mii.fType = MFT_SEPARATOR Then
    				' This is a separator bar.
    				Debug.Print "   " & String(3 * level, ".") & "-----"
    			Else
    				' This is a text item.
    				' If this is checked, display (X) in the margin.
    				Debug.Print IIf(.fState And MFS_CHECKED, "(X)", "   ");
    				' Display the text of the item.
    				Debug.Print String(3 * level, ".") & Left(.dwTypeData, .cch)
    				' If this item opens a submenu, display its contents.
    				If .hSubMenu <> 0 Then
    					IterateThroughItems .hSubMenu, level + 1
    				End If
    			End If
    		Next c
    	End With
    End Sub
    
    ' *** Place the following code inside Form1. ***
    ' When Command1 is clicked, output the entire contents of Form1's menu system.
    Private Sub Command1_Click()
    	Dim hMenu As Long  ' handle to the menu bar of Form1
    	
    	' Get a handle to Form1's menu bar.
    	hMenu = GetMenu(Form1.hWnd)
    	' Use the above function to output its contents.
    	IterateThroughItems hMenu, 0
    End Sub
    I'm sure if its not EXACTLY what you want it may help you on your way and at the very least give you a more firm direction.

    DocZaf
    {;->


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    Dear Zaf Khan

    Thank you so very much for your kind help.
    However, This wasn't what i'm after.
    Please Double check my post and visit the link. It might gives you a better picture.

    Again, Thanx.




    [Edited by Lyla on 08-02-2000 at 06:46 AM]

  5. #5
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

    Thumbs up The Answers On Microsoft's Site

    Hi Lyla,

    I clicked the link which you have in your post and i found the answer there

    http://msdn.microsoft.com/workshop/b...#wb_print_hook


    HCBT_ACTIVATE notifies us when a window is about to receive the WM_ACTIVATE message. It is at this point that we can take control of the dialog. The idea is to send messages to the window to make it think that the user is interacting with the dialog. You can enter text into textboxes, set checkboxes and radio buttons, and click OK or Cancel. The easiest way to identify controls in the dialog is to find out their resource ID's with a tool like Spy++. Then you can call GetDlgItem to obtain the HWND of the control and SendMessage to interact with it
    That means that whether the control that controls the fetaures you want to diable/enable/modify is a menu option or button or ANY OTHER control that has a resource Id, and thats nearly all of them.

    The code that does all of the dirty work in the samples is implemented in a reusable class named CWebBrowserPrint. This is defined in the WebBrowserPrint.h and WebBrowserPrint.cpp files. This makes it easy to incorporate the ability to set custom print settings in any C++ application that is hosting the WebBrowser control. The public aspects of the class are shown below.
    Code:
    class CWebBrowserPrint
    {
    public:
       enum Orientation {
          OrientationUndefined,
          OrientationPortrait,
          OrientationLandscape };
       enum PrintRange {
          PrintRangeUndefined,
          PrintRangeAll,
          PrintRangePages,
          PrintRangeSelection };
       enum PrintFrames {
          PrintFramesUndefined,
          PrintFramesScreen,
          PrintFramesSelected,
          PrintFramesIndividually };
       
       void SetWebBrowser(IWebBrowser2* pWebBrowser);
       bool Print();
       bool ReadDlgSettings();
       CString GetPrinterName(ULONG lIndex);
       ULONG GetPrinterCount();
       CStrin GetDefaultPrinterName();
    
       // Page Setup dialog settings
       CString m_sPaperSize;
       CString m_sPaperSource;
       CString m_sHeader;
       CString m_sFooter;
       Orientation m_Orientation;
       float m_fLeftMargin;
       float m_fTopMargin;
       float m_fRightMargin;
       float m_fBottomMargin;
    
       // Print dialog settings
       CString m_sPrinterName;
       bool m_bPrintToFile;
       PrintRange m_PrintRange;
       ULONG m_lPrintRangePagesFrom;
       ULONG m_lPrintRangePagesTo;
       ULONG m_lCopies;
       bool m_bCollate;
       PrintFrames m_PrintFrames;
       bool m_bPrintLinks;
       bool m_bPrintLinkTable;
    };
    Thats just a tiny piece of the many many samples and documents, i must admit it took d=some reading, also a point worth noticing is that MS say it work with WIN2000 due to the differences in the new Print Dialog architecture.


    DocZaf
    {;->





    [Edited by Zaf Khan on 08-02-2000 at 09:55 PM]

  6. #6
    Guest
    What print code are you using?
    This will work as well:

    Code:
    'Don't prompt user
    webbrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
    
    'Prompt user
    webbrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    Zaf Khan, Thanx again.

    That's right! Hooking.
    I downloaded Phookctl & Phookvb. As you saw, Phookctl was written in C ( and I have no clue about C ). I was hopping that I could do it without any additional controls.
    FYI, with IE 5.5 NO need for all this hassle coz it supports Properities. Ofcourse, not everyone is using IE 5.5 and above.

    Matthew Gates Thanx too. I'm using:

    webbrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER

    FYI, IE 4.0 and above Supports this Print code ONLY.

    I'm still looking for anyway around this
    Thanx to all of you.



  8. #8
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    Matthew Gates,

    nice one, you solved my problem without even knowing it!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width