|
Sandeep,
This is wrong forum for this question. Ask it in VC++ forum ,instead.
Prasad
MS MVP - VC++
|
|
|
|
|
When performance is not an issue and when all that we want is just a snapshot of the desktop, we can consider the GDI option. This mechanism is based on the simple principle that the desktop is also a window - that is it has a window Handle (HWND) and a device context (DC). If we can get the device context of the desktop to be captured, we can just blit those contents to our application defined device context in the normal way. And getting the device context of the desktop is pretty straightforward if we know its window handle - which can be achieved through the function GetDesktopWindow(). Thus, the steps involved are:
Acquire the Desktop window handle using the function GetDesktopWindow();
Get the DC of the desktop window using the function GetDC();
Create a compatible DC for the Desktop DC and a compatible bitmap to select into that compatible DC. These can be done using CreateCompatibleDC() and CreateCompatibleBitmap(); selecting the bitmap into our DC can be done with SelectObject();
Whenever you are ready to capture the screen, just blit the contents of the Desktop DC into the created compatible DC - that's all - you are done. The compatible bitmap we created now contains the contents of the screen at the moment of the capture.
Do not forget to release the objects when you are done. Memory is precious (for the other applications).
Void CaptureScreen()
{
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(hDesktopWnd);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,
nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,
hDesktopDC,0,0,SRCCOPY|CAPTUREBLT);
SaveCapturedBitmap(hCaptureBitmap); //Place holder - Put your code
//here to save the captured image to disk
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
}
In the above code snippet, the function GetSystemMetrics() returns the screen width when used with SM_CXSCREEN, and returns the screen height when called with SM_CYSCREEN. Refer to the accompanying source code for details of how to save the captured bitmap to the disk and how to send it to the clipboard. Its pretty straightforward. The source code implements the above technique for capturing the screen contents at regular intervals, and creates a movie out of the captured image sequences.
In consideration to the above code please let me know how to capture the network PC`s desktop to my software..
I want to capture it continously i dont want to save it, i want it`s Rectangular Area in ma software...
Please let me know how to do this(of course sockets are used) or create a method for this...
|
|
|
|
|
HassanKU wrote: In the above code snippet,
In the above snippet there is no C++/CLI. You are in the wrong forum. Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Can someone help me with the link errors in this[^] project.
I was tryin to resolve this from last friday with no success. Would be gr8 if someone can compile this for me without errors. It gives me link errors whenever I use TIFFReadRGBAImage, but once I comment it out there are no errors. Any help...!!
-thanks.
Pavan
|
|
|
|
|
Obviously, you're not linking to the TIFF library properly. If you're using C++/CLI, you have built in tiff support. If you're not using .NET, you can still use GDI+, but you'd then be in the wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all,
will anybody plz tell me what is the meaning of the following error. it has troubled me a lot.
thanx in advance.
AuthXParser error LNK2019: unresolved external symbol "public: __thiscall TinyXPath::xpath_processor::xpath_processor(class TiXmlNode const *,unsigned short const *)" (??0xpath_processor@TinyXPath@@QAE@PBVTiXmlNode@@PBG@Z) referenced in function "public: class XMLNodeList __thiscall XMLNode::selectNodesW(unsigned short const *)" (?selectNodesW@XMLNode@@QAE?AVXMLNodeList@@PBG@Z)
|
|
|
|
|
It looks like you forgot to add the proper library in the linker command line.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello everyone,
I'm want to build a Gpib drivers for an Agilent instruments.
Now...I want it to be a "class a-like" driver , for example if the user wants to set a center frequency of 100MHz in a spectrum driver it will look like this:
...
// defenition
Agilent_Spectrum spectrum;
// initialization
spectrum.init(9);
// send a frequncy
spectrum.frequncy.center.MHz=100;
...
The question is : can I do it without using classes ?
|
|
|
|
|
Using just plain C you can do whatever you want. It's enough to you, isn't it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The answer would be, if you're not using classes, you're probably not using C++/CLI, so you must be asking in the wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
(I do work in c++, and I do know how to use classes...classes is the answer for my problem but it's a lot of work).
I didnt say that Im not using classes...I said I want to do it without using classes...meaning:
the question is "can I do it in a simple and more primitive way ?" maybe something like "namespace" or structures ?
|
|
|
|
|
Yes, I can see that you're working in C++, but, again, this is the C++/CLI forum, and you are not using C++/CLI as far as I can see.
Of course you can write anything you like without using classes, just like I can walk to the store instead of driving. You are not forced to use the tools that make yuor job easier.
Oh, and a struct IS a class, they are the same thing, the only difference is the default access modifier.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I made my algorithm in visual c++2005, now I want to do an interface in VC++2005 to this algorithm but the code has only functions not classes or something like this and I put my functions in the main application source file(forminterface.cpp) ...a short example is written like this...:
#include "stdafx.h"
#include "Form1.h"
using namespace forminterface;
.................
void prepareitems(item *f, item *l, int *w, int *h, int *d, int *ra, int *rb, int *rd)
{
item *i;
int k;
for (i = f, k = 0; i != l+1; i++, k++) {
w[k] = i->dx; h[k] = i->dy; d[k] = i->dz;
ra[k]=i->rx;rb[k]=i->ry;rd[k]=i->dz;
}
}
..............
[STAThreadAttribute]
int main(array<system::string ^=""> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
I want to call this function in my "start button"(private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e) {} ......of the interface but I don't know how or if I must declare this function in other place because it give me error like"prepareitem is not a member of global namespace"....please help me I am disperate ...I don't know where to put the functions of my algorithm and in this way to make the conection with my interface...
lavi
|
|
|
|
|
Looks to me like it's not visible from where you call it ( assuming that it's prepareitems and not prepareitem in the error ). Why not wrap this in a class, so you have a header file you can include to make it visible ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't know how to do this ...I go to Source file->add class->visual c++(c++ class)->and I create a new class and a new header like this?
#include "StdAfx.h"
#include "gt.h"
gt::gt(void)
{
}
#pragma once
ref class gt
{
public:
gt(void);
};
how can I call this function or this class in my ...StartPackingbutton:
private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e)
{.........?}....please help me if you know...
|
|
|
|
|
#include "gt.h"
Assuming the method is static:
gt.MyMethod(whatever);
If you don't know how to call a method in a class, I recommend buying a book on C++ and working through it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello ,
This piece of code is meant to browse for a file , display the path and display the content , its browsing but not displaying the filepath and content , can anyone help with this?
OpenFileDialog^ fileChooser = gcnew OpenFileDialog();
try{
fileChooser->InitialDirectory = "C:\\My Documents";
}
catch( ... ){
MessageBox::Show("No C:\\ drive", "Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
fileChooser->DefaultExt = "*.rtf";
fileChooser->Filter ="Rich Text Format (*.rtf)|*.rtf|"
"Text Files (*.txt)|*.txt|"
"All Files (*.txt; *.rtf)|*.txt;*.rtf;";
fileChooser->FilterIndex = 1;
Windows::Forms::DialogResult result = fileChooser->ShowDialog();
if(result == System::Windows::Forms::DialogResult::OK)
return;
//get specified file name
fileName = fileChooser->FileName;
//show error is user specified invalid file name
if(fileName=="")
{
(MessageBox::Show("Invalid File name","Error!", MessageBoxButtons::OK, MessageBoxIcon::Error)); } else
{
file_richTextBox->Text ="";
ReadFileInfo(fileName);
}//end of else
}//end of browseButton_Click
try{
input = gcnew FileStream(filenam, FileMode::Open, FileAccess::Read);
FileInfo^ fInfo = gcnew FileInfo(filenam);
//Display filepath
String^ fname = fInfo->FullName;
file_textBox->Text = fname;
//Check file extension and load file info
fname = fInfo->Extension->ToLower();
if (fname->Equals(".rtf"))
file_richTextBox->LoadFile(input, RichTextBoxStreamType::RichText);
else
file_richTextBox->LoadFile(input, RichTextBoxStreamType::PlainText);
input->Close();
}
catch( ... ){
MessageBox::Show(String::Format("{0} is not a valid text file.", filenam),
"Error!", MessageBoxButtons::OK , MessageBoxIcon::Error);
}
}
d
|
|
|
|
|
Debun wrote: if(result == System::Windows::Forms::DialogResult::OK)
return;
How do you think it'll work if you return when the user clicks OK? Perhaps you meant to do a != check?
Regards,
Nish
Fly on your way like an eagle
Fly as high as the sun
On your wings like an eagle
Fly and touch the sun
|
|
|
|
|
hi
i am writing a program using linked list and binary input/output
but i dont have any sample code for geting started with
can any one help me with sample c++ code for this program?
hari
|
|
|
|
|
If you're using C++/CLI ( and if you're not, you're in the wrong forum ), you can still use STL, and the STL list class ships with full source.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I was wondering how to totally take out the title bar windows uses and replace it with a new one in a program like winamp and sonic recordnow does.
|
|
|
|
|
Using .NET ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yanshof wrote: I try to use some MFC class
Odds are then high that you're not using C++/CLI. Try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Can I code in C or C++ for the Macintosh? I have borland tools. I also have Visual C++ in the Visual Studio, but have never used it. thanks, joeinorange2@aol.com
Joe Sharp
|
|
|
|
|
Why not? Apple claims a Mac does everything better than a PC, and a Mac has everything you will ever need preinstalled. By the way, you are in the wrong forum since this is the "C++/CLI" forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|