*** Curso de C para programadores Harbour.
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello friends,
To finish HTML report generator, I would need to change printer default from landscape to portrait and vice versa.
I found some C++ code. Maybe you could work on that in your course?
viewtopic.php?f=3&t=40526&p=242221&hilit=landscape&sid=ca5535308805b297ab04c27df561e23b#p242221
https://www.amyuni.com/forum/viewtopic.php?t=1224
Best regards,
Otto
To finish HTML report generator, I would need to change printer default from landscape to portrait and vice versa.
I found some C++ code. Maybe you could work on that in your course?
viewtopic.php?f=3&t=40526&p=242221&hilit=landscape&sid=ca5535308805b297ab04c27df561e23b#p242221
https://www.amyuni.com/forum/viewtopic.php?t=1224
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Claro que sí Juan...
Y serás muy bienvenido!!!
Y serás muy bienvenido!!!

______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hola Otto.
Para el curso haremos interfaces con una DLL.
Esa DLL será una de SQLite ya que quiero desarrollar una clase básica para acceder a SQLite.
De cualquier modo dame más información por si puedo ayudar...
Para el curso haremos interfaces con una DLL.
Esa DLL será una de SQLite ya que quiero desarrollar una clase básica para acceder a SQLite.
De cualquier modo dame más información por si puedo ayudar...
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hola Otto prueba esto:
Mételo en donde tengas tu programa en C ya que veo que usas variables estaticas.
Code: Select all | Expand
// Asigna orientacion desde C
short prnSetOrientation( short dmOrientationNew )
{
LPDEVMODE lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
short dmOrientationOld = lpDevMode->dmOrientation;
lpDevMode->dmOrientation = dmOrientationNew;
ResetDC( pd.hDC, lpDevMode ) ); // Creo que te faltaba esto para que la parte hardware de la impresora se entere
GlobalUnlock( pd.hDevMode );
return dmOrientationOld;
}
// Asigna orientacion desde PRG
HB_FUNC( PRNSETORIENTATION )
{
short dmOrientationNew = hb_parnidef( 1, 0 );
hb_retni( prnSetOrientation( dmOrientationNew ) );
}
Mételo en donde tengas tu programa en C ya que veo que usas variables estaticas.
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello Manuel,
Thank you for your help.
At the moment I call up DAT files saved with RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry to change the orientation.
I wanted to call the new function PRNSETORIENTATION (1), but I get errors when compiling and linking.
Can you please show me how I can insert the function in FW.
Best regards,
Otto
Thank you for your help.
At the moment I call up DAT files saved with RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry to change the orientation.
I wanted to call the new function PRNSETORIENTATION (1), but I get errors when compiling and linking.
Can you please show me how I can insert the function in FW.
Best regards,
Otto
Code: Select all | Expand
#include "FiveWin.Ch"
function Main()
Setdefault()
hochformat()
landscape()
return NIL
//----------------------------------------------------------------------------//
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
/*
#pragma BEGINDUMP
// Asigna orientacion desde C
short prnSetOrientation( short dmOrientationNew )
{
LPDEVMODE lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
short dmOrientationOld = lpDevMode->dmOrientation;
lpDevMode->dmOrientation = dmOrientationNew;
ResetDC( pd.hDC, lpDevMode ) ); // Creo que te faltaba esto para que la parte hardware de la impresora se entere
GlobalUnlock( pd.hDevMode );
return dmOrientationOld;
}
// Asigna orientacion desde PRG
HB_FUNC( PRNSETORIENTATION )
{
short dmOrientationNew = hb_parnidef( 1, 0 );
hb_retni( prnSetOrientation( dmOrientationNew ) );
}
#pragma ENDDUMP
*/
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hola Otto la tienes que añadir al archivo printdc.c de FWH
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello Manuel,
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.
I have to see the changes here:

Best regards,
Otto
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.
I have to see the changes here:

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Posiblemente Windows mantenga una configuración para una aplicación y otro para el sistema...
Tendría que investigar.
Tendría que investigar.

______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello Manuel,
I found this code but do not know how to use.
Best regards,
Otto
Once 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.
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 );
I found this code but do not know how to use.
Best regards,
Otto
Once 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.
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 );
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Intentaré mirarlo lo antes posible a ver si se consigue algo...
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Querido Otto, he traducido tu código y lo he aplicado al codigo enviado anteriormente:
Te recuerdo que lo tienes que añadir a printdc.c de FWH
No lo compilo por lo que si hay errores y no lo sabes resolver dimelos
Code: Select all | Expand
void SetStatusDefault( LPDEVMODE lpDevMode )
{
DWORD dw;
HANDLE m_hPrinter = NULL;
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 ) NULL, SMTO_NORMAL, 1000, NULL );
}
prnSetOrientation( short dmOrientationNew )
{
LPDEVMODE lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
short dmOrientationOld = lpDevMode->dmOrientation;
lpDevMode->dmOrientation = dmOrientationNew;
SetStatusDefault( lpDevMode );
GlobalUnlock( pd.hDevMode );
return dmOrientationOld;
}
HB_FUNC( PRNSETORIENTATION )
{
short dmOrientationNew = hb_parnidef( 1, 0 );
hb_retni( prnSetOrientation( short dmOrientationNew ) );
}
Te recuerdo que lo tienes que añadir a printdc.c de FWH
No lo compilo por lo que si hay errores y no lo sabes resolver dimelos
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello Manuel,
Thank you for your help.
Unfortunately, I am not familiar with C functions.
I have inserted your code into printdc.c and integrated this file into my project.
I get the following error message:
Error E2188 C: \ FWH \ source \ winapi \ printdc.c 1228: Expression syntax in function HB_FUN_PRNSETORIENTATION
Warning W8004 C: \ FWH \ source \ winapi \ printdc.c 1229: 'dmOrientationNew' is assigned a value that is never used in function HB_FUN_PRNSETORIENTATION
*** 1 errors in compile ***
Best regards,
Otto
Thank you for your help.
Unfortunately, I am not familiar with C functions.
I have inserted your code into printdc.c and integrated this file into my project.
I get the following error message:
Error E2188 C: \ FWH \ source \ winapi \ printdc.c 1228: Expression syntax in function HB_FUN_PRNSETORIENTATION
Warning W8004 C: \ FWH \ source \ winapi \ printdc.c 1229: 'dmOrientationNew' is assigned a value that is never used in function HB_FUN_PRNSETORIENTATION
*** 1 errors in compile ***
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Ya he visto el problema:
Prueba ahora...
Code: Select all | Expand
void SetStatusDefault( LPDEVMODE lpDevMode )
{
DWORD dw;
HANDLE m_hPrinter = NULL;
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 ) NULL, SMTO_NORMAL, 1000, NULL );
}
prnSetOrientation( short dmOrientationNew )
{
LPDEVMODE lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
short dmOrientationOld = lpDevMode->dmOrientation;
lpDevMode->dmOrientation = dmOrientationNew;
SetStatusDefault( lpDevMode );
GlobalUnlock( pd.hDevMode );
return dmOrientationOld;
}
HB_FUNC( PRNSETORIENTATION )
{
short dmOrientationNew = hb_parnidef( 1, 0 );
hb_retni( prnSetOrientation( dmOrientationNew ) );
}
Prueba ahora...
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hello Manuel,
now I get:
Error: Unresolved external '_GlobalAllocPtr' referenced from C:\WINHOTEL_ENTWICKLUNG_2021\XREPORT\RELEASE\PRINTDC.OBJ
Error: Unresolved external '_GlobalFreePtr' referenced from C:\WINHOTEL_ENTWICKLUNG_2021\XREPORT\RELEASE\PRINTDC.OBJ
Is it a problem, but I use xHarbour?
Can you also show me how to call this new function from FWH?
Best regards,
Otto
now I get:
Error: Unresolved external '_GlobalAllocPtr' referenced from C:\WINHOTEL_ENTWICKLUNG_2021\XREPORT\RELEASE\PRINTDC.OBJ
Error: Unresolved external '_GlobalFreePtr' referenced from C:\WINHOTEL_ENTWICKLUNG_2021\XREPORT\RELEASE\PRINTDC.OBJ
Is it a problem, but I use xHarbour?
Can you also show me how to call this new function from FWH?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
-
- Posts: 768
- Joined: Sun Jun 15, 2008 7:47 pm
- Location: Sevilla
- Been thanked: 5 times
- Contact:
Re: *** Curso de C para programadores Harbour.
Hola Otto modifica esto:
GlobalAllocPtr -> GlobalAlloc
GlobalFreePtr -> GlobalFree
Por otro lado he investigado un poco el tema y creo que he visto algo en el propio Harbour.
GlobalAllocPtr -> GlobalAlloc
GlobalFreePtr -> GlobalFree
Por otro lado he investigado un poco el tema y creo que he visto algo en el propio Harbour.
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía