how do I close a thread?
doug25
Posts
-
ofstream optimization problem -
ofstream optimization problemI haven't explained it very well. Basically, I've written a program that writes a .x file using wofstream. But the file doesn't look very pretty so I'm using the directx code I posted to convert it to a better format, so I can also save it as binary or compressed as well as structured text. Basically saves me having to rewrite the program. I'll close the thread.
-
ofstream optimization problemthanks, I'll try that
-
ofstream optimization problemthe problem is some strings are not loaded, or at least are not written to the new file. e.g. each line in the output file that should contain "Frame frame_name {" (works without opt.) reads "Frame {". I will try freeing the memory of child data objects although I have assumed they get released when the top level data object get released and I will try what Jochan suggested. There is very little documentation on how to use these functions. I won't be able to reply for a while if I do fix the problem but cheers.
-
ofstream optimization problemwell, it could be a mistake I've made but I've managed to find exactly where the error occurs by using #pragma optimize("g", off) and #pragma optimize("g", on) it's one function, I can't see any mistakes
#pragma optimize("g", off)
void AddDataObject(ID3DXFileSaveObject* xFileSave, ID3DXFileData* child, ID3DXFileSaveData* xSaveData)
{
// Add data for this child then each of it's children
SIZE_T nChildren = 0;
child->GetChildren(&nChildren);// add child GUID templateid, id; child->GetType(&templateid); child->GetId(&id); char name\[MAX\_PATH\]; SIZE\_T sz; child->GetName(name, &sz); SIZE\_T dataSize; void\* data = NULL; child->Lock(&dataSize, (LPCVOID\*)&data); if(xSaveData) { xSaveData->AddDataObject(templateid, name, (const GUID\*)&id, dataSize, data, &xSaveData); } else { xFileSave->AddDataObject(templateid, name, (const GUID\*)&id, dataSize, data, &xSaveData); } child->Unlock(); // For each child of child, add child data // Add data for all sub children (recurse) for(int i=0; iGetChild(i, &ch))) { // Add data for children of this child (ch) AddDataObject(xFileSave, ch, xSaveData); } }
}
#pragma optimize("g", on)
-
ofstream optimization problemsorry, I've discovered what was happening, it isn't a problem with wstring optimazation. I was converting the file to another format the functions i'm using behave differently with optimization. The problem is nothing to do with vectors or wstrings. it's a directx set of functions i'm using that fail when optimazation is turned on. It was difficult to determine tat this was where the program was failing.
-
ofstream optimization problemso wofstream can't be optimized? it all works well without optimization
-
ofstream optimization problemHi, I'm using wofstream to write text to a file my problem is that, with any level of optimization, neither write() or << allows me to write a wstring or c string in the form of (WCHAR*). example
WCHAR* str = new WCHAR[MAX_PATH];
wcscpy(str, L"walk");
myfile.write(str, wcslen(str));No string written to file
wstring str2 = L"walk";
myfile << str2;No string written to file I am able to to do
myfile << "String";
how do I fix?
-
How do I get recurring events from holding a button down?thanks, I've managed to get the holding button down to work. I just used a global veriable to track the state of the button via the WM_DRAWITEM notification and then in my program loop referred to this variable.
-
How do I get recurring events from holding a button down?thanks for the reply, but when i say button I mean a button control not a keyboard key. I'm looking for an event such as WM_COMMAND that is generated while the button is pressed until the button is released. WM_COMMAND though just is generated on click not press as well.
-
How do I get recurring events from holding a button down?Hi, I have a button that is supposed to increase the size of an image when it's held down. I want it so that when the button is held down, I get a repeated event. How do I know in my application that a button is held down, is there an event generated that is sent to the window procedure ?
-
ShowHTMLDialog not working in Windows 7Ah, the problem is where I convert a char string to wide char string. I need to convert the url I want to display to a wide char string and if I leave that code out and just specify google as the url, the program works in windows 7. I'm not sure what I'm doing wrong with the conversion ?
char url[MAX_PATH];
_getcwd(url, MAX_PATH);
std::string file = url;
file += "\\Help.html\0";OLECHAR* oleChar = NULL;
oleChar = (OLECHAR*)calloc(file.length(), sizeof(OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, file.c_str(), -1, oleChar, sizeof(OLECHAR)*file.length());BSTR bstrURL = SysAllocString(oleChar);
-
ShowHTMLDialog not working in Windows 7the error is that the program crashes on a call to ShowHTMLDialog(only on windows 7) and no dialog window appears. thanks, I will check out the dependancy walker
-
ShowHTMLDialog not working in Windows 7Hi, I thought I'd cracked this problem but it seems that I was wrong. Although I know now that the problem lies with the operating system. I want to display a web page in a window. I realized that this is possible with the ShowHTMLDialog function, however it only works in windows XP not windows 7. There is something else though: I can get a web page to display when I run the program directly in visual studio but not when I run it as a stand-alone application(in windows 7). So I think the problem is that some required dlls are being loaded when I run it in visual studio but not as standalone. It seems that the only dll i need for ShowHTMLDialog is mshtml.dll but I'm not sure if other dlls with different versions from windows XP are being used. What's going on when I run the program from visual studio that is different from running the program on it's own ? How do I get ShowHTMLDialog to work in windows 7 ? (I'm not using MFC) thanks,
-
web browser control difficultyI've got the program to work :)! after some modifications. still not sure what the problem was but I think it had something to do with structure declarations I'd placed in a header file..
-
web browser control difficultyI understand this, I have been using the full path and file name. I need to convert the string to a BSTR, I'm assuming i'm doing it correctly because as I say, the program works but only shows a web page when I run it from visual studio. here's how:
char url[MAX_PATH];
// _getcwd(url, MAX_PATH);
GetModuleFileName(InstanceHandle, url, MAX_PATH);
std::string file = url;
file = file.substr(0, file.find_last_of("\\"));
file += "\\Help.html";
//file = "Help.html";// show that the path is correct
MessageBox(NULL, file.c_str(), NULL, NULL);OLECHAR* oleChar = NULL;
oleChar = (OLECHAR*)calloc(file.length(), sizeof(OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, file.c_str(), -1, oleChar, sizeof(WCHAR)*file.length());vURL.bstrVal = SysAllocString(oleChar);
-
web browser control difficultyThanks, but i'm not using MFC
-
web browser control difficultyHello, I'm trying to display a web page inside my own window. I found a c++ example by chris becke on the net which is huge. I ported the code into my application but I can only get the web page to display when I run the project in visual c++. Is there a more bare bone example that displays a web page inside a window ? or why does my program only work when I run it from visual c++ ? I'm not of a great state of intelligence to understand all the com code needed to display a web page but with a little help I think I might understand.. thanks,
-
Restricting rights to delete a dynamic array ? [modified]thanks :)
-
Restricting rights to delete a dynamic array ? [modified]There's virtually no performance difference between a vector and dynamic array most of the time, I agree. I'm certain my measurements are correct but I decided to take a few more to get a better idea of the exact difference. The test program was compiled in release mode with full optimizations, Maximize Speed, Favor fast code, no debug info... The results show that reading values stored in a dynamic array can be anywhere from 1 times faster and above compared to reading values from a vector in the normal way i.e. using the overloaded subscript operator. When fewer accesses are made, there will be virtually no difference in the time taken by a vector and dynamic array i.e. dynamic array is 1... times faster than vector, but if a million accesses are done at once, array is about 8000 times faster. Not quite sure why, but that's how it works. Certain 3d computations for example might benefit from the extra performance that using dynamic arrays directly can provide. When I started using C++, I came accross a program that could help manipulate pixels on the screen faster than using e.g. windows GDI, I converted the vectors used to dynamic arrays and got a massive difference in performance on a fast computer (that was two years ago, so it's still a "fast computer"). But that was unusual, so probably vectors are almost always the best way to go.
modified on Wednesday, January 6, 2010 11:48 PM