Can't lock the handle of hDevMode after calling PrintDlg

Can't lock the handle of hDevMode after calling PrintDlg

Post by Kazte » Fri, 14 Jul 2000 04:00:00



Hi
  I work with msVisual C++ v1.51. This compiles code for windows 16 bits
(3.0 / 3.1)  and later.

 My problem :
  I call the PrintDlg function and try to retrieve the DevMode structure in
order to call the same printer the next time without any selection.
but the pointer to the devmode structure can't be retrieved

 Here's how I code this:

 1. call PrintDlg . This sets a valid handle of a DevMode structure in the
PRINTDLG structure returned.
 2. try to find the memory location of datas :  ptr = GlobalLock(.....);
3. write the retrieved datas on harddisk.
4. reload datas later
5. send them to the function CreateDC(....   &DevMode   ....);
6. Use the DC of the previously selected printer.

---------------------------------------------------------------------------
PRINTDLG pd;
DEVMODE *lpDevMode;

PrintDlg(&pd);

lpDevMode = (DEVMODE *) GlobalLock(pd.hDevMode);
----------------------------------------------------------------------------
-

at this point, the function global Lock returns a NULL pointer.
My code works well if compiled using 32bits like msvc2.0 and above, but it
fails when compiling in 16bits (msvc1.51).

 Please need your help, I don't understand anything to this bug.

 
 
 

1. PrintDlg: hDevMode and hDevNames documentation error ?

While answering a question for another poster, I noticed what appears to
be an error in the documentation for the PrintDlg() common dialog
function.

The PRINTDLG structure contains two global memory handles, hDevMode and
hDevNames. If you allocate these structures yourself you are supposed to
use moveable memory. If you do not allocate them, PrintDlg() will
allocate them (presumably using moveable memory) and return the handles
to you.

The on-line documentation, on the page for PRINTDLG, then goes on to
say:
   "Because this structure is a movable global memory object, the value
of hDevMode may change during the execution of PrintDlg."
and:
   "Because this structure is a movable global memory object, the value
of hDevNames may change during the execution of PrintDlg."

I thought the value of _moveable_ memory was that the handle _does not_
change when you resize the memory block; only its pointer changes.

Would anyone care to comment on this?

Norm

2. Lode Runner on LX200

3. Getting the handle to PrintDlg()'s dialog

4. Notification Server slows down drastically when a client dies

5. Getting a printer DC without calling `PrintDlg' routine

6. screenshots

7. Technical term for 'circular call' or 'ring call'

8. WTD: Novell Guru - Bangkok

9. Modifying the PrintDLG common dialog 'caption'

10. I Still can't get a hold of the CALL HANDLE !!!!!!!!!!!!!!!!

11. How to call function from 'DLL calling application' inside DLL

12. Can't find the right Call-Handles

13. I don't get call handles