|
I found a sort of solution:
I get the pixels from the screen with GetPixel().
First : HDC im = GetDC(hwnd);
And the something like:
kleur = GetPixel(im, x, y);
rood = (int) GetRValue(kleur);
groen = (int) GetGValue(kleur);
blauw = (int) GetBValue(kleur);
SetPixel(hPrinter, x, y, RGB(rood, groen, blauw));
But it looks it delivers verry small images...
So any other tips will be welcome... Thx !
|
|
|
|
|
For a rectangular region of pixels, there's no need to copy a pixel at a time.
You can use something like StretchBlt() instead.
Most modern printers (and thus their DCs) have a much larger dots-per-inch (DPI) value
than screens, so you should use GetDeviceCaps() to get the HORZRES/VERTRES and/or
LOGPIXELSX/LOGPIXELSY values for the printer DC so you know what dimensions to
stretch the captured pixels to.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use of StretchBlt or BitBlt and you need to handle (hdc) of printer.
|
|
|
|
|
I've got an application that runs on several computers which handles simultaneous video capture (to be clear, each system runs it's own copy of the capture software). I've got another application that runs on another computer and is used to control capture software that is running on the other systems.
Currently, the capture software uses the winsock call "listen" to listen for incoming connections on a specific port. When I want to connect to the capture systems from the control system, I use the winsock call "connect" to make the connection. Currently, I cycle through a list of possible capture machines and attempt to connect to each one, however, the capture systems may or may not be running the capture software. Because connect doesn't allow me to specify a timeout, this connection process can take an extremely long time if even a single capture system is powered down or isn't running the software.
So my question is:
Is there a way to check to see if a system is listening for a connection before I call connect? Or, is there a better way to handle establishing connections between my machines.
Thanks,
Adam Kraver
|
|
|
|
|
Unfortunately you can't find out if a TCP port is open other than trying it. However there some design you could give a try:
- time out the connect call or use a socket library that can
- use a separate protocol to check availability, this could be the control system actively checking the hosts or the hosts sending an "hey I am alive" message in regular intervals
- use more than one client on the control system to compensate for delays
Hope it helps
/M
|
|
|
|
|
I would like to be able to reuse a project created in Visual Studio 6.0 in the latest Visual C++ 2008 Express package, but when compiling, I get this error message:
Compiling...
StdAfx.cpp
c:\myprojects\my projects\slammers\stdafx.h(16) : fatal error C1083: Cannot open include file: 'afxext.h': No such file or directory
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version 9.00.21022
What is the proper way (if it exists) to reuse projects?
thank you.
|
|
|
|
|
Question 31:
Does Visual C++ 2008 Express Edition include MFC and ATL?
Answer:
No, MFC and ATL are not included with Visual C++ 2008 Express. MFC and ATL will be included in Visual Studio 2008 Standard and above editions.
http://www.microsoft.com/express/support/faq/[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hello everyone,
Here is my precompiled header settings,
--------------------
Create/Use PCH Through File stdafx.h
PreCompiled Header File .\Debug/client.pch
--------------------
1.
It means all the content before stdafx.h will be precompiled into client.pch? So that each time compiler "assumes" the content before stfafx.h will not be changed. Right?
2.
How will compiler solve this situation?
#include "foo.h"
#include "stdafx.h"
#include "goo.h"
#include "stdafx.h"
Compiler will pre-compile foo.h, goo.h and stdafx.h into one client.pch file? Or pre-compile foo.h + stdafx.h into one file, and pre-compile goo.h and stdafx.h into another file?
thanks in advance,
George
|
|
|
|
|
The compiler will ignore the included file above stdafx.h...
You should get a warning as well, something like
warning C4627: '#include <foo.h>': skipped when looking for precompiled header use
To do something like that negates the usefulness of a precompiled header anyway....why would you do it?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
I am reading MSDN definition for the file name parameter from,
http://msdn2.microsoft.com/zh-cn/library/7zc28563(en-us).aspx
[^]
here is the meaning for the file parameter from MSDN,
--------------------
Specifies a header (.h) file. When this argument is used, the compiler
compiles all code up to and including the .h file.
--------------------
For exmaple, we have a file like this,
include "stdafx.h"
1. Does it mean when we compile the file, only stdafx.h and section 2 are compiled?
2. Or does it mean when compiler do the precompile, section 1 and stdafx.h will be pre-compiled into some .pch file?
regards,
George
|
|
|
|
|
Hi,
AFAIK, it is a rule that every cpp file in program should include "stdafx.h" and also it should be in the first line before including any other header.
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
|
Hi,
I am not sure, I think as Mark said, whatever in the "section1" will be ignored and remaining will be compiled.
You can check it by using some mathmatics functions in your cpp file and include the "math.h" before "stdafx.x", you may get error.
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Thanks Suman,
For the pre-compile phase to generate pre-compiled headers (.pch), is only stdafx.h used to generate the client.pch or both section 1 and stdafx.h are used to generate the client.pch?
(you can check my original post for more details about context)
regards,
George
|
|
|
|
|
There's a third compiler option you need to work with here
/Yc Create precompiled header
/Yu Use precompiled header
If you look closely at the settings for a wizard-generated Visual C++ project,
ONE source file uses the /Yc option to create the precompiled header....this is typically
stdafx.cpp. All the other source files use the /Yu compiler option, to use the precompiled
header.
The "Create/Use PCH through file" option has two uses -
1) when used with /Yc, it specifies the file to stop precompilation on (at the end of)
2) when used with /Yu, it specifies the file to replace with the precompiled header
This has the following effects if "stdafx.h" is the "Create/Use PCH through file" setting:
1) For the file compiled with the /Yc option, everything included before and through the stdafx.h file
is compiled into a precompiled header file.
2) For any files compiled with the /Yu option, everything included before and through the stdafx.h file
is ignored and replaced with the precompiled header file.
Hopefully I explained that OK.
More info here: /Yu (Use Precompiled Header File)[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark!
I read through the wonderful reply and information referred by you. I think in my case, I need to creat two pre-compiled files since for each source file, the pre-compiled information are different, right?
regards,
George
|
|
|
|
|
George_George wrote: I think in my case, I need to creat two pre-compiled files since for each source file, the pre-compiled information are different, right?
First, I'm not sure how well that works, but you could easily try it.
But a precompiled header is really meant for common definitions - e.g. CRT headers, Windows SDK headers, app-common classes, etc.
For anything that varies between source files, those should be included separately, and in fact, must be.
The precompiled header is available just for efficiency, so the compiler doesn't have to waste extra time compiling the same
exact items for every source file.
I personally have never encountered a case where I needed to have more than one PCH file like you're showing, with differing
include files above the precompiled header.
The standard PCH usage...
...#includes and definitions used by all modules go in here
#include "stdafx.h"
#include "stdafx.h"
#include <math.h>
#include <vfw.h>
...
#include "stdafx.h"
#include <vector>
#include <string>
... ...always works fine for me.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your advice, Mark!
I think I need to merge them into one pch file.
regards,
George
|
|
|
|
|
Hi I would like to Know the steps reqd to connect from VC++9 to oracle?
Cheers
|
|
|
|
|
|
Hi all,
I m working on VC++2005, and my application is SDI type.
when i run my application in MENUBAR the option of Print and print preview are disabled.
any one can tell me how can enable them.
Thanks in advance
|
|
|
|
|
Hi,
Is this discussion helpful: print handler[^]?
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Hi all,
i have an problem in load icon for sub-dialog box.
i want to show main application icon on subdialog box or internal dialog box of application.
i m using this.
HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
where IDR_MAINFRAME is icon of main application.but it not works.
anyone can help me.
thanks in advance
|
|
|
|
|
Hi,
Are you calling SetIcon() to set the loaded icon or not?
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
thanks. now my problem is resolved
|
|
|
|