Ohhh no - you try to call the API with a window handle as a parameter, but the the API is defined like the following:
BOOL PrintDlg( LPPRINTDLG lppd // initialization data );
So you have to call it with the address of a PRINTDLG structure. This structure contains informations used to initialize the dialog box (including the handle to the owner window).
See http://www.msdn.microsoft.com/library/default.asp?URL=/library/psdk/winui/co mmdlg3_7xwy.htm
How to do it in Squeak: - create a new subclass Win32PRINTDLG of ExternalStructure - implement the class method #fields to define the fields of the struct like: Win32PRINTDLG(class)>>fields "Win32PRINTDLG defineFields" ^#( #(#lStructSize 'long') #(#hwndOwner 'long') ... ) see http://www.msdn.microsoft.com/library/default.asp?URL=/library/psdk/winui/co mmdlg3_7xwy.htm for the structure definition (note that any structure member is a long (4 bytes), except nFromPage, nToPage, nMinPage, nMaxPage, nCopies (only two bytes) - evaluate "Win32PRINTDLG defineFields" to create accessor methods on the instance side - create an API call method shellPrintDialog: aWin32PRINTDLG "Displays a print dialog box" <apicall: bool 'PrintDlgA' (Win32PRINTDLG*) module: 'comdlg32.dll'> ^self externalCallFailed This should work. If the API call goes wrong it returns FALSE (= 0).
I personally dont like the way Squeak calls API functions. In Smalltalk MT you only write: WINAPI PrintDlg: PRINTDLG new
That's a little bit easier ;)
Hope this helps Torsten
BTW: It's interesting that you mail address is Kronos.com - my nickname is Cronos
-----Original Message----- From: Norton, Chris [mailto:chrisn@Kronos.com] Sent: Freitag, 30. Juni 2000 04:26 To: Squeak (E-mail) Subject: [Q] Using FFI to call standard Windows dialogs
Hi Folks.
I was experimenting with FFI on my Windows NT box and I kept crashing my image (virtual memory dumps). Can anybody help me with this call?
~~~~~~~~~~~~~~~~~~~~~~~~~~ Win32Shell>> shellPrintDialog: aHWND "Win32Shell new shellPrintDialog: Win32Window getFocus"
<apicall: bool 'PrintDlgA' (Win32Window) module: 'comdlg32.dll'> ^self externalCallFailed
~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm trying to launch the print dialog.
Thanks for your thoughts!
---==> Chris
PS> And my next question is, of course, how do I get a document to print once I've got the dialog launching from Squeak (e.g. how do I provide the dialog with a document to print?)...
On Fri, 30 Jun 2000 Torsten.Bergmann@phaidros.com wrote:
I personally dont like the way Squeak calls API functions. In Smalltalk MT you only write: WINAPI PrintDlg: PRINTDLG new
That's a little bit easier ;)
It's easier because someone implemented WINAPI and PRINTDLG classes before. You can do the same in Squeak. If you have too much time, that is.
-- Bert
At 11:02 30.06.00 +0200, Torsten.Bergmann@phaidros.com wrote:
I personally dont like the way Squeak calls API functions. In Smalltalk MT you only write: WINAPI PrintDlg: PRINTDLG new
That's a little bit easier ;)
But you can do this in Squeak, too. Just implement it that way. I'd probably suggest to use #printDlg: instead. The disadvantage of one single WINAPI class is that this gets pretty large and will probably even beat class Morph in the number of methods then...
bye -- Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf
squeak-dev@lists.squeakfoundation.org