|
Recently i have converted my project to VS2008 from VS2005.
My application crashes when we try to open a new job file from 'open' command.
Actually we have derived CFileDialog and added a preview on the right side of dialog.
So that when selecting the job iteself we can see the preview of it.
this works fine in VS2005. But it seems some problem after converting to VS2008.
Any solution to solve this problem.
Crashes in Vista machine alone. In Xp it works fine.
modified on Wednesday, August 19, 2009 2:42 AM
|
|
|
|
|
The crash is most likely a problem with the preview on the right side.
You should debug it and zero in on the problem.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
It works fine in XP machine after VS2008 migration.
But it dint work in Vista machines.
|
|
|
|
|
You shoul set
BOOL bVistaStyle = FALSE
in your derived class's constructor.
|
|
|
|
|
yes i have done that. It works fine.
|
|
|
|
|
Hi all
I am inserting files into SQL server using bulk insertion.
Can anybody tell me how to do it using variables.
I will store the data in a structure and how to insert this
structure to the SQL server.
Inserting using files is taking time.
Please help.
Regards
Deepu
|
|
|
|
|
Is this related to C++/MFC?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
type:IMAGE
it's my pleasure to make friend with you.
|
|
|
|
|
Hi there
I have just discovered that CStdioFile does not "work correctly" with files bigger than 2^32 bytes. Everything works fine in my program using CStdioFile, until the file size gets up to the limit. (Opening the large file with CFile and doing GetLength() gives the correct value, doing the same with CStdioFile gives garbage, and Seeks to the end crash out with a bad seek exception.) The MSDN site where I discovered this limit says "use CFile" instead. However, CFile is unbuffered, and I need to do quite a bit of skipping around with small reads and writes. I was only using CStdioFile because of its buffering - I'm reading/writing binary data.
Short of writing my own buffer, any ideas? Is there likely to be a big performance hit if I just use CFile instead? Would you advise using CArchive (which I believe is buffered), or is the overhead not worth it?
Thanks for any ideas.
Bill H
|
|
|
|
|
You will probably need to implement buffering yourself, unless there is some third party class.
CArchive is used for serialization and moreover you need a CFile object to work with CArchive .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Bill Heitler wrote: and I need to do quite a bit of skipping around with small reads and writes.
Traditional buffered I/O is terrible for this. It means you will keep filling and flushing the buffer. You are better off writing an algorithm tailored to your needs.
|
|
|
|
|
Good point - I'm sure you're right in principal about the buffering. Although I suppose it must depend on how close together the data locations are.
Just for interest I ran a very quick-and-dirty measure of the time to write then read 100,000 consecutive single floats. With CStdioFile it took 0.343 s, with CFile it took 3.348 s, and constructing a CArchive from the CFile and flushing and closing between the write and read, it just took 0.152 s. So I guess the buffering of CArchive makes a difference, at least for consecutive operations. But I don't know whether CArchive also has the 2^32 file size limit of CStdioFile. Does anyone else?
|
|
|
|
|
I have in a C++ module a for loop that can take some minutes to complete. I would like to add a pause/resume feature, and would also like to be able to stop it. However while the loop is running the program is totally unresponsive. Is there anything to be done ?
Raymond Mercier
|
|
|
|
|
Move the loop into a background thread and on each iteration (or every nth one) check for a "pause" flag that can be set by the UI thread; just be sure it is done in a thread-safe manner.
|
|
|
|
|
Thanks, but I have so little experience with threads, I will have to bone up on it.
Raymond
|
|
|
|
|
For dialog boxes, you can add and periodically call the following. Adjust to get best responsiveness:
BOOL CMyDialog::Pump()
{
MSG msg;
while (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return FALSE;
}
}
LONG idle = 0;
while (AfxGetApp()->OnIdle(idle++));
return TRUE;
}
|
|
|
|
|
Thanks, but I don't see how that can be made to deal with a loop.
Raymond
|
|
|
|
|
In the loop you periodically call the function; this keeps the message pump going and allows messages to be processed. This is the traditional way to make a progress/cancelable dialog box.
The alternative, and preferable for anything lengthy, is to run the operation in a thread.
|
|
|
|
|
In the end it was easy enough to run the function with its loop in a thread.
"ThreadProcTCP" is a rather involved module, with a loop, but it all works fine.
if (hChild)
GetExitCodeThread( hChild, &dwExitCodeThread );
if (dwExitCodeThread!=STILL_ACTIVE)
hChild = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProcTCP, hWnd, 0, &dwChild );
RaymondM
|
|
|
|
|
Note two things; a thread handle is non-signaled when it's running and signaled when it's not. Thus you can do a WaitForSingleObject() on a thread handle. Second: if you do any CRT calls in your thread, you should use __beginthreadex() (not all CRT calls need thread local storage (TLS), but figuring out which ones need it is tedious and, to my knowledge, not documented.)
|
|
|
|
|
Hallo,
is there any possibility to prevent an embedded child window to change its z-order?
My current problem is, I have an control embedded that brings itself into the front sporadically. Since it's embedded in one of my dialogs, the corresponding dialog is popping into the foreground, too.
Within the application this causes an affected dialog to pop in front of another dialog the user could be working in at the same moment.
For testing purposes I made a ::SetParent(controlHwnd, NULL). Once being a child of the desktop, it pops in front of any application now, not only on top of the application it was embedded in.
Anyhow, since I have no chance to modify the control itself (no sources!), I am searching for a way to prevent the control of changing its z-order. Is there any chance to "pin" it?
I have tried nearly all windows styles, but since the control seems to push itself into the front, I cannot do a lot against it this way. Perhaps subclassing the control's window and filtering some specific events? Any help appreciated!
Thanks a lot in advance,
Roland
|
|
|
|
|
This Article by Raymond Chen[^], might suggest a solution.
Then again it might make things worse by confusing the issue.
What you want to determine is why your control "brings itself into the front sporadically".
It's being triggered by something, obviously.
Here's another Interesting bit of z-order lore[^].
|
|
|
|
|
I obviously don't get this bind stuff as I cannot seem to get it right
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <boost/bind.hpp>
using namespace boost::bind;
typedef int DWORD;
typedef std::pair<std::string, bool> user_info;
typedef std::map<DWORD, user_info> USER_MAP;
typedef std::vector<DWORD> VEC_STAFF;
int _tmain(int argc, _TCHAR* argv[])
{
USER_MAP m_Users;
VEC_STAFF Staff;
VEC_STAFF::iterator it = std::partition(Staff.begin(), Staff.end(),(bind(&USER_MAP::find, m_Users, _1) != m_Users.end()));
What I wanted to code to do is that for every entry in the Staff vector it should check to see whether that user id was present in the map, and if so move those items to the front.
I have an example using a functor that works as I hoped the above code would, but the bind version is obviously not doing what I think its doing.
struct InUsersMap : public std::unary_function<USER_MAP::key_type,bool>
{
InUsersMap(USER_MAP & theMap, USER_MAP::const_iterator end)
: m_theMap(theMap)
{
}
inline bool operator()(CSecurePatients::USER_MAP::key_type& id) const
{
return m_theMap.find(id) != m_theMap.end();
}
private:
const USER_MAP &m_theMap;
}
Finally does anyone know how to avoid getting the socket bind function from windows being included
|
|
|
|
|
When a .Net code calls an unmanaged C++ code, do we have the same thread executing the code.
And what about code exception ? Is .Net code capable of catching exception
originating from the unmanaged C++ code.
Thank you in advance.
(I don't program in .Net I just would like to know).
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
Yes
No (except possibly for a structured exception [generated by the OS])
|
|
|
|