Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing Macro to call Win32 comdlg32/user32 functions.

Status
Not open for further replies.

Starg

MIS
Jul 17, 2002
16
AU
Hi,
Does anybody have examples on how to make win32 APIs calls for common dialogs (I am trying to open the Print Dialog). My code compiles but does not display the dialog or return an error. I think the problem I am having is returning the handle to the current window. I make the Powerplay application active and the getforgroundwindow call returns a number, but I do not think I am doing it properly. Some example code would be GREAT :)

Here is what I have so far:


Type PRINTDLGS
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hDC As Long
flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As String
lpSetupTemplateName As String
hPrintTemplate As Long
hSetupTemplate As Long
End Type

declare function PrintDlgA lib "comdlg32" alias "PrintDlgA" (pPrintDlg as PRINTDLGS) as Long
Declare Function GetForegroundWindow Lib "user32" () As Long

Sub Main()

Dim objPPApp as Object
dim PrintDlg as PRINTDLGS

PrintDlg.lStructSize = Len(PrintDlg)

set objPPApp = CreateObject("Powerplay.Application")

'make Powerplay visible
objPPApp.Visible 1

PrintDlg.hwndOwner = GetForegroundWindow()
Result = PrintDlgA(PrintDlg)
End Sub
 
Dave,
Yes it does, but that does bring me to another point. In the final version of this macro I would want the application to be invisible. This means I need to assign the window handle to a dialog box that I have displayed, would you know how to the the Window handle of a dialog box that is created in the macro?

Thanks

Starg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top