|
kiran.pinjarla wrote: Should I call another thread showing the dialog and details from the dialog.
Yes.
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.
|
|
|
|
|
Do you really have to spawn a new thread for this?
It depends on how you want your application to react, but you haven't said anything about that yet.
What I'm thinking about is this:
Your dialog box receives some user input that presumably is used for starting the copying process. When the user desires to start the copying process the dialog could probably be dismissed, or simply create another dialog on top of the first one to handle progress information about the copying process. Call ::CopyFileEx() and provide a function pointer to a callback that will be called for updating the progress of the copying process for each file. Inside this callback you can update a progress bar or whatever information you want to show the user.
When the last file has been copied you simply close the progress information dialog and revert to the old dialog, or whatever GUI is beneath it.
This will keep everything in one single thread, the files will be copied and the user notified about the progress.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I have created a class that encapsulates the open session, open request, send request, read response until buffers are empty and the closes the connections. When I create the first instance, everything work perfectly. I then destroy the object and create another object. This time everything seems to be working fine until the code hits the HttpSendRequest routine. At this point it hangs and never returns. All routines and parameters before the call were successful and had valid values. I have noticed a number of other posts related to this but not answers. Any ideas? pls help me
-- modified at 2:51 Friday 25th May, 2007
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
What are different form.h and form.hpp???
|
|
|
|
|
ashost07 wrote: What are different form.h and form.hpp???
here[^] are some answers.
|
|
|
|
|
How to rasie a exception that can only be caught by __try/__except, but cannot be caught by try/catch?
In a Windows application written by VC. What time to use structured exception instead of C++ exception?
|
|
|
|
|
In standard C++ try /catch can only catch C++ exceptions: that is only exceptions that are raised by the C++ throw statement. Unfortunately some version of Microsoft Visual C++ (6.0 and below) do not follow the standard in this regard. This was fixed in later versions but the old non-standard behaviour can be selected with the /EHa[^] switch (not a good idea in general).
__try /__except is a low level construct and can catch any exception. Note however that with __try /__except the destructors of objects on the stack as it is unwound are not called, so this construct doesn’t play nice with C++. It will break the RAII pattern for example.
To explicitly raise a C++ exception use the C++ throw keyword.
To explicitly raise an exception (not a C++ exception) you have two options:
1. Do something wrong! For example to raise a divide by zero exception try to divide by zero; to raise an access violation attempt to access an invalid memory location.
2. Use the Win32 RaiseException[^] function.
Steve
|
|
|
|
|
Stephen Hewitt wrote: so this construct doesn’t play nice with C++.
Excellent reply. Where were you when I learned that the hard way?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
But in my testing program, all kinds of exceptions including zero-dividing or NULL pointer can be caught by catch(...). Why? Does that mean we can always use C++ try/catch in C++ programs?
|
|
|
|
|
Lane Yu wrote: But in my testing program, all kinds of exceptions including zero-dividing or NULL pointer can be caught by catch(...). Why? Does that mean we can always use C++ try/catch in C++ programs?
As my previous post indicated, the fact that you can use try /catch to catch NULL pointer references and zero-dividing indicates that:
- You're using an old and non-standard compiler such as Microsoft Visual Studio 6.
- You're using a compiler with a non-standard extension with enables this non-standard behaviour; such as the later Microsoft compiler's /EHa switch.
In standard C++ try /catch can NOT catch these exceptions!
Steve
|
|
|
|
|
Thank you. I'm using VC6.
|
|
|
|
|
I have developped a software. Now I need to make a setup file. I have used "Visual Studio 2005" to created a setup file. But it needs to install "Framework 2.0" when the user install it, it is very inconvenient.
Does anybody know some other tools to make it?
Thanks a lot.
|
|
|
|
|
there are plenty of tools out there, but you should be able to do a VS2005 install without .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 )
|
|
|
|
|
|
In my college course, we mainly did console C and C++ programs. Now I studied MFC and C#.NET for GUI programs but I prefer good old C++.
My question is MFC is what is used to make applications for Windows? Like small apps like uTorrent for example to common programs like Winamp or basically the programs found on Download.com.
The thing is I can't find a good book on MFC. Seems like it is "old" technology especially with the push of C# and .NET
I really want to get started making some simple applications in C++ for Windows. Is MFC the only way?
|
|
|
|
|
There are many class libraries, but the two you'll hear the most about are MFC and ATL/WTL. (WTL is a set of GUI classes that build upon ATL.) However, you don't have to use a class library, and in fact it's my strong opinion that you should not use any class library at all until you understand how to do GUI programming at the Win32 API level.
EDIT: Forgot to give my thoughts on uTorrent. From what I see in Spy++, it looks like it was all hand-rolled. I don't see any window classes or names that indicate MFC or ATL was used. Last modified: 38mins after originally posted --
|
|
|
|
|
Firestorm ZERO wrote: The thing is I can't find a good book on MFC
Unfortunately, Microsoft pushed it down so hard, that many books vanished in a very short period about 1-2 years ago. MFC seems to be a four letter word around here anymore as far as some Microsoft MVP's are concerned.
I've been trying to weed myself away from it but I'm finding it hard to give up.
For what it's worth, we just decided to base a very large and important app on MFC if your asking "who's using MFC nowadays?"
As for .NET using C++, I took a good hard look at Nish's book "C++/CLI in Action" and he makes a good effort at trying to explain it all but I was so lost toward the middle due to C++/CLI's complexity and lack of traditional C/C++ programming concepts that I had to put it down. I think I have a better chance learning the STL before C++/CLI. The little experiment with managed extensions also lends to the confusion of what is what anymore when referring to .NET from a C++ perspective.
Firestorm ZERO wrote: Is MFC the only way?
If your intent is to use C++, COM appears to be the easiest way to provide interfaces for other languages and MFC is the way to go for that if you dislike template programming first hand. If looking at template code does not make your eyes cross then ATL/WTL might be worth looking into. Mr. Dunn provides some fairly interesting tutorials on WTL here on CP.
|
|
|
|
|
Firestorm ZERO wrote: I really want to get started making some simple applications in C++ for Windows. Is MFC the only way?
No, of course, it isn't the only way. You can use directly Win32 API, or other class libraries. If you aren't stuck with C++, then you can use C# to develop Windows applications.
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.
|
|
|
|
|
I am trying to access a C# dll from MFC application. One of this dll method, XMLDoc(), returns an XMLDocument object. When I compile the c++ project, a tlh file is created where I find:
virtual HRESULT __stdcall XMLDoc (
/*[out,retval]*/ IUnknown * * pRetVal ) = 0;
Seems this method returns IUnknown instead of XMLDocument object directly. I am facing problem getting the XMLDocument object from this IUnknown interface.
Can anybody show me a way/sample to do this?
Thanks in advance.
Nazmul
|
|
|
|
|
Probably a cast of pRetVal pointer will be harmless. Anyway, the better (and safer) way is asking the IXMLDocument interface via the (*pRetVal)->QueryInterface method.
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.
|
|
|
|
|
Hi all. Im trying to find some information on the ConductEchoSession() API. Google only has one result, as well as Yahoo. And they both point back to a post on a forum a few months ago. MSDN doesnt have a clue what it is or provide any information about the function. The name seems to be self explanitory Conduct echo session. But i like to be able to look things up and since i cant do that for this function i need the help from someone to give a brief explanation. Thanx in advance!
|
|
|
|
|
It's not an API, it's a function that someone wrote. The code is provided in the post[^].
|
|
|
|
|
I am not 100% sure how keyboard input works, so I thought I'd ask it here.
I already asked about blocking joystick devices in C++, but I got no answers
See here: http://www.codeproject.com/script/comments/forums.asp?msg=2038033&forumid=1647&mode=all&userid=4049045#xx2038033xx
[^]
Mostly, I am curious if there is a way to detect keyboard input from a "real keyboard" and differentiate it from a clicker/macro program. I want to do this in C++. I know there are WinAPI functions as well as Direct3d functions for such things, but I couldn't find any information on if it's possible to tell them apart.
Any answers would be appreciated. Thanks in advance.
|
|
|
|
|
You can use SetWindowsHookEx() with the WH_KEYBOARD_LL parameter to monitor all low-level keyboard messages. From the callback function, LowLevelKeyboardProc(), you can block any of the messages by returning a nonzero value, so that the message isn't sent to the target window. You could do something like this:
...
//Prototypes
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
...
//Global variables
HHOOK hLowlevelKeyboardHook; //Low-level keyboard hook handle
...
//Main Window Callback function
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
...
switch(msg)
{
case WM_CREATE:
hLowlevelKeyboardHook=SetWindowsHookEx(WH_KEYBOARD_LL, //Low-level keyboard messages
LowLevelKeyboardProc, //Hook Callback function
NULL, //Monitor all system messages
0 //Monitor all system messages
);
break;
}
...
}
...
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPKBDLLHOOKSTRUCT kbdst;
if(nCode<0) //No message to process
return CallNextHookEx(hLowlevelKeyboardHook, nCode, wParam, lParam);
//Block all keyboard messages, if they are the letter 'A'
kbdst=(LPKBDLLHOOKSTRUCT)lParam;
if(kbdst->vkCode==41)
return -1;
//Otherwise, send the message to the next hook
return CallNextHookEx(hLowlevelKeyboardHook, nCode, wParam, lParam);
}
Hope this helps!
--PerspX
|
|
|
|
|
I have a requirement to read data from a serial port and send it out over a network port. The data must be sent when either of these two conditions are met:
1) 1400 bytes read.
2) 20 milliseconds have elapsed since the last read finished (if no data is present wait another 20 ms or until condition 1)
To try an meet these goals I am using overlapped IO. Here is the read:
ReadFile(hComm, ReadBuffer, 1400, &dwRead, &osReader);
I am trying to use a Waitable Timer to signal the 20 ms for requirement 2. The problem is how do I stop the current read operation and get all the characters that have been read when the timer expires? I tried using WaitForMultipleObjects but I am stuck on what to do when the timer expires.
I am writing this application in VC++ using Visual Studio 2005, target platform is Windows XP.
|
|
|
|