|
I was having the exact same problem. But, my application doesn't have threads. I ran into it because I commented out the following line from my document OnCloseDocument() function:
CDocument::OnCloseDocument();
Since the CDocument base class OnCloseDocument wasn't being called, the document was being left out there still open and my app couldn't terminate.
Mike Ellertson
|
|
|
|
|
Hi all, How can i tell if the cell contains the autodate?
I tried the following way and it didn't work..
<br />
CString cellPos;<br />
IndToStr(srIndex,scIndex,cellPos);<br />
Range aRange = asheet.GetRange(COleVariant((CString)cellPos),COleVariant((CString)cellPos));<br />
<br />
VARIANT va = aRange.GetValue();<br />
<br />
if(va.vt != VT_EMPTY )<br />
{<br />
CString valStr(va.bstrVal);<br />
if(va.vt == VT_DATE)<br />
{ <br />
MessageBox(valStr); <br />
} <br />
}<br />
|
|
|
|
|
Hi,
I've been developing MFC (HTMLView) applications for quite sometime now. In order to reference the images and javascript .js file I used the res://app.exe/ protocol and it works just fine. In my last project I need to use a java applet library .jar but no matter what I try it doesn't work unless the java applet is in a webserver. I have used the following approaches:
- codebase file://C:/dir/file.jar => failed
- archive file://C:/dir/file.jar => failed
- codebase res://app.exe/file.jar => failed
- archive res://app.exe/file.jar => failed
- codebase http://webserver/file.jar => success
- archive http://webserver/file.jar => success
The question is: How can I use a java applet in an MFC application without using a webserver?
Thanks a lot for any lights on this.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Not sure exactly what you are trying to do, but an applet must run within Java, whether thats from the command line or within an HTML page. Look at http://www.juicystudio.com/tutorial/html/object.asp for information on how to embed in HTML, and you will need to use the 'codebase' attribute to specify the jar file.
|
|
|
|
|
Hi,
Thanks but I know how to embed the applet in my HTML page. As a matter of fact the problem only occurs when the applet is in the application resources like I can do with HTML pages, CSS files, GIF/JPG images, etc. Unfortunatelly it doesn't work with applets. Bellow you can see the part of the code I'm using to load the applet:
<applet code="SomeCtrl" width="350" height="250" name="myctrl"
="" archive="SomeCtrl.jar" viewastext="">
The thing is, if I use this code in a page in my webserver it works correctly since the jar is in the same directory as the page is. But I do wnat to load this applet from the application resources or externally using the file:///C:/folder/ protocol. I have tested the file:/// protocol and it works if the HTML page is on disk but in my case the HTML page is in the resource.
If it still not clear, please just let me know.
Thanks again,
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
I think there's a res: protocol for loading stuff from resources.
Steve S
|
|
|
|
|
I've already done that, and that's the problem it doesn't load the applet with the res:// protocol nor using the file:/// if the browser is embbeded in an MFC application. I could successfully write an html page to load in IE using both file:/// and http:// protocols but it comes to MFC application the only way to load the applet is using the http:// protocol, file:/// and res:// don't work.
Any suggestions.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Sorry, didn't read the root message.
When you specify res://exe-name/resource, is the resource specified as HTML or JAR (or something else)..?
At the back of my mind is that there was some kind of problem with this on Win9x at some point.
Steve S
|
|
|
|
|
Hi Steve,
The jar file is specified as HTML, as it is the images and javascripts files. One funny thing is: I have just made a page in FrontPage using the file:/// protocol and the page works fine in the browser. If I use the same page in the application resources I got a Exception in the applet location in the page.
Thanks
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
Short answer is: Sorry, can't be done.
When you start a Java applet, the browser passes the URL of the applet codebase to the Java Virtual Machine. The JVM is not going to understand a res: URL, and it is specifically prohibited from using a file: URL to load an applet because of all sorts of security problems.
What you should be able to do is run the applet as a regular Java application, in which case the JVM is free to access the local disk to find the Jar file. Often applets will also have a "main" function that lets you run them as a regular application; if yours does not you will have to write another Java class with a "main" function that creates a frame and starts the applet within it.
If your applet code needs tighter integration with your MFC app than running as a separate Java process will allow, you might have to look at the JNI (Java Native Interface), or whatever the equivalent is for Microsoft's brain-damaged JVM, to incorporate the Java runtime into your application.
|
|
|
|
|
Hi antlers,
That sounds amazingly harder than I thought. Would you think it would be a better idea to use ActiveX controls instead of applets? Would the use of ActiveX controls present the same kind (or maybe different) of problems?
Thanks a lot for your explanation. It helped me a lot to understand the process.
Crercio O. Silva / DBTools Development
http://www.dbtools.com.br
|
|
|
|
|
I guess ActiveX controls would work. You might need to have them installed along with the app on the machine instead of read from the resource file though.
Microsoft wrote some extensions to their JVM that allow Java stuff to be accessed as ActiveX controls, and I suspect that doing this would be the least work for you (unless recoding the applets is really easy). I haven't used Java this way myself, but check
http://www.codeguru.com/java/tij/tij0195.shtml
|
|
|
|
|
hi there
i have been working on a mathematical program, and i need some way to measure elapsed time between 2 operations precisely (if possible, as precise as sciencemark has in its primordia benchmark: www.sciencemark.org), but i dont like just going out and using some third party class... right now I am able to measure "only" up to miliseconds...
thanx
Thiago
|
|
|
|
|
Given that Windows is not a resal-time OS, much precision is not going to be a reality. Depending on your OS (e.g., 9x, NT), the timer resolution will range from 10ms to 55ms. Read this site for more.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
A common trick is to measure multiple executions of a function and then calculate the execution time from the result. For example, you could run your functions 100,000 times. Then you divide the result by 100,000 to get the time for a single execution.
Off course a lot of things can and do go wrong with this. On Windows you will not get really good data for many reasons. But this method produces an upper bound of maybe higher precision than what you have now.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
#include <iostream>
#include <fstream>
using namespace std;
char matrix [3][3]; //Tic Tac Toe Matrix
char check();
void init_matrix();
void get_player_move();
void get_computer_move();
void disp_matrix();
int main()
{
char done = ' ';
init_matrix();
ofstream examplefile("example.txt");
do
{
disp_matrix();
get_player_move();
done = check(); //See if any winner
if(done != ' ') break; //Winner!!!
get_computer_move();
done = check(); //See if any winner again
if(done != ' ') break;
} while(done == ' ');
if(done == 'X')
{
if (examplefile.is_open())
{
examplefile << "Winner: X\n";
examplefile.close();
}
cout << "You won!!!\n";
}
if(done == 'O')
{
if (examplefile.is_open())
{
examplefile << "Winner: O\n";
examplefile.close();
}
cout << "I won!!!\n";
}
else
{
if (examplefile.is_open())
{
examplefile << "Winner: Draw\n";
examplefile.close();
}
cout << "Draw!!!\n";
}
disp_matrix(); //Display final matrix
return 0;
}
//Initialize the matrix
void init_matrix()
{
int i, j;
for(i=0; i<3; i++)
for(j=0; j<3; j++)
matrix[i][j] = ' ';
}
//Get the player's move
void get_player_move()
{
int x, y;
cout << "Enter X,Y coordinates for your move: ";
cin >> x;
cin >> y;
x--; y--;
if(matrix[x][y]!= ' ')
{
cout << "Invalid move, try again.\n";
get_player_move();
}
else matrix[x][y] = 'X';
}
//Get a move from the computer
void get_computer_move()
{
/*
int i, j;
if(matrix[i][j] !=' ')
if(i*j==9)
{
cout << "draw\n";
system("pause");
}
else
matrix[i][j] = 'O';
*/
}
//Display the matrix
void disp_matrix()
{
int t;
for(t=0; t<3; t++) {
cout << matrix[t][0] << " | " << matrix[t][1] << " | " << matrix[t][2];
if(t != 2)
cout << "\n---|---|---\n";
}
cout << "\n";
}
//See if any winner
char check()
{
// New checking system
int i;
for(i=0; i<3; i++) // Check rows
if(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2])
{
return matrix[i][0];
}
for(i=0; i<3; i++) // Check columns
if(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i])
{
return matrix[0][i];
}
//Test diagonals for winner
// Left to right
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])
{
return matrix[0][0];
}
// Right to left
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])
{
return matrix[0][2];
}
/*
// Old checking system
// Check rows
if(matrix[0][0] == matrix[0][1] && matrix[0][0] == matrix[0][2])
{
return matrix[0][0];
}
if(matrix[1][0] == matrix[1][1] && matrix[1][0] == matrix[1][2])
{
return matrix[1][0];
}
if(matrix[2][0] == matrix[2][1] && matrix[2][0] == matrix[2][2])
{
return matrix[2][0];
}
// Check columns
if(matrix[0][0] == matrix[1][0] && matrix[0][0] == matrix[2][0])
{
return matrix[0][0];
}
if(matrix[0][1] == matrix[1][1] && matrix[0][1] == matrix[2][1])
{
return matrix[0][1];
}
if(matrix[0][2] == matrix[1][2] && matrix[0][2] == matrix[2][2])
{
return matrix[0][2];
}
// Check diagonal (left to right)
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])
{
return matrix[0][0];
}
// Check diagonal (right to left)
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])
{
return matrix[0][2];
}
*/
return ' ';
}
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Hi all,
i have an SDI application. when i run it and select a document from the recent list, it is loaded perfectly calling "OnOpenDocument" method.
after that i close the file using 'File->Close' and the method "OnCloseDocument" is called as well...
then i select the file again and nothing happens..... i've placed a break point in the "OnOpenDocument" method and saw it didn't reached there.....
can any1 help?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
http://www.artima.com/intv/goldilocks.html[^]
I especially liked the section "Climbing Above C-Level."
Stroustrup: "The C++ community has yet to internalize the facilities offered by standard C++. By reconsidering the style of C++ use, major improvements in ease of writing, correctness, maintainability, and efficiency can be obtained."
This is all too true. And it certainly applies to the code I'm having to maintain at the moment. It also applies to almost all the C++ code I've had to maintain over the past few years. Part of the problem has been that Standard C++ (STL, etc.) was difficult and certainly when STL was new it was pretty damn difficult to get to grips with. I remember at one time seeing the theoretical document behind the original HP (I think it was HP?) implementation and being completely bamboozled.
However, today there are plenty of good books around so current C++ developers should have no excuse for avoiding it (though Francis Glassborow of The Association of C and C++ Users tells me that the majority of professional programmers don't read books on programming so this may have something to do with it). Sure Standard C++ is big and does get pretty complicated but in fact basic use of it is easy and can alleviate a lot of common problems. There are lots of worked examples in, e.g., the MS Visual C++ online help. That was my first route into it.
Stroustrup: "Most of these techniques are criticized unfairly for being inefficient. The assumption is that if it is elegant, if it is higher level, it must be slow. It could be slow in a few cases, so deal with those few cases at the lower level, but start at a higher level. In some cases, you simply don't have the overhead. For example, vectors really are as fast as arrays. "
This too rings true. C/C++ developers are often obsessed with perceived inefficiency and often have poor intuition about it. Some time ago I read a case study on the use of Eiffel at a Fortune 500 storage manufacturer. Eiffel is an OO language analogous to Java and C# (i.e., managed runtime, etc.). The project required rewriting an existing C application in Eiffel. The developers were new to Eiffel and had the intuition that performance would be inferior as a result of Eiffel's managed runtime. In fact, it turned out that the new application was 10 times faster. Obviously, much of this performance boost would have been due to moving to a more efficient OO design, resulting in more code re-use. Also, no doubt the C application would have been faster than the original had it been redesigned in C. Still, it showed up the poor intuition of the C developers. We should aim first at maintainability and correctness. Efficiency will often follow as a consequence.
Kevin
|
|
|
|
|
Dear developers,
One never knows to what edge freelance development can take you, like it did to me now all desperate to find a database implementation for embedded systems that are not .NET or 0x86 compatible. I have a pure C/C++ portable platform for some sort of programmable terminals, and I need a more or less generic implementation of a simple database, preferably with indexes or some sort of optimization. Any table is deemed to never have more than 1000 records. And the entire database is best residing in a single file. It’s killing me to think that these progressing days I would have to marvel it all on my own like in old times.
One last detail: It would be the nicest implementation with file-access level implemented clearly, like a driver so that I could just insert my own file-access operations that will work for me.
Anyone who has whatever relevant please, throw at me, be endlessly grateful for that.
Regards,
Just one of you.
|
|
|
|
|
Hi all,
I am using the following code:
CArray<int,int> myArray;
for (int i=0;i < 10;i++)
myArray.Add(i);
myArray.RemoveAt(5);
TRACE(_T("\n"));
for ( i = 0; i < myArray.GetSize(); i++)
{
TRACE(_T("%d\n"),myArray.GetAt(i));
}
TRACE(_T("size is : %d"),myArray.GetSize());
TRACE(_T("\n"));
myArray.SetAtGrow(5,200);
for ( i = 0; i < myArray.GetSize(); i++)
{
TRACE(_T("%d\n"),myArray.GetAt(i));
}
TRACE(_T("size is : %d\n\n"),myArray.GetSize());
problem is, both sizes are 9 in the debug output window....
and for the second time i print the array i see that 200 is instead of 6 and not 5!!!??????
can any1 help here?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Yep pretty normal... SetAtGrow only increases the size if the index specified is bigger than the actual size... I bet you need InsertAt rather than SetAtGrow
|
|
|
|
|
hi,
thanks for reply,
i've managed with SetAt instead of remove and then setatgrow....
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi ive got app with Static splitter window. On each pane there is a listctrl (classic file explorer). When i first start my app i cant get any item focused even if i use SetActivePane and SetItemState. The same problem i have when i try to change view with tab key. The pane is active (or i quess so) but no list member is activated till i mouse click on it.
Can u help me plz ? Thanks in advance.
|
|
|
|
|
im making a mp3 player and i want to get the end o the music to pass to the next music in the list
im actually doing this:
while(MCIWndGetPosition(m_Video) == MCIWndGetEnd(m_Video))
{
::MessageBox(m_Video,"PING","PING",MB_OK);
}
but when the end position ends it doesnt return the testing message box
please somebody help me resolving this issue
Regards
AI_Warrior
Portugal;P
|
|
|
|
|
lol?
what you have here means that the program will loop THROUGH the message box until the end is reached.
once the message box shows, the execution stops here!
if you want to do it that way, it has to look like:
while( player_online )
{
play_next_track();
while( MCIWndGetPosition(m_Video) != MCIWndGetEnd(m_Video) )
Sleep( 1 );
}
but i don't know if this is the optimal way... i propose to use an existing mp3 player, until you've learned how it works the best way!
Don't try it, just do it!
|
|
|
|