The following sample code shows how the printer dialog is created and associated with a notebook page. The example ends by showing the dialog procedure for the associated dialog.
#define INCL_DOSRESOURCES APIRET dlgret; HWND hwndPage, hwndNotebook; PDLGTEMPLATE pDlgt; SEL sel = NULL; /**********************************************************************/ /* Allocate memory. */ /**********************************************************************/ DosAllocMem((PPVOID)&pDlgt, sizeof(DLGTEMPLATE), PAG_COMMIT | PAG_READ | PAG_WRITE); /**********************************************************************/ /* Retrieve the dialog resource. */ /**********************************************************************/ dlgret = DosGetResource((HMODULE)0, /* Resource */ /* (Obtain from executable) */ RT_DIALOG, /* Resource type */ ID_DLG_PRINTDRV, /* Resource ID */ (PPVOID)&pDlgt); /* Dialog template address */ /**********************************************************************/ /* Create a dialog. */ /**********************************************************************/ hwndPage = WinCreateDlg(HWND_DESKTOP, /* Parent window handle */ hwndBook, /* Owner window handle */ fnwpPrint, /* Dialog procedure */ /* address */ pDlgt, /* Dialog data structure */ /* address */ NULL); /* Application data */ DosFreeMem(pDlgt); /* Free memory */ /**********************************************************************/ /* Associate dialog with the inserted notebook page. */ /**********************************************************************/ WinSendMsg(hwndBook, BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId), MPFROMHWND(hwndPage)); /**********************************************************************/ /* Dialog procedure. */ /**********************************************************************/ MRESULT EXPENTRY fnwpPrint(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2) { switch (msg) { case WM_INITDLG: /****************************************************************/ /* Place dialog initialization code here. */ /****************************************************************/ break; case WM_COMMAND: return ((MRESULT) FALSE); break; default: return WinDefDlgProc (hwndDlg,msg,mp1,mp2); } return WinDefDlgProc (hwndDlg,msg,mp1,mp2); }