Page 1 of 1
SetLandscape
Posted: Sun Jun 13, 2021 12:57 am
by Otto
Hello friends,
If I use oPrn:SetLandscape() or oPrn:SetPortrait() ? oPrn:nOrient always returns 1.
Is SetLandscape working for you?
Best regards,
Otto
Code: Select all | Expand
function nOrientPrn()
local cret, oprn
PRINTER oPrn
cRet := oPrn:getmodel()
? cRet
oPrn:SetLandscape()
? oPrn:nOrient
oPrn:SetPortrait()
? oPrn:nOrient
endprint
return cret
Re: SetLandscape
Posted: Sun Jun 13, 2021 6:12 am
by Antonio Linares
Dear Otto,
Please try this change in your code:
? oPrn:nOrient := oPrn:GetOrientation()
Re: SetLandscape
Posted: Sun Jun 13, 2021 8:10 am
by Otto
Dear Antonio,
I did what you suggested but Setorient() in my case does not work.
If I change directly the Printer setup in the setup window then you get the right orientation from GetOrient() function.
Best regards,
Otto
function SetOrient(nOrient)
local cret, oprn
//#define DMORIENT_PORTRAIT 1
//#define DMORIENT_LANDSCAPE 2
PRINTER oPrn
if nOrient=2
oPrn:SetLandscape()
else
oPrn:SetPortrait()
endif
endprint
return NIL
function nOrientPrn()
local cret, oprn
PRINTER oPrn
cRet := oPrn:getmodel()
? oPrn:nOrient := oPrn:GetOrientation()
endprint
return cret
Re: SetLandscape
Posted: Sun Jun 13, 2021 9:04 am
by Antonio Linares
yes, thats the right way to do it
Re: SetLandscape
Posted: Sun Jun 13, 2021 9:41 am
by Otto
Dear Antonio,
maybe I explained myself bad.
It is not working.
Only if I change the orientation manually I can see with getorient() right orientaion. But Setorient() is not working.
What should I do?
Best regards,
Otto
Re: SetLandscape
Posted: Sun Jun 13, 2021 4:23 pm
by Antonio Linares
Please try it this way and lets check if there is a difference:
PrnLandscape( oPrinter:hDC )
...
PrnPortrait( oPrinter:hDC )
Re: SetLandscape
Posted: Sun Jun 13, 2021 7:26 pm
by Otto
Dear Antonio,
the situation is the same. It hasn't changed.
Best regards,
Otto
Re: SetLandscape
Posted: Sun Jun 13, 2021 10:28 pm
by nageswaragunupudi
For me, this is working
Code: Select all | Expand
PRINT oPrn PREVIEW
oPrn:SetPortrait()
? oPrn:GetOrientation() // --> 1
oPrn:SetLandScape()
? oPrn:GetOrientation() // --> 2
Did I not understand the problem?
Re: SetLandscape
Posted: Mon Jun 14, 2021 12:24 am
by Otto
Dear Mr. Rao,
shouldn't these changes affect the printer setup?

Best regards,
Otto
Re: SetLandscape
Posted: Mon Jun 14, 2021 7:33 am
by Otto
Dear Mr. Rao, dear Antonio,
My problem is that I need to print from TActiveX.
It seems that Fivewin creates a printer device context and not makes the default for this printer for all applications.
Printing from the web browser control I think is a different application.
Therefore, I would need the changes for all applications.
Can you please help me?
Best regards,
Otto
https://www.amyuni.com/forum/viewtopic.php?t=1224Once the DEVMODE structure has been modified to suit our configuration, we can either create a
printer device context using the CreateDC API call:
Code: Select all
HDC hDC = CreateDC( _T( "winspool" ), szPrinter, NULL, lpDevMode );
Or make this configuration as the default for this printer and for all applications using this printer.
Code: Select all
DWORD dw;
PRINTER_INFO_2 *pi2;
// get default printer info structure which contains the DEVMODE
GetPrinter( m_hPrinter, 2, NULL, 0, &dw );
pi2 = (PRINTER_INFO_2 *)GlobalAllocPtr( GHND, dw );
GetPrinter( m_hPrinter, 2, (LPBYTE)pi2, dw, &dw );
// set the new printer info structure
pi2->pDevMode = lpDevMode;
SetPrinter( m_hPrinter, 2, (LPBYTE)pi2, 0 );
GlobalFreePtr( pi2 );
// notify applications that the default DEVMODE has changed
SendMessageTimeout( HWND_BROADCAST, WM_DEVMODECHANGE, 0, (LPARAM)szPrinter,
SMTO_NORMAL, 1000, NULL );
Re: SetLandscape
Posted: Mon Jun 14, 2021 10:26 pm
by Otto
Hello Antonio, hello Mr. Rao,
The first tests with Rundll32 and the PRINTUI.DLL work.
I have to call rundll32.exe with WINEXEC but it works.
If it were possible, I would prefer to be able to make the change with Fivewin.
Best regards,
Otto
Code: Select all | Expand
function hochformat()
winexec('RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Sr /n "Seminar" /a "c:\setprnter\Seminarhoch.dat"')
return nil
function landscape()
winexec('RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Sr /n "Seminar" /a "c:\setprnter\Seminar.dat"')
return nil
function Setdefault()
winexec('RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /y /n "Seminar"')
return nil
Re: SetLandscape
Posted: Thu Jun 17, 2021 3:41 pm
by Otto
Hello friends,
Switching between landscape and portrait is working fine now
Best regards,
Otto
