Hide arranging form before print

I have code to change forms controls before printing and then back after print
    eg; form color from brown to white,etc
the changes is briefly visuable. before printing
.How can i stop this?


Sub BeforePrint()
    lstPrinters.Visible = False
    cmdHelp.Visible = False
    cmdDeleteCboItem.Visible = False
    miFrame1Top = Frame1.Top
    picBelowTop.Visible = False'hide the pic containg buttons
    mLFormColor = Me.BackColor
    Me.Frame1.BackColor = vbWhite
    Frame1.Top = 500'leave space at the top as a margin
    FraProjects.BackColor = vbWhite
    Me.BackColor = vbWhite
'    Command2.Visible = False
'    Command3.Visible = False
End Sub
Ihave tried this:
created another for just for printing and copied values
Tried this:
frmPrintGetBids.Left = Screen.Width + 800 'hide the form off the screen
This produced a completely black printout

setting the print forms z.order to 1,but it did not hide it.

Have not tried api setting the move to the back,
getting tired of trying things that don't work.
How can this be fixed ?
isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Add this API
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long

And then  
LockWindowUpdate frmGetBids.hwnd
' Change colors and then print
LockWindowUpdate 0
0
isnoend2001Author Commented:
Thanks MartinLiss i will try that after i change code to use another form for printing
0
Martin LissOlder than dirtCommented:
You don't need to use another form. Did you see the project I posted in the make a forms width fit printout thread?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

isnoend2001Author Commented:
Yes i see it and it works.
The actual color of the form is brown and has many controls
The one i sent you is how it will look when printed.
The LockWindowUpdate did not work it shows the form as before changes
0
isnoend2001Author Commented:
Before and after printBeforeAfterprintBeforeAfterprint
0
isnoend2001Author Commented:
CaptureClient is added twice
' CreateBitmapPicture   - Creates a picture object from a bitmap and palette.
' CaptureWindow         - Captures any window given a window handle.
' CaptureActiveWindow   - Captures the active window on the desktop.
' CaptureClient           - Captures the entire form.
' CaptureClient         - Captures the client area of a form.
' CaptureScreen         - Captures the entire screen.
' PrintPictureToFitPage - prints any picture as big as possible on the page.
0
Martin LissOlder than dirtCommented:
Yes I see that it doesn't work. The CaptureForm code takes a "snapshot" of the way the screen looks and since the LockWindowUpdate prevents the changes from being seen, the the snapshot is taken of the way it looked before. Let me think about this a bit and if I come up with anything I'll let you know.
0
Martin LissOlder than dirtCommented:
Don't worry about CaptureClient since it's not used in your case.
0
Martin LissOlder than dirtCommented:
While there might be a way to take a snapshot of a changed form without it being visible, if you use my code then literally "what you see is what you get" and you may have to live with the changes being briefly visible.
0
isnoend2001Author Commented:
Thanks MartinLiss. I had another thought
Have another borderless form cover the client area briefly (on top)
0
Martin LissOlder than dirtCommented:
Again with my code, what you see is what you get so if you cover it you'll get a picture of the cover.
0
isnoend2001Author Commented:
I found this:
CaptureForm - Captures the entire form.
 CaptureClient - Captures the client area of a form.
0
Martin LissOlder than dirtCommented:
CaptureForm is what I'm using. CaptureClient wouldn't act any differently as far as WYSIWYG.
0
isnoend2001Author Commented:
maybe the code i posted here: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28535877.html#a40377516
Would work where you pass the forms name
0
Martin LissOlder than dirtCommented:
I can't tell by looking at it so you'll need to try it.
0
jkaiosIT DirectorCommented:
Are you using Access or pure VB?

If Access then you can just set the Display When property of each control to Screen Only rather than writing additional lines of code.

If using pure Visual Basic, how do you print the form image?  Are you using the <Form>.PrintForm method?
0
isnoend2001Author Commented:
not using access only vb6
0
isnoend2001Author Commented:
MartinLiss
Re: I can't tell by looking at it so you'll need to try it.

Tried it and it did not work. it printed the cover form and the form to be printed
0
isnoend2001Author Commented:
The only other thing i can think of to try is Put the code to print into another form
copy the data and print the other form
0
Martin LissOlder than dirtCommented:
But it needs to be visible in order to print it so that doesn't gain you anything.
0
Martin LissOlder than dirtCommented:
I have an idea. Be back soon.
0
isnoend2001Author Commented:
ok
0
Martin LissOlder than dirtCommented:
I know that the form that I have is not your actual form but what to rearrange that form so that it is narrower. That let's PrintForm work and PrintForm doesn't require that the changes be visible. As a demonstration this project temporarily changes the form's backcolor to vbYellow, prints it, and changes the backcolor back to what it was.
Q-28536734.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Thanks MartinLiss
What i don't understand is how the printed output does not show the forms title bar. This is good but i don't see how.
This may create another option :eg; copy the data to another form and use PrintForm on the other form
0
Martin LissOlder than dirtCommented:
That won't work. I'll modify the project after I eat dinner.
0
isnoend2001Author Commented:
ok
0
Martin LissOlder than dirtCommented:
Well what I was going to do was to add a label at the top of the form that would contain "Bids" that would only be made visible for the print, but you already have lblJobName so why do you need the form's caption in the picture?
0
isnoend2001Author Commented:
I don't want the forms caption in i thought printform always included the title bar weather you wanted it or not. is this incorrect ?
0
Martin LissOlder than dirtCommented:
PrintForm never shows the form caption.
0
isnoend2001Author Commented:
Thanks, thought it did
0
isnoend2001Author Commented:
MartinLiss discovered this;
The printform will work in a form without it being shown
Public Sub PrintGetBids()
  frmPrintGetBids.Visible = True
 frmPrintGetBids.Left = Screen.Width + 500
 PrintForm
End Sub
0
Martin LissOlder than dirtCommented:
The printform will work in a form without it being shown
Yes I know that's true, but in the code you just posted you have

 frmPrintGetBids.Visible = True

so I don't understand what you are trying to say.
0
isnoend2001Author Commented:
yes but then i moved off the screen
 frmPrintGetBids.Left = Screen.Width + 500
0
Martin LissOlder than dirtCommented:
Why?

Are you printing from a modified copy of the other form? If so why do you feel you need to do that?
0
isnoend2001Author Commented:
Yes it is a modified copy of the other form, guess i did it because I had already made the modified copy  from earlier attempts, before printform eg grid and column widths,placement etc
on the upside:
No need to write code to put everything back.
On the downside:
Another form added to project.
Is there any reason why this will not work ?
0
Martin LissOlder than dirtCommented:
Another downside is that you'll need to remember to make changes to both forms if the main one needs to be changed. I wouldn't do it that way but your way will work.
0
isnoend2001Author Commented:
Thanks, have already ran into that:
lblRecap.Caption = "Recap for " & cboBids.Text
0
Martin LissOlder than dirtCommented:
It should be a fairly easy thing to do it with one form. Can you provide a copy of your main form (even if it won't work by itself) and tell me all the temporary changes you want to make to it for printing purposes?
0
isnoend2001Author Commented:
Thanks MartinLiss,but the form has ton's of ocx's that have to replaced.
This i know how to do (althought not as good as you)
i Sure like your help for what I don't how to do
If I sent the code I wrote you could not stop laughing long enough.
I have stuff like this:
Dim PaperWidth As Long
PaperWidth = 1440 * 8.5
lblRecap.Left = PaperWidth / 2 - lblRecap.Width / 2
lblJobName.Left = PaperWidth / 2 - lblJobName.Width / 2
0
Martin LissOlder than dirtCommented:
I wouldn't laugh. Believe me I've seen it all. Many more years ago then I like to think about (circa 1973) when I was in one of my first programming classes we were being taught COBOL which has a MOVE statement, and one person attempted to write a program that contained many statements like PLEASE MOVE.... lol. I guess I do laugh at some code:)

Anyhow here's how I'd change that code.

Const PaperWidthInTwips As Long = 11520

lblRecap.Left = PaperWidthInTwips / 2 - lblRecap.Width / 2
lblJobName.Left = PaperWidthInTwips / 2 - lblJobName.Width / 2
0
isnoend2001Author Commented:
I have had some funny support calls
had ad customer email me with a software problem
His closing comment "And I'm not looking for an email buddy"
Another lady "Your left or My Left ?"
Another lady on the phone with me telling her to click the cd.
She said "I'm holding the mouse right by the cd door and nothing happens"
never seen this before PaperWidthInTwips
0
Martin LissOlder than dirtCommented:
PaperWidthInTwips is just a descriptive name that I made up.
0
Martin LissOlder than dirtCommented:
It's 1440 times 8.5
0
isnoend2001Author Commented:
I see now No wonder it didn't Google
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.