|
Hello,
I am trying to add a cancel button to a modeless dialog I have created for my program. For this program, I enter information in the main dialog and when I click ‘Start’ a series of calculations are preformed. A second dialog box appears and acts as a status box – it sends information about the calculations to a text box in the second dialog. I have a cancel button on this second dialog that works, but only after EVERY calculation has been completed. My problem is this – I would like to have some way to check to see if the user has clicked the cancel button in between my calculation loop. Thanks in advance.
Loren
|
|
|
|
|
Hello,
You can add OnTimer() function in your main dialog. Include a code that will check say every 2 seconds if the modeless dialog is still open or not.
Example:
// say MyModeless is the modeless dialog object.
void CTFMHOSTView::OnTimer(UINT nIDEvent)
{
if(!MyModeless)
{ // means MyModeless has been closed
}
SetTimer(1,2000,0);// restart the timer again
CRecordView::OnTimer(nIDEvent);
}
rgrds,
Mar
Mar Solero Jr.
|
|
|
|
|
Spank me!! wrote:
My problem is this – I would like to have some way to check to see if the user has clicked the cancel button in between my calculation loop.
Either have the calculation done in a separate thread and stop this thread in your CANCEL-handler.
Or 'pump the message queue' in intervals while doing your calculation.
Call this function:
static bool PeekAndPump()
{
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return false;
}
}
LONG lIdle = 0;
while (AfxGetApp()->OnIdle(lIdle++));
return true;
}
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I have an MDI application whose main window icon is different than its document icons. As a result, whenever a document is opened in XP, the main window icon is replaced with a generic window icon in the taskbar. It would seem that this should be something easy to fix, but I haven't been able to find a solution. Thanks for the help.
Mike
|
|
|
|
|
I wrote a winsock service that spawns a new thread on the "accept" function. Sometimes it seems that when I "recv" the client doesn't seem to have closed the connection gracefully? The service continues to peg the CPU at 100% (even though I have checked for SOCKET_ERROR and byte size of 0 returned from "recv").
My question is.....(code is "pseudo-pseudocode")
Can I rely on the following to work properly considering the problems that I have found with closing the socket on the client end?
int nTimeout = 1000;
nError = setsockopt(client, SOL_SOCKET, SO_RCVTIMEO, (char*)&nTimeout, sizeof(nTimeout));
Or, is something like this going to be more reliable (albeit pretty ugly...), where the "accept" calls a timer thread which in turn calls the client thread until it times out(as follows)?
UINT ClientTimerThread(LPVOID pParam) {
CWinThread* thread;
LPDWORD exitvalue;
if (WaitForSingleObjectEx(thread = AfxBeginThread(ClientThread,pParam), 10000, false) == WAIT_TIMEOUT) {
socket s = (SOCKET)pParam;
closesocket(s);
GetExitCodeThread(thread, exitvalue);
TerminateThread(thread, (DWORD) exitvalue);
}
return 0;
}
Any advice would be greatly appreciated...
~LizardWiz()
|
|
|
|
|
Please do not even consider applying your second solution: TerminateThread is not to be used unless under catastrophic conditions.
In Winsock2 SO_RCVTIMEO works fine (you sure is Winsock2 and not 1.1 what you're using?) Nevertheless, even if it didn't work that wouldn't justify the CPU peak. Can you post more of the reading code?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I wrote mfc program to send email using SMPT protocols. The program works, but I noticed the followings:
1- My email is recognized as junk mail by major .com companies such as yahoo..
2-Microsoft hotmail won't deliver my email even though I got confirmation (code 250, 221), however, when I get code 250 I see message: "Queued mail for delivery". I do not know why the email is queued, anyway I never receive it.
Thanks for any clue.
|
|
|
|
|
It's hard to say, but the server probably parses the message and notices some important SMTP header is missing. You can try catching the output of a commercial mail application and mimicking that in your program, just for testing purposes: then, carefully erasing one header at a time you'll find what the server is requiring as mandatory. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
hi,
refer http://www.naughter.com for smtp class. smtp class code is there. it's working fine. this problem is not occured there. very nice code.
Have A Nice Day
Murali.M
|
|
|
|
|
hi everybody,
does anyone of you all know how to write covariance matrix and eig function in Visual C++?
or anyone of you noe any website got the Visual C++ maths function algorithm free for use?
thank you very much.
vincent sim
|
|
|
|
|
I am using a CTreeView and need to move the tree nodes using Drag and drop . Any ideas for sample code to move nodes. Help is appreciated .
|
|
|
|
|
Here[^]'s an useful article. HTH,
K.
There are many here among us who feel that life is but a joke.
But you and I, we've been through that, and this is not our fate,
So let us not talk falsely now,
the hour is getting late
|
|
|
|
|
I have a question regarding scrolling on rich edit controls. I want to scroll to the bottom of the control like when you click the vertical scroll bar. I tried the linescroll func with getlincount, but it only work when I 1st start the progam. When the user uses the scroll bar, this method does not work as expected. Instead, it give me a blank page (blank page but scroll bar at bottom). Is there Cwnd function that I should used instead. Thank you for any help.
|
|
|
|
|
Hi, i'm trying to implement the Darkside mini SQL library in my ISAPI extension DLL. I tested the library before with a console application and it worked great, but not with my ISAPI dll... I get the following errors:
MHExtension.cpp
c:\dsqlm_1\include\dsql_m_structs.h(46) : error C2059: syntax error : 'constant'
c:\dsqlm_1\include\dsql_m_structs.h(46) : error C2143: syntax error : missing ';' before '}'
c:\dsqlm_1\include\dsql_m_structs.h(47) : error C2377: 'INT' : redefinition; typedef cannot be overloaded with any other symbol
c:\program files\microsoft visual studio\vc98\include\windef.h(161) : see declaration of 'INT'
c:\dsqlm_1\include\dsql_m_structs.h(47) : error C2377: 'FLOAT' : redefinition; typedef cannot be overloaded with any other symbol
c:\program files\microsoft visual studio\vc98\include\windef.h(145) : see declaration of 'FLOAT'
c:\dsqlm_1\include\dsql_m_structs.h(47) : error C2377: 'CHAR' : redefinition; typedef cannot be overloaded with any other symbol
c:\program files\microsoft visual studio\vc98\include\winnt.h(134) : see declaration of 'CHAR'
c:\dsqlm_1\include\dsql_m_structs.h(48) : error C2377: 'BOOL' : redefinition; typedef cannot be overloaded with any other symbol
c:\program files\microsoft visual studio\vc98\include\windef.h(142) : see declaration of 'BOOL'
c:\dsqlm_1\include\dsql_m_structs.h(64) : error C2146: syntax error : missing ';' before identifier 'unique'
c:\dsqlm_1\include\dsql_m_structs.h(64) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(64) : error C2501: 'unique' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(65) : error C2146: syntax error : missing ';' before identifier 'indexed'
c:\dsqlm_1\include\dsql_m_structs.h(65) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(65) : error C2501: 'indexed' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(66) : error C2146: syntax error : missing ';' before identifier 'nullable'
c:\dsqlm_1\include\dsql_m_structs.h(66) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(66) : error C2501: 'nullable' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(67) : error C2146: syntax error : missing ';' before identifier 'in_active'
c:\dsqlm_1\include\dsql_m_structs.h(67) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(67) : error C2501: 'in_active' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(70) : error C2629: unexpected 'class Column ('
c:\dsqlm_1\include\dsql_m_structs.h(70) : error C2238: unexpected token(s) preceding ';'
c:\dsqlm_1\include\dsql_m_structs.h(83) : error C2061: syntax error : identifier 'boolean'
c:\dsqlm_1\include\dsql_m_structs.h(84) : error C2146: syntax error : missing ';' before identifier 'isUnique'
c:\dsqlm_1\include\dsql_m_structs.h(84) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(85) : error C2061: syntax error : identifier 'boolean'
c:\dsqlm_1\include\dsql_m_structs.h(86) : error C2146: syntax error : missing ';' before identifier 'isIndexed'
c:\dsqlm_1\include\dsql_m_structs.h(86) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(87) : error C2061: syntax error : identifier 'boolean'
c:\dsqlm_1\include\dsql_m_structs.h(88) : error C2146: syntax error : missing ';' before identifier 'isNullable'
c:\dsqlm_1\include\dsql_m_structs.h(88) : error C2501: 'boolean' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(99) : error C2143: syntax error : missing ';' before '*'
c:\dsqlm_1\include\dsql_m_structs.h(99) : error C2501: 'Database' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(99) : error C2501: 'db' : missing storage-class or type specifiers
c:\dsqlm_1\include\dsql_m_structs.h(103) : error C2629: unexpected 'class Table ('
c:\dsqlm_1\include\dsql_m_structs.h(103) : error C2238: unexpected token(s) preceding ';'
c:\dsqlm_1\include\dsql_m_structs.h(151) : error C2143: syntax error : missing ';' before '}'
c:\dsqlm_1\include\dsql_m_structs.h(151) : error C2143: syntax error : missing ';' before '}'
c:\dsqlm_1\include\dsql_m_structs.h(151) : error C2143: syntax error : missing ';' before '}'
c:\dsqlm_1\include\sql_lexer.h(39) : error C2143: syntax error : missing ';' before '{'
c:\dsqlm_1\include\sql_lexer.h(39) : error C2447: missing function header (old-style formal list?)
c:\dsqlm_1\include\bridge.h(101) : error C2079: 'table' uses undefined class 'Table'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(18) : error C2143: syntax error : missing ';' before '__stdcall'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(18) : error C2501: 'BOOL' : missing storage-class or type specifiers
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(18) : error C2371: 'BOOL' : redefinition; different basic types
c:\dsqlm_1\include\dsql_m_structs.h(48) : see declaration of 'BOOL'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(38) : error C2143: syntax error : missing ';' before '__stdcall'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(38) : error C2501: 'BOOL' : missing storage-class or type specifiers
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(38) : error C2371: 'BOOL' : redefinition; different basic types
c:\dsqlm_1\include\dsql_m_structs.h(48) : see declaration of 'BOOL'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(425) : error C2143: syntax error : missing ';' before 'tag::id'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(425) : error C2501: 'BOOL' : missing storage-class or type specifiers
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(425) : error C2371: 'BOOL' : redefinition; different basic types
c:\dsqlm_1\include\dsql_m_structs.h(48) : see declaration of 'BOOL'
D:\Programming\Projects\VC++ Projects\MordredsHaven\MHExtension.cpp(425) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Something to do with the types already defined in windef.h.. but i don't see why it says that since there's no type redefinition, just an enum, like this (dsql_m_structs.h):
class MyDate;
namespace dsqlm {
class Database;
enum boolean { FALSE=0,TRUE=1 };
enum DsqlType {SMALLINT,INT,BIGINT,FLOAT,DOUBLE,CHAR,VARCHAR,
DATE,TIME,TIMESTAMP,BOOL,AUTOID,UID};
enum ComparissonOperator {EQUALS,NOT_EQUALS,GREATER_THAN,LESSER_THAN,
GREATER_THAN_OR_EQUAL_TO,LESSER_THAN_OR_EQUAL_TO,
LIKE};
enum LogicalOperator {AND,OR};
...
Does anyone see how i could fix it? I really need the database..
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Hello,
Here is the question:
Is it possible to modify an exception inside a catch block and then rethrow it ?
Under
http://www.codeproject.com/cpp/ANSI-cpp-dec96/except.asp
the only point I see connected to this question is:
19When the handler declares a non-constant object, any changes to that
object will not affect the temporary object that was initialized by
execution of the throw-expression. When the handler declares a refer-
ence to a non-constant object, any changes to the referenced object
are changes to the temporary object initialized when the throw-expres-
sion was executed and will have effect should that object be rethrown.
But this is confusing to me because it seems that is possible to modify a
const exception while it is not possible to modify a non const exception:
which is exactly the contrary that I would expect !
like:
<br />
catch ( BasicException& e ) {<br />
e.setMessage( e->getMessage() + " some more informations here " );
throw;
}<br />
<br />
catch ( const BasicException& e ) {<br />
e.setMessage( e->getMessage() + " some more informations here " );
throw;
}
Thank you in advance for any answer
Marcello
P.S.
If it is not clear enough what I need to do, here is an example:
<br />
typedef std::basic_string<VCFChar> String;<br />
<br />
class BasicException : public std::exception {<br />
public:<br />
BasicException( const VCF::String & message ) {<br />
message_ = message;<br />
}<br />
<br />
void setMessage( const VCF::String & message ) {<br />
message_ = message;<br />
}<br />
String getMessage () {<br />
return message_;<br />
}<br />
String message_;<br />
}<br />
<br />
<br />
class A {<br />
void f() {<br />
bool error = true;<br />
if ( error ) {<br />
throw BasicException( "original message" );<br />
}<br />
}<br />
<br />
void g() {<br />
try {<br />
f();<br />
}<br />
catch ( BasicException& e ) {<br />
e.setMessage( e->getMessage() + " some more informations here " );<br />
throw;
}<br />
};<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
A a;<br />
try {<br />
a.g();<br />
}<br />
catch ( BasicException& e ) {<br />
cout << e.getMessage() << endl;<br />
}<br />
}<br />
|
|
|
|
|
The paragraph states precisely what one would expect, i.e that non-const references to exception objects allow for modyfing and the changes will go up the stack if the object is rethrown. That is, no surprises here.
If you read it carefully, the first part says a non-constant object, as in
catch(BasicException e) and the second refers to non-constant references as in
catch(BasicException& e) In the first case, what the catch handler gets is a copy of the thrown object, exactly as when you call a regular function with signature foo(BasicExceotion e) . In the second case, you get a reference to the original object and modifying can be done freely.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you very much
I guess my neurons started crossing with each other
Sometimes the C++ specifications language is very hard to follow
Now this is very clear
Cheers,
Marcello
|
|
|
|
|
Hello there,
I'm getting these linker errors when I compile and execute my VC++ MFC OpenGL application.
I've included the header files for OpenGL.
I've checked all functions for correct parameter type.
Open.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
Open.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
Open.obj : error LNK2001: unresolved external symbol _gluPerspective@32
Open.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
Open.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
Open.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
Open.obj : error LNK2001: unresolved external symbol __imp__glHint@8
Open.obj : error LNK2001: unresolved external symbol __imp__glDepthFunc@4
Open.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
Open.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
Open.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
Open.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4
Open.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
Open.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
Open.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
Open.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
Open.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
Open.obj : error LNK2001: unresolved external symbol __imp__glClear@4
Debug/Gest_Rep.exe : fatal error LNK1120: 18 unresolved externals
Any ideas whats wrong?
Thanks in advance.
|
|
|
|
|
Looks like you forgot to actually link to the opengl libraries. Do it and the errors will go away.
--
I am perpetual, I keep the country clean.
|
|
|
|
|
Did it and the errors went away
|
|
|
|
|
Given an executable compiled using VC++ (unmanaged), is there a way to identify if the EXE is a debug or release build? Obviously, if you had the two builds side by side, the larger would be the debug, but is there a way to detect if the EXE is a debug build?
Regards
|
|
|
|
|
Well one way would be to check its DLL dependancies and if it was using the MFC/CRT Debug DLL's you'd now. There are probably better ways.
IMO Debug .EXE's should be able to identified by their filename, in the same way Debug DLL's are.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
how about
#ifdef _DEBUG
/* do something here */
#endif
is that what you were asking?
~LizardWiz()
|
|
|
|
|
No, I was looking more for something to determine if a selected EXE is a debug build or not. Not from within code, but if someone just hands you an EXE, how can I determine if it is a DEBUG build.
I think Neville answered my question...just wish there was a little easier solution. I was hoping for something more programmatic...an app I could drag and drop an EXE into or a shell extension that I could use to right click and select on an EXE in Explorer.
thanks for the response, though.
|
|
|
|