|
Mike,
Sometimes, it just helps when someone forces you to look at your code again eh!!? Whilst we've been discussing this, I converted the template class so that it simply used standard members and discovered that there was a general error in some of my logic that was making it appear that these static constants were getting initialised to 1. Of course, however, they weren't - as you've demonstrated and I've just verified.
What didn't help - and I'm not going mad on this one - is that the VC++ debugger picks up these values at run-time as 1 (perhaps understandably, since their values are dependent on the template args), regardless of what value they actually have, therefore I had just assumed that the compiler was stupid, and not me. I should have remembered that the console project is my friend when it comes to debugging values.
Thanks to your help, I have now converted it back to static constants and have received a fifth of a second speed increase over the course of 250,000 operations that will use this class - not much, but enough for me to be happy !
Thanks very much for your help,
Zoltan
I'm not as evil as my name suggests
|
|
|
|
|
Great, I'm glad it worked out for you. Funny thing about the debugger, you could report that to MS so they fix it for Whidbey.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
Actual sign at the laundromat I go to: "No tinting or dying."
"Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."
-- Michael P. Butler in the Lounge
|
|
|
|
|
Hello,
Is anyone knows how to remove template from mdi that was added by
Suppose i made 2 doc tempates:
CMultiDocTemplate* Template1;<br />
CMultiDocTemplate* Template2;<br />
<br />
Template1 = new CMultiDocTemplate(IDR_RENTCATYPE, RUNTIME_CLASS(CMyAppDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(Form1));<br />
<br />
Template2 = new CMultiDocTemplate(IDR_RENTCATYPE, RUNTIME_CLASS(CMyAppDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(Form2));<br />
<br />
AddDocTemplate(Template1);<br />
AddDocTemplate(Template2);<br />
HOW DO I REMOVE ONE/ALL OF THE TEMLPATES ??? ( or at least change them );
Thank You in Advance.
P.S. Help Please, SOS
|
|
|
|
|
Hi.
I am quite new to windows and MFC programming and I have over the last few months, been developing an application that 'does stuff'.
Now, I have decided that given the design, it would be much more suited to the 'DLL' concept. So, I would like to convert the application to a client/server approach.
So, with a view to testing some of the 'needed' functionality, I created a very simple client and server.
One or both client(s) and server require the use of MFC, that is to say, neither derive classes from MFC but the server uses MFC functions; CString, Afx.. stuff. The client may also use MFC stuff CString etc..
Before I describe the problem, it might, but I dont know if it is relevent to note that both client and server link in MFC dynamically.
Anyway, I define a very simple server function that accepts an LPCTSTR which it should display in a message box.
However, I keep getting the same debug error after the call from the client to the server completes:
Debug Error!
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a differnt calling convention.
I have tried all sorts of combinations of call conventions and I have now hit a brick wall.
Any advice or pointers would be much appreciated.
Best regards.
James.
|
|
|
|
|
The simple answer is that you must use the same calling convention.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Without the source and project files it will be tough to help you with this problem.
It could be compiler settings on one source module are different than another.
It could be something funky being done with a function pointer.
It could be some kind of memory corruption.
It could be ... ?
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I have a dialog in a DLL and how can I mininaze that dialog to the system tray?. I have try some standard tray app but I don't get it to work in the dialog is in a DLL.
How can I make this happend? Please
|
|
|
|
|
Hello everyone.
I want to display the hand cursor over an item when it is selected in a tree control list? Please help me.
|
|
|
|
|
Hello. I am trying to write a database program that is similar to a punch out clock. This is for a small restaurant with 25 employees. What i would like to implement is a time clock program that keeps track of when and how many hours an employeee works.
Right now I have one table in my database, named
Employee Info, besides that i am stuck. Here is my problem. I do not know if i should create a new table for every employee that is currently employeed and keep track of when he/she has worked and for how long. Or should i just dump every employee into one table and sort the table according to employee id?
Some advice would be greatly appreciated.
One thing, an employee normally punches in, punches out for a brake, punches back to work and than punches out at the end of the night....
Please help..
|
|
|
|
|
crimsongrape wrote:
create a new table for every employee that is currently employeed and keep track of when he/she has worked and for how long
No.
crimsongrape wrote:
dump every employee into one table and sort the table according to employee id
make that "every employee timestamp".
You could have :
employee table (as you have)
timecard table with employee id, punch in, punch out times, and total time as a calculated field.
Make sure you check for employees punching in with an existing 'open' timecard record (ie they forgot to punch out last time).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
i insert a picture object in the richedit control, it will rise ON_CHANGE notify,
but the function ReplaceSel will cause a reentrancy in win98, in win2k, it will not,
so strange!
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_EN_CHANGE(IDC_RICHEDIT, OnChangeRichedit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyDialog::OnChangeRichedit()
{
int nEnd = m_editRich.GetTextLength();
m_editRich.ReplaceSel("TestValue"); //when run in "ReplaceSel", it will call OnChangeRichedit() immediately,
//it reentrant! so it does not work well!
int nLabel = m_editRich.GetTextLength();
}
i want to known the reason that the function "ReplaceSel" will cause reentrancy in windows 98, any reply is expected!
|
|
|
|
|
So far this is what I got. I am attempting take a simple answer from a user and output the right string.
#include "iostream.h"<br />
#include "windows.h"<br />
<br />
void main(void)<br />
<br />
{<br />
int age;<br />
int date;<br />
int y;<br />
int n;<br />
<br />
cout << "User what is your age?\n";<br />
cin >> age;<br />
cout << "So user you are " << age;<br />
cout << " years of age?\n";<br />
cout << "User I have a fraise you should see!\n";<br />
cout << "Would you like to see the fraise?\n";<br />
cin >> if y else<br />
cout << "Hello World!\n";<br />
cin if n else cout << "Well I hope you have a good day";<br />
}
You NEVER KNOW till you TRY
|
|
|
|
|
How can make my dialog windows get to the top of the right on my desktop?
|
|
|
|
|
Get the dimensions of the screen by calling GetWindowRect() , then call MoveWindow() on your dialog.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Additionally, get the desktop width via GetSystemMetrics(SM_CXSCREEN) . Then, move your window to (0|screenwidth-appwidth).
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks! I will try use that.
|
|
|
|
|
I have a Smart Card SDK , it contains one .dll file, .h header file and nothing else.
He given one SDK document containing all the Smart Card WINAPI functions.
I am new to VC++.
So i want to know how to write program in VC++ to read and write data from/to smart card.
How to use the .dll and .h file in this program to access the device ?
|
|
|
|
|
jsaroj wrote:
I have a Smart Card SDK , it contains one .dll file, .h header file and nothing else.
He given one SDK document containing all the Smart Card WINAPI functions.
yeah i think file name are Winscard.h,winscard.dll
i have little question pls don't mind do u know how to use external dll in the project ,if not search mdn for loadlibrary and getprocaddress api's
jsaroj wrote:
So i want to know how to write program in VC++ to read and write data from/to smart card.
yeah i too have worked with the smartcard but using com port not with api's yeah,if you havbe some sample with your sdk,send it to me i will help you to understand that ok.
actually the smartcard are harwdare dependent,some menufacture smartcard device work on different command set and other on different there are a few manufacture who actually following the ms smartcard api,is you reader manaufacturer is compliant with ms.
ok
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I'm developing a program by GDI but I has a knotty problem when i use the function pDC->SetMapMode(MM_LOMETRIC);
When it runs on my computer is good but shapes(as ellipe, square, circle,...) are crooked when my application runs on other computer, I don't know why... Please help me...thanks.
|
|
|
|
|
Hello,
I am loading a dll from an app (.exe) and it has to remain in memory after the app terminates execution.
Well, the problem i've been having consists in that whenever the app stops running, the dll is automatically freed (possibly because it is associated with the creating thread/instance.)
How can I prevent this from happening? I mean, how can I make the Dll remain in memory until it receives a notification saying it can terminate?
Thanks,
Dave
BTW: it is a dll with MFC support...
|
|
|
|
|
dNimrod#X wrote:
I am loading a dll from an app (.exe) and it has to remain in memory after the app terminates execution.
And do what exactly ?
The dll is just a bunch of functions, the exe is the main thread of execution.
What are to trying to accomplish ?
...cmk
Save the whales - collect the whole set
|
|
|
|
|
dNimrod#X wrote:
how can I make the Dll remain in memory until it receives a notification saying it can terminate?
What you're asking doesn't make sense. By definition, a DLL is a library - it is an extension to an application. It makes no sense to have a library in memory without an application using it.
Basically, you can't do this. Windows automatically frees all libraries when you close your application. There is nothing you can do about it, by design. If you want your DLL to stay in memory, your application has to stay in memory as well.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Hi,All,I am developing an ACTIVEX control embedded in IE, which is used to display continuous jpegs captured from a server.Firstly I wrote my ACTIVEX control in MFC,and call InvalidateControl() to realize control window redraw.It is ok.Then I rewrote my ACTIVEX in ATL,most of the code regards to grapic are same,but this time since InvalidateControl() can not be called in ATL based control, I call FireViewChange() to realize control window redraw time by time.However,I found that the control window got flicker when it is redraw.What happened and how to deal with?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|
Hi
I have made one DCOM application which runs successfully but at the end it hangs out and doesn't gets closed in normal way...Any help or any idea...
All statements are getting executed very well in sequences...but at the end it is not returning as it should return at the point of call.
I used this small DCOM application in my VB application. At the point where I call this DCOM it runs well and does all the task that I want it to do. It's control also goes at the last line i.e "return S_OK" but then it hangs out.
Any one have any idea plz..my whole code is written here...
-----------------------------------------------------------
STDMETHODIMP CDConv::vAiConvert(VARIANT vTrace, VARIANT vDevID, VARIANT vInFileName, VARIANT vOutFileName, VARIANT vCOpt, VARIANT vSOpt, VARIANT vPrefix, VARIANT vFileTitle, VARIANT vTimeDelta, VARIANT vFlag, VARIANT *vReturnValue, VARIANT *vRetValue)
{
// TODO: Add your implementation code here
int iTrace = 0;
int iTimeDelta = 0;
char *sDevID = new char[1024];
char *sInFileName = new char[1024];
char *sOutFileName = new char[1024];
char* sDstFile = new char[_MAX_PATH + _MAX_FNAME];
char *sCOpt = new char[1024];
char *sSOpt = new char[1024];
char *sPrefix = new char[1024];
char *sFileTitle = new char[1024];
long fp = 0;
BOOL bFlag = true;
FILE *fd;
fd = fopen("C:\\AiDebug.txt","a+");
//setvbuf( fd, NULL, _IONBF, 0 );
fprintf(fd,"========================================================================================================================\n\n");
try
{
bFlag = vFlag.boolVal;
fprintf(fd,"try...bFlag = %d",bFlag);
}
catch(...)
{
bFlag = true;
}
try
{
iTrace = vTrace.intVal;
fprintf(fd,"try...iTrace = %d\n",iTrace);
}
catch(...)
{
iTrace = 0;
fprintf(fd,"catch...iTrace = %d\n",iTrace);
}
try
{
strcpy(sDevID, (char*)(_bstr_t)vDevID.bstrVal); // pa@aileron.ws
fprintf(fd,"try...sDevID = %s\n",sDevID);
}
catch(...)
{
strcpy(sDevID,"");
fprintf(fd,"catch...sDevID is empty\n",sDevID);
}
try
{
strcpy(sInFileName, (char*)(_bstr_t)vInFileName.bstrVal);
fprintf(fd,"try...sInFileName = %s\n",sInFileName);
}
catch(...)
{
strcpy(sInFileName,"");
fprintf(fd,"catch...sInFileName = %s\n",sInFileName);
}
try
{
strcpy(sOutFileName, (char*)(_bstr_t)vOutFileName.bstrVal);
fprintf(fd,"try...sOutFileName = %s\n",sOutFileName);
}
catch(...)
{
strcpy(sOutFileName,"");
fprintf(fd,"catch...sOutFileName = %s\n",sOutFileName);
}
try
{
strcpy(sCOpt, (char*)(_bstr_t)vCOpt.bstrVal);
fprintf(fd,"try...sCOpt = %s\n",sCOpt);
}
catch(...)
{
strcpy(sCOpt,"");
fprintf(fd,"catch...sCOpt = %s\n",sCOpt);
}
try
{
strcpy(sSOpt, (char*)(_bstr_t)vSOpt.bstrVal);
fprintf(fd,"try...sSOpt = %s\n",sSOpt);
}
catch(...)
{
strcpy(sSOpt,"");
fprintf(fd,"catch...sSOpt = %s\n",sSOpt);
}
try
{
strcpy(sPrefix, (char*)(_bstr_t)vPrefix.bstrVal);
fprintf(fd,"try...sPrefix = %s\n",sPrefix);
}
catch(...)
{
strcpy(sPrefix,"");
fprintf(fd,"catch...sPrefix = %s\n",sPrefix);
}
try
{
strcpy(sFileTitle, (char*)(_bstr_t)vFileTitle.bstrVal);
fprintf(fd,"try...sFileTitle = %s\n",sFileTitle);
}
catch(...)
{
strcpy(sFileTitle,"");
fprintf(fd,"try...sFileTitle = %s\n",sFileTitle);
}
try
{
iTimeDelta = vTimeDelta.intVal;
fprintf(fd,"try...iTimeDelta = %d\n",iTimeDelta);
}
catch(...)
{
iTimeDelta = 0;
fprintf(fd,"catch...iTimeDelta = %d\n",iTimeDelta);
}
//AiConvertDoc(iTrace, sDevID, sInFileName, sOutFileName, sCOpt, sSOpt, sPrefix, sFileTitle, iTimeDelta);
try
{
if(AiConvertDoc(iTrace,sDevID,sInFileName,sOutFileName,sCOpt,sSOpt,sPrefix,sFileTitle,iTimeDelta) == false)
{
if (iTrace > 0)
{
fprintf(fd,"Else part AiconvertDoc Failed");
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI12", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
}
}
catch(...)
{
if (iTrace > 0)
{
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI12", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
}
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
if(strlen(sOutFileName) != 0)
{
fprintf(fd,"sOutFileName = %s\n",sOutFileName);
_splitpath (sOutFileName, drive, dir, fname, ext);
sprintf(sDstFile,"%s%s%s.OUT",drive,dir,fname);
fprintf(fd,"sDstFile = %s\n",sDstFile);
}
else
{
if (iTrace > 0)
{
fprintf(fd,"sOutFileName....NULL\n");
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI12", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
}
FILE *fin, *fout;
fin = fopen(sOutFileName, "rb");
if(_filelength(fileno(fin)) > EMAIL_ATTACHMENT_MAX)
{
fclose(fin);
if (sOutFileName)
sOutFileName = NULL;
// Return an erro File size not supported
if (iTrace > 3)
{
fprintf(fd,"Attachement Size Too Big %ld\n", GetLastError());
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI13", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
}
if (fin)
{
fout = fopen(sDstFile, "wb");
if (fout)
{
int cNum;
while ((cNum = fgetc(fin)) != EOF)
{
switch(cNum)
{
case 0:
fputc(171, fout);
break;
case 13:
fputc(175, fout);
fputc(174, fout);
break;
case 171:
fputc(175, fout);
fputc(171, fout);
break;
case 175:
fputc(175, fout);
fputc(175, fout);
break;
default :
fputc(cNum, fout);
break;
}
}
fclose(fout);
}
fclose(fin);
}
if((fp = _open( sDstFile, _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE )) != -1)
{
// If Trace is Enabled: Notify status
if (iTrace > 1)
{
fprintf(fd,"File Transfer Successfull...\n");
}
long fLen = _filelength(fp) ;
if(fLen < EMAIL_ATTACHMENT_MAX)
{
VarAdd(vReturnValue, &(_variant_t)"B", vReturnValue);
VarAdd(vReturnValue, &(_variant_t)sDstFile, vReturnValue);
VarAdd(vReturnValue, &(_variant_t)"", vReturnValue);
VarAdd(vReturnValue, &(_variant_t)sPrefix, vReturnValue);
VarAdd(vRetValue, &(_variant_t)"TRUE", vRetValue);
printf("After making string DEL B DstFile DEL sPrefix\n");
}
else
{ // Return an erro File size not supported
if (iTrace > 3)
{
fprintf(fd,"Attachment size too big \n");
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI14", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
}
_close(fp);
} /// End of if((fp = _open( sDstFile, _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE )) != -1)
else
{
// If Trace is Enabled: Notify status
if (iTrace > 3)
{
fprintf(fd,"Converted file could not be read \n");
VarAdd(vReturnValue, &(_variant_t)"RNN10SGI15", vReturnValue);
VarAdd(vRetValue, &(_variant_t)"FALSE", vRetValue);
goto Terminate;
}
/* We are returning nothing here currently We may be changing it in future */
}
DeleteFile(sOutFileName);
DeleteFile(sInFileName);
fprintf(fd,"All Task Completed...\n");
Terminate:
fprintf(fd,"After Terminate successfull...\n");
if(sCOpt) delete [] sCOpt;
if(sSOpt) delete [] sSOpt;
if(sDstFile) delete [] sDstFile;
if(sOutFileName) delete [] sOutFileName;
if(sFileTitle) delete [] sFileTitle;
if(sInFileName) delete [] sInFileName;
fprintf(fd,"After deleteing all successfull...\n");
// Uninitialize COM Objects
::CoUninitialize();
fprintf(fd,"After CoUnitialize...\n");
fclose(fd);
return S_OK;
}
|
|
|
|
|