|
-
Jul 23rd, 2001, 02:56 AM
#41
Member
Joacim, I figured out what's not working. I got the class to display a msgbox by modifying the ShowPrinter dialog like this:
Code:
Public Function ShowPrinter() As Boolean
Dim pd As PrintDlgStruct
Dim nRetVal As Long
pd.lpSetupTemplateName = ""
pd.lpPrintTemplateName = ""
pd.hwndOwner = m_Owner.hwnd
pd.nCopies = Me.PrintCopies
pd.Flags = PD_HIDEPRINTTOFILE Or PD_NOPAGENUMS Or PD_NOSELECTION
pd.lStructSize = Len(pd)
nRetVal = PrintDlg(pd)
MsgBox pd.nCopies
Me.PrintCopies = pd.nCopies
ShowPrinter = (nRetVal <> 0)
End Function
What I found was that everytime the msgbox appeared, no matter what the number of copies was set to, pd.nCopies was always 1 for some reason. Do you know why it would do that? Is there a way to fix it? Please respond A.S.A.P. Thanks for all your help.
-
Jul 23rd, 2001, 09:00 AM
#42
Yes I know whats wrong.
When you call ShowPrinterProperties and you'll have the option to set the number of copies in that dialog (I can't do it on any of my printers)
the value is sent directly to the printer and is not (for some reason) saved in the structure (Why? -Ask Microsoft).
When this is stored in the printer the printer itself will print that number of copies without you needing to loop thru the PrintCopies property.
If you don't want this behaviour I can only suggest that you don't show the properties dialog but only call the ShowPrinter dialog.
Best regards
-
Jul 23rd, 2001, 12:00 PM
#43
Frenzied Member
ccommondialog.filename won't work.... I am doing openfolder in the commondialog class, but when i try to retrieve the filename it won't work, is there another way to do this??
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Jul 23rd, 2001, 01:40 PM
#44
The FileName property can only be used when you pick a file (in the Open and Save As dialogs).
When you call the ShowFolder method use the Path property instead.
Best regards
PS.
To Cinder829,
Thanks for downloading Source Edit. I hope you enjoy it and please mail me any feedbacks you can think of.
And if you didn't download it, there is a version 1.2 update on http://www.sourceedit.cc
-
Jul 23rd, 2001, 04:31 PM
#45
Member
Well, I've gotten rid of the print properties dialog, but I still can't print multiple copies. Do you know why pd.nCopies wouldn't change when the user closed the print dialog? For some reason it's always 1. Is there a fix or a workaround? Here's the code I have right now.
Code:
Public Function ShowPrinter() As Boolean
Dim pd As PrintDlgStruct
Dim nRetVal As Long
pd.lpSetupTemplateName = ""
pd.lpPrintTemplateName = ""
pd.hwndOwner = m_Owner.hwnd
pd.nCopies = Me.PrintCopies
pd.Flags = m_Flags
pd.lStructSize = Len(pd)
nRetVal = PrintDlg(pd)
Me.PrintCopies = pd.nCopies
ShowPrinter = (nRetVal <> 0)
End Function
P.S. Joacim, I know that Source Edit probably wasn't really made to edit vb programs, but it would still be nice if it did a better job with visual basic form files, e.g. didn't display all of the form information at the top of the file. Other than that, it's great! Keep up the good work...
-
Oct 10th, 2001, 07:30 AM
#46
Joacim,
I'm trying to use this class to show the color dialog, and I can't get it to set the focus on the correct box for the initial color. My code is as follows:
VB Code:
i_CommonDialog.Init Me
i_CommonDialog.Color = Me.BackColor
lb_Result = i_CommonDialog.ShowColor
If lb_Result = True Then Me.BackColor = i_CommonDialog.Color
When the color dialog appears, the first color box in the dialog has focus (which is a pink color box on mine) instead of the gray that is my form backcolor. If I click OK without clicking on any color boxes, the color does not change to the color in that first box, it does stay the same color as my form, which would be correct. But it should set focus on the initial display of the dialog box to the correct color box, shouldn't it?
I also noticed that the custom color boxes at the bottom are not always the same.
Thanks..... (this class is very helpful)
-
Oct 10th, 2001, 08:31 AM
#47
The problem is that you assign one of the system colors. In this case (probably) vbButtonFace which has a value of &H8000000F. Which isn't actually grey.
To change this behaviour add the following declaration to the class
VB Code:
Private Declare Function GetSysColor _
Lib "user32" ( _
ByVal nIndex As Long) As Long
Now change the Property Let Color procedure into the following
VB Code:
Public Property Let Color(ByVal nNew As Long)
Dim sHex As String
m_Color = nNew
If m_Color < 0 Then
' A system color. Convert it to correct color
sHex = Right$(Hex(m_Color), 4)
m_Color = CLng("&H" & sHex)
m_Color = GetSysColor(m_Color)
End If
End Property
You should now get the correct color.
Thank you so much for pointing this out.
-
Feb 25th, 2002, 12:23 PM
#48
Junior Member
show folder
Does this class work in MS Word 97?
I have it running in VB6 but want to use it in VBA
I am declaring my class as following but I'm getting an error
Dim cdl As CCommonDialogs
Set cdl = New CCommonDialogs
cdl.Init Me
cdl.ShowFolder
-
Feb 25th, 2002, 03:12 PM
#49
You have to make some slight changes to the code to make it work in Word.
The Init method takes a VB Form as an argument. This form is then used as the parent window for the dialog boxes.
Remove the Init method and change all the code you find with m_Owner.hWnd to 0.
Best regards
-
Feb 26th, 2002, 05:30 AM
#50
Junior Member
Thanks for the quick response. Unfortunately I didn't have any luck. I'm new to VBA and learning this as I go so it could be something quite simple that I'm doing wrong. I'm using the class in a template which I place in the startup folder for word. It wont let me step through the code to find the error so I feel a little helpless. Why is it not possible to run my macro when I'm editing the template. Why do I have to run the template in the startup folder in order to run the macro and then not be able to view the code behind the macro? Any help muchly appreciated!
-
May 10th, 2009, 02:58 PM
#51
New Member
Re: Common Dialogs made easy
How I can show common dialog ( commondialog1.showfont for Example) in center of screen ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|