|
"In our team, I do not accept c++ code which contains other free store queries than new and delete" ...
For a Windows application? No wonder the memory gets fragmented.
What about HeapCreate/HeapAlloc/HeapFree for larger custom data objects?
VirtualAlloc/VirtualFree for large data objects? The fastest one there - evrything else just layers on top of VirtualAlloc.
|
|
|
|
|
The Gdiplus Bitmap:Save method returns void and generates two exceptions, ArgumentNullException and ExternalException, neither of which cover the case where a save fails because, say, there is not enough space on the disc or trying to write to a read-only disc. Can anyone tell me how to detect such a failure. My program seems to silently ignore such failures. Thanks for any help.
Niklas Lindquist's suggestion of calling GetLastError solves the problem. After a little experimentation I discovered that Bitmap::Save set the last error to 0 if it succeeds so if GetlastError((0 returns a non-zero value there has been an I/O error. Thanks for the two replies.
-- Modified Tuesday, August 24, 2010 2:33 PM
|
|
|
|
|
One idea could be to check if GetLastError() changes.
(and please don't cross post[^])
|
|
|
|
|
Thanks for your reply which has helped me to solve my problem. I found that Bitmap::Save sets the last error to 0 if (it thinks) it is successful and non-zero if it fails.
Sorry about the cross-post. This is my first attempt at using the bulletin board and I thought that my first post had failed.
Thanks again for your help.
Hugh McIntyre.
|
|
|
|
|
No problem
|
|
|
|
|
Hi,
I have a very strange problem with edit controls in Windows 7 (Ultimate), where once the number of characters exceeds a certain number, the contents become invisible. The text is still there, and can be copied, edited etc, but it is just not shown. Deleting characters makes it re-appear.
I have reproduced this in a new MFC project, using Visual Studio 2010, just by making a dialog app which has a single-line edit control on its dialog.
I have found that the exact number of characters required to make the text disappear depends on the text. For instance, filling the control with the letter 'i', it takes 16379 chars to become invisible, but for the letter 'W' it takes 3275. For '_', it takes 5459. I wondered if it was the size in pixels that caused the problem, and found (using GetTextExtent on the edit control's DC) that for the letter 'i' the width was 65516 pixels, 'W' was 45850 pixels, and for '_' was 43672 pixels, so I can't see any relationship there.
(I am building the app in Visual Studio 2010 on Vista, though that doesn't make any difference, as an old version of our app built in VS2005 behaves the same in Win7).
Does anyone have any ideas of what is going on?
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV) "A problem well defined is a problem half-solved" – John Dewey
|
|
|
|
|
Hi all,
i analyze some times in 64 bit machine Print and Print Function not responding.
when i debug the code i found in OnPreparePrinting(CPrintInfo* pInfo) function DoPreparePrinting(pInfo) return false.
one more thing i noticed here,this problem occur only when i run my application with Administrator priviledegs means by using "Run An Administrator" option.
but this problem is resolve when i restart the machine.
if i run application without using option run as admin its working fine.but its necesary for my application to run as admin
please tell me how can i resolve the problem without restarting the machine.
thanks in advance.
|
|
|
|
|
Hello all,
I'm trying to print the filename to Dbgview which i receive from GetFileInformationByHandleEx, But it's getting crashed every time..
PFILE_NAME_INFO pFileNameInfo;
DWORD dwFileNameLength = 1024;
DWORD err;
TCHAR szTemp[MAX_PATH] = "";
pFileNameInfo = (PFILE_NAME_INFO)HeapAlloc(GetProcessHeap(), 0, dwFileNameLength);
if(pFileNameInfo != NULL)
{
if(GetFileInformationByHandleEx(FileHandle, FileNameInfo, &pFileNameInfo, dwFileNameLength) != 0)
{
MessageBox(NULL, L"Before Check", L"Success", MB_OK);
OutputDebugStringW(pFileNameInfo->FileName);
}
else
{
err = GetLastError();
swprintf(szTemp, L"Get info Error = %d", err);
MessageBox(NULL, szTemp, L"Error", MB_OK);
}
HeapFree(GetProcessHeap(), 0, pFileNameInfo);
}
else
{
err = GetLastError();
swprintf(szTemp, L"Heap Error = %d", err);
MessageBox(NULL, szTemp, L"Error", MB_OK);
}
Thanks All..
|
|
|
|
|
Have you tried single stepping?
Do you end up with a filename which should be NULL terminated, but is not?
If it's crashing all the time, it sounds simple to find with a debugger! If nothing else, you'll know WHICH line is crashing.
Have you tried with a small filename?
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
You are sending the address of your memory pointer rather than the pointer itself to the GetFileInformationByHandleEx() function. The code should read:
if (GetFileInformationByHandleEx(FileHandle, FileNameInfo, pFileNameInfo, dwFileNameLength) != 0)
Note: no & (addressof operator) on pFileNameInfo .
It's time for a new signature.
|
|
|
|
|
Yes, Silly Mistake, There shouldn't be &.. Thanks
Also how do i get the real path? pFileInfo->FileName gives me "\sample\a.txt"and i need "C:\sample\a.txt"
|
|
|
|
|
gothic_coder wrote: how do i get the real path?
I'm not sure offhand, I would suggest checking the MSDN documentation for this function and seeing if it has any links to other similar functions.
It's time for a new signature.
|
|
|
|
|
Hi,
I am using the CHtmlView derived class in my application to display an html page. However clicking any link in the page opens up by default in Internet Explorer. Is there any way I can make the links in the CHtmlView control to open up in the default browser set in the machine.
For example I set Firefox as the default browser. After that I launch my application and click on the link, it still opens up in IE.
Please let me know if its possible and how?
|
|
|
|
|
An (untested) idea would be to override the OnBeforeNavigate method, and then call ShellExecute on the URL. That will open the URL in the default browser. And of course you have to terminate the request in the CHtmlView.
|
|
|
|
|
Hi,
Thanks for the reply.
Control reaches OnBeforeNavigate2 only for links which open up in the application itself. For hyperlinks which open up in a browser, it reaches
OnNewWindow2 and I can call ShellExecute to open it in the default browser.
But the problem here is that I can't find out the url of the hyperlink that was clicked from inside this function. Is there any way to find it out?
The functions GetLocationURL, GetLocationName, GetFullName don't return the value that is expected.
|
|
|
|
|
I have no means of trying this for the moment, but wouldn't the activeElement[^] be the link that was selected? Just a guess though...
|
|
|
|
|
I saw this article, but I didn't have time to test it yet.
http://www.iol.ie/~locka/mozilla/control.htm
|
|
|
|
|
Hi all,
i want to export data from CListCtrl to excel file.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
There are lots of articles around (try here on CodeProject) about exporting data to Excel, either using ODBC or the Interop interfaces.
It's time for a new signature.
|
|
|
|
|
You can make a clipboard copy function, and format your clipboard text data using tabs and newlines. Then a simple paste in Excel will make the magic happen.
|
|
|
|
|
So are you having trouble "exporting" or "importing?" Be specific.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
write all elemtents separated with a ";" in a csv file. That can excel read.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have an MFC MDI application, with a view based on a dialog template. When the user clicks a button to start a certain operation, I want to change the cursor, then change it back again when the operation finishes.
If I process OnSetCursor in my main frame, this works nicely, except when the user is over a grid control in my view, where it switches back to the default. I've tried adding the same code to an OnSetCursor in the grid window code, but that doesn't help.
Is there no way to 'lock' a cursor change so that I have control over who or what can change it again? (I can't use SetCapture, it doesn't make sense).
The only other way I can think to get around this would be several awfully kludgey calls to SetSystemCursor to change the default system cursor, running the risk of changing the default system cursor by accident.
Also, if I use my own cursor it potentially won't match the current theme. Is there anyway to take the current cursor and overlay something on top (like a plus sign)? Something akin to icon overlays?
|
|
|
|
|
I'm not a Windows GUI specialist, however the way I understand it, you should choose one of these two models:
1.
your GUI is basically unavailable to the user, so you show a wait cursor, but don't accept the user to point, click, or type in that form (which all would be hard anyway lacking a normal cursor). This would be accomplished by modifying the cursor somehow (don't know the details), and disabling a lot of stuff.
2.
your GUI is fully available except for restarting the ongoing action which should not be started again before it finishes. This gets accomplished by leaving the cursor alone, and simply disabling whatever Control started the action (e.g. disabling a Button, or alternatively changing its function and text, say to "Cancel"). Since Controls look different when disabled or you changed the text, that should at the same time be your clue that the action is still on-going.
Hope this helps.
|
|
|
|
|
This was a request from our users and I'm investigating the possibilities. What they want is more of a status indication I think. That is, they want something at the cursor level to show they are in "Adding" mode (say) or "Creating" mode. This wouldn't impact on the behaviour of the app, just serve as an extra visual cue.
I'm starting to think this isn't worth the effort and there are other cues I could use (and already do, maybe they are just too subtle for my users!)
Cheers,
Dan
|
|
|
|
|