|
I have a toolstrip menu with a toolstripdropdownbuttom, and one of the dropdown items takes a snapshot of the current screen display for a printscreen. The problem I am having is that the toolstrip dropdown menu itemsappear in back of the data displayed on the screen. The code is as follows:
Protected Sub bnBtnReportPrintForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles bnBtnReportPrintForm.Click bnMnuReport.HideDropDown()'parent toolStripMenuItem printForm() 'prints the screen End Sub
I tried inserting a timing delay (System.Threading.Thread.Sleep(500)) and a test conditional (while bnMnuReport.Visible) but this has not helped.
Does anyone have any idea how to insure that the toolstripdropdown is hidden before the screenshot is printed?
Thanks, -BGood - Changed TypeKira QianMSFT, ModeratorWednesday, June 24, 2009 6:22 AM
- Changed TypeBGood Wednesday, June 24, 2009 3:38 PMnot resolved
-
| | BGood Wednesday, June 17, 2009 7:18 PM | Hi BGood, My test show difference with your description. The first time I click DropDownButton to do screenshot, everything be ok. The second time I do this. The DropDownButton will cover some part of the previous screenshot. The first screen shot is correct. The second will have dropdownbutton covered blank. That is because when you drop down the menu, it cover the previous screen shot, repaint will draw default color for the form, so the next shot will have that blank space. Screen shot always happen after dropdownbutton closed. Here is my code. public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void screenShotToolStripMenuItem_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.CopyFromScreen(this.Location, new Point(0, 20), this.Bounds.Size); } } If you have any question, please feel free to tell me. Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Friday, June 19, 2009 7:15 AM | We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Wednesday, June 24, 2009 6:22 AM | Hi Kira,
Thanks for the reply. Because the problem is unresolved I have changed it back to question status and my apologies for my untimely response. I have been preoccupied with other projects.
It is difficult to compare your test case with my presentation because you are using C# and different methods. My question used VB and the PrintFrom method distributed with Visual Basic Power Pack add-in, and the toolstrip drop-down shows up unexpectedly when I call printform().
Although the timing delay did not work for me, maybe another possible solution would be to create a new program thread consisting of the call to bnMnuReport.HideDropDown() so I could trigger the printForm() on completion of the HideDropDown() event.
If you think this might be worthwhile, do you have any suggestion on how to create and monitor such a thread?
Thanks, -BGood | | BGood Wednesday, June 24, 2009 3:48 PM | Hi BGood, Could you please post your screen shot? I just guess the problem you are facing but without seeing that. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Thursday, June 25, 2009 1:41 AM | Hi again Kira, Looking at the upper left corner of the screen, here is the screenshot of my drop-down menu to print the screen: http://mrktvalu.com/screenshots/PrintScreenMenu.jpgand here is the screenshot of the PrintForm result: http://mrktvalu.com/screenshots/PrintScreenResult.jpg(I hope these links show up in the post. Please let me know if there is a trick to getting the image to display while editing.) Notice how the drop-down menu shows through the data fields on the form's display canvas. Thanks again for taking a look at this. -BGood | | BGood Thursday, June 25, 2009 4:13 PM | Hi BGood, Thank you for sharing me the screen shot. The problem seem only relate to the TextBox area. The TextBox remain some shadow of the drop down list while other form area looks better. I think delay the print action won't help even longer than 1 second. But I still don't see your code to print the form, could you please show me that? Another thinking is put a small button on your ToolStip, just print the form. This seems the easiest solution. But still I willing to find the problem, so please show me the print code let me see if there is a better solution. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Friday, June 26, 2009 2:11 AM | Hi Kira,
Here is the print form code, and some commented out code which did not work (except for the messagebox approach, but then the messagebox appears in the print screen):
Protected Sub bnBtnReportPrintForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles bnBtnReportPrintForm.Click bnMnuReport.HideDropDown() 'While bnMnuReport.DropDown.Visible ' System.Threading.Thread.Thread.Sleep(500) ' 'SendKeys.SendWait("{escape}") 'End While 'SendKeys.Send(vbCr) 'MessageBox.Show("snapshot") printForm() End Sub 'ts btn > Report > Print Form
Protected Overridable Sub printForm() With Me.PrintForm1 Dim porientation_original As Boolean = .PrinterSettings.DefaultPageSettings.Landscape .PrinterSettings.DefaultPageSettings.Landscape = True .PrinterSettings.DefaultPageSettings.Margins.Left = 15 .PrinterSettings.DefaultPageSettings.Margins.Right = 15 .PrinterSettings.DefaultPageSettings.Margins.Top = 200 .PrinterSettings.DefaultPageSettings.Margins.Bottom = 75 .PrinterSettings.DefaultPageSettings.PrinterResolution.Kind() = Printing.PrinterResolutionKind.High .PrintAction = Printing.PrintAction.PrintToPreview .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly) .PrinterSettings.DefaultPageSettings.Landscape = porientation_original End With End Sub 'printScreen form
Thanks,
-BGood | | BGood Friday, June 26, 2009 2:26 AM | Hi BGood, The printForm method doesn't show valuable print code with your current form screen shot, it just show me the settings. Why? Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Friday, June 26, 2009 3:10 AM | Hi Kira,
PrintForm is a custom tool which I downloaded with the VB power pack for Visual Studio 2008. I haven't looked 'under the hood' at the tool, and I'm not sure I have the source code to do so.
Thanks,
-BGood | | BGood Friday, June 26, 2009 3:49 AM | Hi BGood, I cannot help much on third part tool/component. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Friday, June 26, 2009 6:31 AM | Kira,
The VB power pack is from Microsoft, but thanks for taking a look anyway. By the way, how do you get your screenshots to show up in your posts?
Thanks,
-BGood | | BGood Friday, June 26, 2009 2:31 PM | Hi BGood, To give screen shot to the forum, you can first upload a picture to a website and edit your post's html like this. <img src="http://www.microsoft.com/sample.JPG" alt="" /> src is the real location of your image. So the image can appear to the forum. Also VB power pack are not served at this forum. Winform forum support standard controls. Anyway glad to serve you. Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Monday, June 29, 2009 1:46 AM |
|