|
I think you are using it in your dialog box. So all keys pressed go to the parent window. In this case it is going to the Cancel or OK button, so the application exits.
You need to handle your particular key combination e.g, Ctrl + Q etc for the main dialog using accelerators.
this is this.
|
|
|
|
|
Thankx for you kind response...But sorry to say that I m not been able to understand what you are saying exactly ....Can you please say it in more details plz...
Regards
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Can I see your code? Can you trace if OnkeyDown function gets called?
|
|
|
|
|
I don't mind if you want to see my code.....but where and how to send my code....can you plz give me u'r personal mail address so that I can send it over there....
And yes I have traced it but it never goes into OnKeyDown fuction.
Regards
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
My C++ program should call another program (GAMS), give data to it and then wait for the return data of this program. How do I do this in general or does anybody know how to do it with GAMS???
Thanks in advance!
|
|
|
|
|
We need to know a little more about this GAMS... is it a command line app? or a GUI app with an automation interface?
Joel Holdsworth
|
|
|
|
|
It is similar to Matlab I think... normally you have to open GAMS and you have to have a text file with all the information needed (in this case it´s a optimization problem...so you have a few equations and matrixes), and you tell GAMS "Solve it!" and the output data is put into another text file.
So I guess it´s a GUI, but my problem is that I don´t know whether it has an automation interface...boohoo...
|
|
|
|
|
try dropping the text file onto the icon for GAMS. If it opens up and runs, that means it will accept the name of the text file as a command-line argument. If this is the case, you could use ShellExecute() and just send it the path to the text file as an argument.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Joel Holdsworth wrote:
We need to know a little more about this GAMS...
Just a guess:
Guide to Available Mathematical Software
GPS Azimuth Measurement System
Genome Annotation Management System
General Algebraic Modeling System
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
See here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I'm doing the excercise after the chapter about copy-constructor, Here's how it goes:
Create a very simple class, and a function that returns an
object of that class by value. Create a second function that
takes a reference to an object of your class. Call the first
function as the argument of the second function, and
demonstrate that the second function must use a const
reference as its argument.
And here's my implementation:
extern class A;
A fun1()
{
return A();
}
void fun2(A& a)
{
}
int main()
{
fun2(fun1());
}
I believe I've done exactly what the author has described, but It seems fun2(...) doesn't have to take a argument of const reference and compiler doesn't complain too!In addition what's the effect of calling A() inside fun1(...) instead of
A a
return a;
|
|
|
|
|
I think the question (from your book) is somewhat unintuitive. I think what it wants is for you to modify a member of A inside fun2(). You'll lose that change/value because your passing a temporary variable, but passing a temporary variable is fair game because it has an lvalue.
A a;
return a;
is the same as
return a();
The latter combines the two lines into one by using a temporary variable. I believe most compilers will produce the same code. They both go on the stack temporarily.
|
|
|
|
|
extern class A;
A fun1()
{
return A();
}
void fun2(A& a)
{}
int main()
{
fun2(fun1());
}
I think specify fun2(...) argument as a const reference make sense. Because when the call to fun2(...) is made the compiler has to generate a temporary object in order to hold the object returned by fun1(...), and this temporary object default to const!But somehow compiler doesn't complain!
Mark Petrik Sosa wrote:
A a;
return a;
is the same as
return A();
is "return A();" just a call to the constructor?
|
|
|
|
|
Hi guys hopefuly someone will be able to help.
I need to open a file for reading but this file is already open by another application for writing.
I have tried playing around with the flags in CreateFile but have still not succeeded.
Does anyone know how to do this?
|
|
|
|
|
If the other app hasn't specified sharing, then you can't do this. The CreateFile call has a sharing parameter which can be any one of (or combination |'d together of)
FILE_SHARE_DELETE
FILE_SHARE_READ
FILE_SHARE_WRITE
or you can specify 0, which means no sharing. This applies when you open a file, and means that you are happy to let subsequent calls to CreateFile open the file if they specify only the access you're willing to allow.
If the other app has specified zero, you can't open it anyhow, but if it's specified FILE_SHARE_READ then you *could* open it for reading, but not for read/write or just write.
Does that help?
Steve S
Developer for hire!
|
|
|
|
|
Thanks for the help Steve.
I just used File Monitor to check how it is being opened by the other application (I do not have source code for it)
It says: Options: Openlf Access: All
I doubt it is allowing share read... I guess I cannot use CreateFile to open this file...
Jeremy.
|
|
|
|
|
Hello...
Arturdt wrote:
I need to open a file for reading but this file is already open by another application for writing.
Which Application lock the File ???
Can you specify the file share permission from both applications ???
When yes, you must only speciefy the correct file share permission when you create or open the file (FILE_SHARE_READ|FILE_SHARE_WRITE).
|
|
|
|
|
The application locking the file is Edonkey (I am reading the .part files)
However I need to do this whilst edonkey is running.
Jeremy.
|
|
|
|
|
You could make a temp copy of the file for your own program, then delete the temp file when finished. That wouldn't require direct access to the target file.
u6ik
|
|
|
|
|
Yes, I am currently making a temp copy however I am dealing with multiple files of 9,500KB many times reaching to gigabytes of data... so I would like to avoid this extra copy!
|
|
|
|
|
Hello...
I want to get the Font width from a font handle and the ::GetObject(...) function to retrieve the font data (in a LOGFONT structure)... But often the lfWidth member is zero or very small...
How to get the correct font width ???
|
|
|
|
|
//You can get it like this:
double width;
RECT Rect;
width=Rect.right;//This is the width of your window.
|
|
|
|
|
which has to do with fonts how, exactly ?
Steve S
Developer for hire!
|
|
|
|
|
That will give you the average width (if available) of a character (in logical units). That may not be what you want, unless it's a fixed pitch font. Better (but slower) is to select the font into a device context, and use the GetTextExtentPoint32 functions for specific strings. Alternatively, if you really want the average width, you can do this using GetCharABCWidths and a bit of math.
Steve S
Developer for hire!
|
|
|
|
|
I believe what you want is something like GetTextMetrics(), which will return an average width in units based on the DC your using. A LOGFONT's lfWidth returns an average width in logical units. Also you can use DrawText() with DT_CALCRECT to get accurate dimensions on a given peice of text on a given DC.
|
|
|
|