Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » GetDefaultPrinter Call does not compile
GetDefaultPrinter Call does not compile [message #30207] Wed, 15 December 2010 16:20 Go to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Please, could you help me compilling this little example app:


#include <CtrlLib/CtrlLib.h>
#include <winspool.h> 
using namespace Upp;
 
struct MyAppWindow : TopWindow 
{
    virtual void Paint(Draw& w) 
    {
        w.DrawRect(GetSize(), SWhite);
        w.DrawText(20, 20, "Hello world!", Arial(30), Magenta);
    }
    
    MyAppWindow() 
    {
        Title("My application").Zoomable().Sizeable();
        
        
        char szPrinterName[255];
        unsigned long lPrinterNameLentgth;
        
        int ret=GetDefaultPrinter(szPrinterName,&lPrinterNameLentgth );
        if(ret==0)
        {
            DWORD dwErr = ::GetLastError();
            char e[100];
            sprintf(e,"%d",dwErr);

            MessageBox(NULL, "GetDefaultPrinter Error", e,MB_ICONINFORMATION);
        }
    }
};
 
GUI_APP_MAIN
{
    MyAppWindow app;
    app.SetRect(0, 0, 200, 100);
    app.Run();
}



The compiler says:
C:\upp\MyApps\ppp\main.cpp: In constructor 'MyAppWindow::MyAppWindow()':
C:\upp\MyApps\ppp\main.cpp:21: error: 'GetDefaultPrinterA' was not declared in this scope
C:\upp\MyApps\ppp\main.cpp:29: error: returning a value from a constructor


This is just a test application.

Thank you

JoseB


[Updated on: Wed, 15 December 2010 16:22]

Report message to a moderator

Re: GetDefaultPrinter Call does not compile [message #30211 is a reply to message #30207] Wed, 15 December 2010 21:47 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Just add winspool library.

So:
- Select your package
- Do right click or select menu Project
- Choose Package Organizer
- In right side blank area do right click
- Choose New Libraries...
- Fill WIN32 in the left field and winspool in right field
- Push Ok
- Push Ok

Thats all. Here there is a screenshot:

index.php?t=getfile&id=2986&private=0
  • Attachment: dib.PNG
    (Size: 27.76KB, Downloaded 824 times)


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30213 is a reply to message #30207] Wed, 15 December 2010 23:38 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Ok. Thank you
(I thought it was a compiler error and not a linking error)

JoseB

[Updated on: Wed, 15 December 2010 23:39]

Report message to a moderator

Re: GetDefaultPrinter Call does not compile [message #30217 is a reply to message #30213] Thu, 16 December 2010 09:05 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Yes you are right. You got that message from the compiler (MinGW) before adding the line:
#include <winspool.h>

Including winspool as include and lib solves it all Smile.


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30227 is a reply to message #30217] Thu, 16 December 2010 17:42 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
I am still getting the same error even after adding the include and the lib references Sad


JoseB
Re: GetDefaultPrinter Call does not compile [message #30228 is a reply to message #30227] Thu, 16 December 2010 19:41 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Sorry, I only got a linking error that was fixed by adding the library.

Could you post more details about your U++ version and Windows version?
Re: GetDefaultPrinter Call does not compile [message #30229 is a reply to message #30228] Thu, 16 December 2010 22:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Try this.
  • Attachment: kk.7z
    (Size: 0.75KB, Downloaded 304 times)


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30237 is a reply to message #30207] Sat, 18 December 2010 03:35 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
I tried the kk.7z and the error still exists.
I am compiling in windows 7 and upp 2901

Please, could you create a little program from the ground upp console or dialog to try it im my environment?

Thanks

JoseB
Re: GetDefaultPrinter Call does not compile [message #30245 is a reply to message #30237] Sun, 19 December 2010 21:15 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

What is the compiler output?


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30262 is a reply to message #30245] Tue, 21 December 2010 10:55 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Here it is:


----- CtrlLib ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 9)
----- CtrlCore ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (2 / 9)
----- Draw ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (3 / 9)
----- plugin/bmp ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (4 / 9)
----- RichText ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (5 / 9)
----- Core ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (6 / 9)
----- plugin/z ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (7 / 9)
----- plugin/png ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (8 / 9)
----- kk ( GUI MAIN GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (9 / 9)
main.cpp
C:\upp\MyApps\kk\main.cpp: In constructor 'MyAppWindow::MyAppWindow()':
C:\upp\MyApps\kk\main.cpp:21: error: 'GetDefaultPrinterA' was not declared in this scope
kk: 1 file(s) built in (0:04.06), 4065 msecs / file, duration = 4125 msecs, parallelization 0%

There were errors. (0:04.90)



JoseB
Re: GetDefaultPrinter Call does not compile [message #30271 is a reply to message #30262] Tue, 21 December 2010 14:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Find file "winspool.h" and #include it in source.


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30274 is a reply to message #30271] Tue, 21 December 2010 17:10 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Do you means include it physically? Make a copy of it or just use the include directive?

I have this already and the error still exists:

#include <CtrlLib/CtrlLib.h>
#include <winspool.h>
using namespace Upp;

struct MyAppWindow : TopWindow
{
...


JoseB
Re: GetDefaultPrinter Call does not compile [message #30275 is a reply to message #30274] Tue, 21 December 2010 17:17 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

The compiler reports "GetDefaultPrinterA" has not been declared.

However "winspool.h" is included.

So it seems:
- either "winspool.h" is not accessible by the compiler
- or "GetDefaultPrinterA" is not included in "winspool.h". In this case tell me your MinGW version. Perhaps it would be outdated.


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30278 is a reply to message #30275] Tue, 21 December 2010 17:46 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Version 2901...

May it be a UPP bug?


JoseB

Re: GetDefaultPrinter Call does not compile [message #30290 is a reply to message #30278] Wed, 22 December 2010 09:39 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Quote:

- either "winspool.h" is not accessible by the compiler
- or "GetDefaultPrinterA" is not included in "winspool.h". In this case tell me your MinGW version. Perhaps it would be outdated.


Please first search in your MinGW include files if "winspool.h" is there.


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30291 is a reply to message #30290] Wed, 22 December 2010 11:14 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Yes, "winspool.h" is there.


JoseB
Re: GetDefaultPrinter Call does not compile [message #30293 is a reply to message #30291] Wed, 22 December 2010 12:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

Please check:

- Is "c:\upp\mingw\include" in Setup/Build Methods/MINGW/Include Directories menu?

- Does "c:\upp\mingw\include\winspool.h" contains GetDefaultPrinterA?



Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30294 is a reply to message #30293] Wed, 22 December 2010 12:28 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Yes, it is in the menu. See img in attachment.

In the c:\upp\mingw\include\winspool.h i have the entries in img in attachment (for you to see line numbers)



JoseB
  • Attachment: MinGW_Incs.png
    (Size: 71.69KB, Downloaded 314 times)
  • Attachment: lines.png
    (Size: 30.40KB, Downloaded 317 times)
Re: GetDefaultPrinter Call does not compile [message #30299 is a reply to message #30294] Wed, 22 December 2010 14:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello JoseB

I do not know what to answer you Sad.

- You have XP or newer windows
- You have "c:\upp\mingw\include\winspool.h"
- And you have in your source:
#include "c:\upp\mingw\include\winspool.h"

or
#include <winspool.h>


I do not understand the compiler error:
C:\upp\MyApps\kk\main.cpp:21: error: 'GetDefaultPrinterA' was not declared in this scope


If you want, open a "TeamViewer" session for me to see in my browser your Desktop. It is like VNC but simple to install and immune to firewalls and proxies.


Best regards
Iñaki
Re: GetDefaultPrinter Call does not compile [message #30301 is a reply to message #30299] Wed, 22 December 2010 14:24 Go to previous message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Can you tell me a email of you to send you the team viewer credentials? (gmail one to GTalk if necessary?)

(imoveisnacionais@gmail.com)

Can we schedule the operating 1 hour later? Here it is 13:33. Can we make that at 14:30h?


JoseB

[Updated on: Wed, 22 December 2010 14:37]

Report message to a moderator

Previous Topic: Could RichEdit print using default selected printer?
Next Topic: public Ctrl in my class - param in constructor problem
Goto Forum:
  


Current Time: Thu Mar 28 17:43:19 CET 2024

Total time taken to generate the page: 0.01490 seconds