|
Hi,
How can i take a screen shot of my screen ... (vc++)
and what the best method..
Sameer
|
|
|
|
|
Well, it's probably not the *best* method, but if you do an ALT-PrintScreen, you can then paste a bitmap of the active window into Paint/PSP/Photoshop/Your favorite graphics program.
I know there are programs out there that make screenshots a painless process, but I must enjoy the pain of manually taking them, because I have no idea what those programs are.
Jon Sagara
"Did you bring the butfor?"
"What's a butfor?"
"To poop with, silly."
|
|
|
|
|
If you mean programatically, if you're using MFC, CWindowDC screen(NULL);, then you can blt it to the bitmap of your choice. Otherwise create a DC with the string "DISPLAY" in Win32.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Dear,
I am a student of Computer Sciences. I need some help regarding Network Interface Card.
I have two network cards installed in my system. I want to make a program which should assign single IP to both cards. I have two independent networks attatched with one machine. One network is attatched with NIC1 and other is with NIC2. I want both network to send data over one IP address. Can anyone help me to build such application.
If anyone can guide in such application, please do it.
your help will be highly appreciable
Fakhar
|
|
|
|
|
Write your own (kernel-mode) driver. Using the same IP for two NIC's in one machine just doesn't makes sense. Actually, it's worse, since you couldn't select what interface to e.g. bind() to!
Perhaps you could explain what you _really_ want to do, and maybe a solution will surface?
|
|
|
|
|
Hi.
I just found a major multithread bug a program I working on. First, I will describe the process that is causes the major multithread problem.
-----
- user opens a text file (any size) w/ text only
- user clicks an option in the menu
- view has a executes its message handler for the menu item
- view calls a function in doc
- doc begins a new thread (thread includes CSinglelock + CriticalSection, data from doc)
- thread resumes and begins processing the data
- when done, thread *PostMessage* mainframe that is done ::: -> AfxGetMainWnd->PostMessage(WM_USER_THREAD, 0, 0);
- main frame *SendMessage* to view ::: -> pView->SendMessage(WM_USER_THREAD, 0, 0)
- view calls a function in doc to close thread
- doc class this function
-----
////
// This function is called to close a thread
//
m_bThread = true; // meaning thread is still active
if (m_pThread && m_hThread) // m_hThread is a HANDLE to the thread
{
::WaitForSingleObject(m_hThread, INFINITE);
delete m_pThread;
m_pThread = NULL;
m_hThread = NULL;
m_bThread = false; // meaning thread has been closed
SetModifiedFlag(TRUE);
}
UpdateAllViews(NULL);
-----
Okay. Everything works good *if the use does not click anything* during the process. In other words, if the user were to click the menu or anything inside the window, the program would malfunction.
Notice the bool "m_bThread." I use it as an indicator about the status of the thread. if m_bThread is true, meaning that the thread is active, the program disables many options in the menu. These options will remain disabled unless m_nThread is false. For some reason, that variable remains *true* if the user starts clicks anyone in the menu or view processing. That means something is keeping the program to ever setting m_Thread to false. On the other hand, if the user does not click anything until after the process is over, everything works as planned.
I have no idea what is going on in the background. Is there a design flaw anywhere?
Thanks,
Kuphryn
|
|
|
|
|
kuphryn wrote:
::WaitForSingleObject(m_hThread, INFINITE);
This doesn't close a thread, it simple waits for thread to end. My guess is that you have deadlock occuring between your worker thread and the main app thread.
Does the thread function itself end? Is the thread doing any UI stuff?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks.
The worker thread communicates with the main thread (UI) on two occassions. It *SendMessage* main to update a progress bar. It *PostMessage* main, which *SendMessage* to view, which calls a function in doc to "close" the thread. When I said close, I am talking about the same function I originally posted above.
I still have no idea what is causing the program to not respond if the user starts click different part of the program. The only thing I can think of is that main ignores the message from the worker thread to close it.
Kuphryn
|
|
|
|
|
Using SendMessage from one thread to another is a very bad idea. Try either removing that or changing it to PostMessage and see if the problem is resolved.
I don't understand why the worker thread is asking the main thread to close it, but that is another issue entirely.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks.
First, the only time the worker thread *SendMessage* to main thread (UI) is to update the progress bar. Prosise's actually uses *SendMessage* in the image view program in his book. I wonder why he uses *SendMessage* for the progress bar and *PostMessage* after the worker thread closes.
I tried implementing *both* *PostMessage* and *SendMessage*. I ran into the exact same program.
Kuphryn
|
|
|
|
|
If your thread is a Worker Thread and not a UI Thread then it is safe to use SendMessage, but I still would use PostMessage. There is usually no reason why the thread should stop and wait for something to be processed in the main thread, which will happen if you use SendMessage.
Run your app under the Debugger and when you have the problem break into the debugger and look at each of threads and see what they are doing. You can select a Thread on the Debug menu and then look at its Stack Backtrace etc. This should help you to see where the problem is.
ED4W makes heavy use of threads and you can spend a lot of time sorting out multithreading problems, especially when you haven't done much multithreading before. Unfortunately MFC makes life more difficult than it needs to be for multithreaded apps.
There are lots of good articles around on Multithreading including some on this site if my memory serves me correctly.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks.
I have no experience using degugging tools such as Spy++, which a member mentioned at Anandtech, and the tool to monitor a specific thread in Visual C++.
Can you give me a quick walkthrough? I just need the order such as "1) select this 2) begin 3) look."
Kuphryn
|
|
|
|
|
kuphryn wrote:
I have no experience using degugging tools such as Spy++, which a member mentioned at Anandtech, and the tool to monitor a specific thread in Visual C++.
Can you give me a quick walkthrough? I just need the order such as "1) select this 2) begin 3) look."
I'm afraid I don't have the time to teach you how to use the VC++ Debugger. Have a read of the Help, that should be enough to get started. There is also a good book by John Robbins called "Debugging Applications" MS Press and no doubt lots of stuff on the Web and in the MSJ Articles. John Robbins writes a regular column in MSJ/MSDN.
You absolutely have to know how to use the VC++ Debugger if you want to do any serious development work, especially if you are multithreading.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
|
Hi.
I believe I have figured out the problem. Here is a scenario. Let say you have a program with splitter window. There are two views and both are CEditView. Let say the top view calls a worker thread. While the worker thread is active, you focus the lower view and begin typing. What is the chance that the worker thread will never get deleted?
I just simulated the scenario above using a very simple program with a progress bar. If I focus on another window wile the progress bar is active, the program will not delete the progress bar, period.
I can upload the source code to that simple simulation anyone wants to see it.
Thanks,
Kuphryn
|
|
|
|
|
Kuphryn, I think that you should spend some time reading about multithreading. "Win32 Multithreaded Programming" by Cohen & Woodring is one book worth reading. Also study the articles on the Microsoft Web site.
I'm afraid you haven't got much of hope with multithreading until you have a very good understanding of all of the basic issues, and know how to use the VC++ Debugger.
I don't see what switching views has to do with whatever your worker thread is doing. If you want to post your sample code then by all means do so.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I copied the code at "Re: using locale, numpunct, num_put to format number with ',' thsnds separator" to try. I also downloaded the Appedix-D Locale from Bjarne Stroustrup's site, and copied example at Section 4.2.1 Numeric Punctuation to try. None of both could compile!
The error message while compiling example found at Usenet:
error C2039: 'numpunct<char>' : is not a member of 'locale'
d:\program files\microsoft visual studio\vc98\include\xlocale(20) : see declaration of 'locale'
error C2664: '__thiscall std::locale::std::locale(const char *,int)' : cannot convert parameter 1 from 'class std::locale' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
And this is the error message while compiling Bjarne's example:
error C2664: '__thiscall std::locale::std::locale(const char *,int)' : cannot convert parameter 1 from 'class std::locale' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Maxwell Chen
|
|
|
|
|
I dunno what the state of iostreams is in the stuff that comes with VC, but I'd be inclined to install the STLPort, which now has an IOStreams implimentation included.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
What is STLPort? Can I program windows apps with this, as I do using VC++6 ? Where can I find it?
Maxwell Chen
|
|
|
|
|
1. A much better version of the STL
2. But of course, it's just another implimentation of parts of the std library. In fact they've even written it so there is a version that deals with VC's pathetic excuse for template support.
3. www.stlport.org, from memory
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi Maxwell, VC++ supports very defficiently this part of the standard library. The following modified version of the original sample compiles and works fine in VC++ 5.0 (hopefully it will work also for VC++ 6.0):
#include <iostream>
#include <locale>
#include <string>
using namespace std;
class my_punct:public std::numpunct<char>
{
protected:
char do_thousands_sep() const {return ',';}
std::string do_grouping() const {return "\3";}
public:
my_punct():numpunct<char>(){}
};
int main(){
locale loc = cout.getloc();
locale new_loc=_ADDFAC(loc,new my_punct);
cout.imbue(new_loc);
cout <<1000000 << endl;
cout.imbue(loc);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you, Joaquin. It works in VC++6. But I could not find anything mentioning _AddFac() in MSDN2000...
And how should I do to cause printf(), sprintf(), CString::Format(), etc., change also ??
Maxwell Chen
|
|
|
|
|
Thank you, Joaquin. It works in VC++6. But I could not find anything mentioning _AddFac() in MSDN2000...
Look at the documentation for locale::locale (the ctor for locale .)
And how should I do to cause printf(), sprintf(), CString::Format(), etc., change also ??
Not sure. Try with setlocale .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
If in one thread the socket gets blocked in the WSAWaitForMultipleEvents() while in another thread
it cleans up the winsock library, what will happen?
|
|
|
|
|