|
Thanks Richard. My MFC Application is very old application which is we are using for years. Dont want to change any class inheritances. except to find an alternative to solve the issue.
|
|
|
|
|
Vijjuuu. wrote: Dont want to change any class inheritances.
Well I'm afraid you are stuck with the problem, unless you can figure out some way to speed up your edit control updates.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes i am stuck Thanks for your time for replying.
|
|
|
|
|
As an alternative, see here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks David. My MFC Application is very old application which is we are using for years. Dont want to change any class inheritances. except to find an alternative to solve the issue.
|
|
|
|
|
Another solution might be to separate the logging from the data acquisition. In other words, instead of receiving data from the pipe(s) and immedialtely log it to a control, how about adding the data to some type of container (e.g., string, vector, list) and let the edit control update itself from that container in a separate thread?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Ya i tried that as well but that making my application more slow
|
|
|
|
|
Hi All,
I am using shared memory functions, to write data into file.
Problem:
When I want to write the buffer 10MB, to file using below function, i am able to write only in first iteration, second iteration i could not write buffer next part in to memory. please help me if any suggestion. or any wrong in the below code. i have only control on this part. i dont have control in other part which has CreateFileMapping.
any thing i need to change in "dwFileOffsetLow" or "dwFileOffsetHigh". from second iteration onwards the
"MapViewOfFile" returning null. Some place i got input as I need to repeate call MapViewOfFile different ranges. But how to call, any help?
WriteBuffer function i defined as follows:
BOOL CWriter::Write(char* pMemName,char* pBinary,long lBuffSize)
{
long lUnitSize = MEM_UNIT_SIZE;
if( lBuffSize <= 0 && lUnitSize <=0 )
return FALSE;
HANDLE hFileMMF = OpenFileMapping(FILE_MAP_WRITE,FALSE,pMemName);
if(hFileMMF == NULL)
{
DWORD dwErr = GetLastError();
return (FALSE);
}
int nCount = 0;
nCount = (int)(lBuffSize / lUnitSize) + 1;
for(int n =0; n<nCount; ++n)
{
DWORD dwFileOffsetHigh = 0;
DWORD dwFileOffsetLow = lUnitSize*n;
LPVOID pViewMMFFile = MapViewOfFile(hFileMMF,
FILE_MAP_WRITE,
dwFileOffsetHigh,
dwFileOffsetLow,
MEM_UNIT_SIZE);
if( pViewMMFFile == NULL )
return (FALSE);
CMutex mutex (FALSE, _T("MIPSMMMutexWriter"));
CString strTemp;
strTemp.Format("%s",pBinary);
mutex.Lock();
try
{
CopyMemory(pViewMMFFile,pBinary,lUnitSize); }
catch(CException e)
{
DWORD dw = ::GetLastError();
TRACE1("%d",dw);
}
mutex.Unlock(); UnmapViewOfFile(pViewMMFFile);
}
return (TRUE);
}
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
modified 10-Nov-11 0:02am.
|
|
|
|
|
Probably your MEM_UNIT_SIZE is not a multiple of the page size, which is required[^] by MapViewofFile.
You can determine the page size of the current system by calling GetSystemInfo[^] and retrieve the dwPageSize member.
Helped?
modified 10-Nov-11 5:32am.
|
|
|
|
|
Thanks for your reply.
Hi I tried the same way, and changed approach. Added for loop, and used getsysteminfo and assigned the granularity at unitsize place. But first time the mapview was success and memory copy also success.
In second iteration it is just failing.
modified code as follows...
GetSystemInfo(&systemInfo);
dwGranularity = systemInfo.dwAllocationGranularity;
....
for( int n = 0; n < nCount; ++n )
{
if(n+1 == nCount)
dwLength = lBuffSize - n*dwGranularity;
pViewMMFFile = MapViewOfFile( hFileMMF,
FILE_MAP_WRITE,
dwOffsetStart,
dwOffsetStart + dwGranularity,
dwGranularity);
...
Granularity is getting as 65536, and the output of GetLastError is 5.(AccessDenied).
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
modified 15-Nov-11 3:37am.
|
|
|
|
|
Please post dwGranularity, and the returnvalue of the failed call and the result of GetLastError() after the failed call
(tip: you can see the error code in the debugger using err, hr in the watch window)
|
|
|
|
|
Hi i updated my previous question with error code and granularity aswel. but i read in some link, Mapped File May Not be Automatically Grown[^], for that i need to use SetFilePointer() and SetEndOfFile() it seems. i could not get exactly how i can utilize these two functions. I am trying -> trail and error way..
Am i in right path? ps help if you know ..
thanks.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
This is the first time I am writing code to get the value from a textbox or listbox, in this case listbox
I keep getting squares. I loaded the listbox with TCHAR's, so I thought TCHARS would be appropriate, then I switched to WCHARs.
It's hard to find a good example to follow on the web.
iValue = (int)SendMessage(lb_SQL_Server_Scan_Servers_Field, LB_GETCURSEL, 0, 0);
if (iValue > -1) {
int nLen = SendMessage(lb_SQL_Server_Scan_Servers_Field, LB_GETTEXTLEN, iValue, 0);
pzServerName = new WCHAR[nLen];
int iResult = SendDlgItemMessage(lb_SQL_Server_Scan_Servers_Field, NULL, LB_GETTEXT, iValue, (LPARAM)&pzServerName);
|
|
|
|
|
jkirkerx wrote: int iResult = SendDlgItemMessage(lb_SQL_Server_Scan_Servers_Field, NULL, LB_GETTEXT, iValue, (LPARAM)&pzServerName);
Have you tried:
iResult = SendDlgItemMessage(lb_SQL_Server_Scan_Servers_Field, NULL, LB_GETTEXT, iValue, (LPARAM) pzServerName);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Should I be getting back readable text, or is it a pointer to what I put in it?
|
|
|
|
|
int iResult = SendMessage(lb_SQL_Server_Scan_Servers_Field, LB_GETTEXT, iValue, (LPARAM) pzServerName);
I got readable unicaode text from just using sendmessage. The documentation on getting the value was pretty vague, but now that I know, I can use the other LB_'s and so forth to get values from other methods.
Thanks
|
|
|
|
|
The point was not the function being used but rather you were sending the address of an address to it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I understood the &pzServerName versus pzServerName in the information you presented. I just thought that the & was needed to assign the returned value to pzServerName.
But I wasn't even sure if I was working with the right function at first, the removal of the & cleared things up.
Thanks for the help, the code works good now, on to writing the value to a ini file or something, just need to store the value somewhere.
|
|
|
|
|
Why is it that the Visual C++ 2008 MFC DOC/View based wizard creates an application class InitInstance with the following code checking the result of new being used to dynamically create a CObject derived frame window?
I was under the impression that MFC new would throw on failure
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
|
|
|
|
|
bob16972 wrote: Why is it that the Visual C++ 2008 MFC DOC/View based wizard creates an application class InitInstance with the following code
i'd guess it's because they didn't update that app wizard template.
|
|
|
|
|
This is the code generated by the wizard, which is merely the user application skeleton that the user (i.e. you) modifies to their own requirements. What you have is the minimum necessary and it's up to you to change it to your own needs.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I guess what I'm asking is why do they even check the pointer if MFC claims it will throw on an MFC (CObject derived class) new failure.
|
|
|
|
|
As mentioned elsewhere, this is just some wizard generated code that has not yet been updated. It's really the sort of thing you should be bringing to the attention of Microsoft rather than raising it here.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: It's really the sort of thing you should be bringing to the attention of
Microsoft rather than raising it here
Alrighty then. I'll get a hall pass next time before I start raising questions here
|
|
|
|
|
What is wrong with my suggestion? You are complaining about a Microsoft product, so the logical thing to do is to report it to Microsoft. How else are they going to discover how concerned you are?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|