|
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem?
Here is code :
try
{
*((char*)0)=1;
}
catch(...)
{
}
It is MFC app in VC6.0.
Thank you.
|
|
|
|
|
This is the difference between C++ typed exceptions and Win32 structured exceptions. What you have is the former. See _set_se_translator() for more.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank you. I'm going to check it.
I wonder why debug mode caught the exception. Does debug mode use some default translator?
|
|
|
|
|
rrrado wrote: I wonder why debug mode caught the exception.
I'm really not sure, but it may have to do with the optimizer.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
rrrado wrote: I wonder why debug mode caught the exception
Might be because you set the "Enable C++ Exception=> YES with Structured exception (/EHa)" for debug configuration settings but not for release configuration.
|
|
|
|
|
In C++ - assuming the implementation follows the standard - catch is only allowed to catch exceptions raised using the throw keyword: since this isn't the case in your example the code in the catch block should NOT be executed. MSVC6 got this wrong but the bug has been corrected in later versions. The /EH[^] switch can be used to reinstate the bug.
Steve
|
|
|
|
|
|
Hi all...
I'm using CxImage to load and draw PNG. Either in dialog box or preferably on desktop screen.. Need help how to draw the PNG. So far i did this.
CxImage* newImage = new CxImage();
newImage->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG1),"PNG"),CXIMAGE_FORMAT_PNG);
Thanks.
|
|
|
|
|
For PNG files you can use of CImage class and its easy to use.
|
|
|
|
|
I guess Cimage and CxImage are sort of same thing..
Neverthless how can i do with Cimage Class..
Thanks..
|
|
|
|
|
Surely CxImage must have rendering methods.
Look for methods called Draw()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark...
After i call this.
newImage->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG1),"PNG"),CXIMAGE_FORMAT_PNG);
How do i call Draw??
Draw has these two declaration..
long Draw(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0, bool bSmooth = false);
long Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL, bool bSmooth = false);
Thanks..
|
|
|
|
|
Till now i've done this with no success.. Trying to draw PNG on desktop.
HBITMAP m_bitmap = NULL;
CxImage image("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.png", CXIMAGE_FORMAT_PNG);
HWND hDesktop = GetDesktopWindow();
HDC hdc = GetDC(hDesktop);
m_bitmap = image.MakeBitmap(hdc);
image.Draw(hdc);
Where am i wrong?
|
|
|
|
|
Edited..
Now i'm doing something like this.. This should disply PNG on picture control..But no success..
case WM_INITDIALOG:
{
HBITMAP m_bitmap = NULL;
CxImage image("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.png", CXIMAGE_FORMAT_PNG);
RECT rect;
HWND hImage = GetDlgItem(hWnd, IDC_DRAW_IMAGE);
GetClientRect(hImage, &rect);
int rectHeight = rect.bottom - rect.top;
int rectWidth = rect.right - rect.left;
int height = image.GetHeight();
int width = image.GetWidth();
int xpos = 0;
int ypos = 0;
if(height > rectHeight || width > rectWidth)
{
double ratiox = (double)rectWidth /(double)width;
double ratioy = (double)rectHeight/(double)height;
double ratio = ratiox > ratioy? ratioy: ratiox;
width = width * ratio;
height = height * ratio;
image.Resample(width, height);
image.Save("E:\\My_Prog\\FINAL_PNG\\Res\\eScan.bmp", CXIMAGE_FORMAT_BMP);
}
xpos = (rectWidth - width)/2;
ypos = (rectHeight - height)/2;
HDC hdc = GetDC(hImage);
image.Draw(hdc, xpos, ypos);
break;
}
|
|
|
|
|
You don't draw on "picture controls". Picture controls keep their own
bitmap and render it themselves.
Try getting your image to render on the window first, then maybe work
on rendering on a child window.
This isn't a CxImage support site, and I've never used the library,
nor am I going to research the documentation, so it's tough to figure
out what's not working.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
There is, as you probably know, the CxImage article, here [^] at CodeProject . On the web there is also the library documentation page [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Like this:
CImage m_Image;
m_Image.Load(_T("yourfile");
m_Image.BitBlt(hdc,0,0);
|
|
|
|
|
Hi all
I am getting an error message in my application "This application has failed to start because cximagecrtd.dll was not found".
I tried to download the cximagecrt.dll/cximagecrtd.dll from net. But i couldn't able to find anywhere. Can some one please provide this for me.
Thanks in advance.
Regards,
Balaram.
Regards,
balaram
|
|
|
|
|
Hi all,
In my mfc application I have a main window which has no title bar, no resizing frame, no border n all. I am programmatically creating title bar and maximize and minimize buttons.
For resizing and move operations I am handling hit test messages.
But since I have no title bar so system menu doesn’t appear by default, and also left click on task bar doesn’t maximize the window.
For this to work I added WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU styles to my frame window. Everthing started working sysmenu on right click,maximize,minimize,move n all but unexpectedly resizeing stopped working. If I remove WS_SYSMENU resize starts working. I have no idea what happened. One solution thought was to add WS_THICKFRAME to the window but I don’t want to use it as it changes the look of window which client doesn’t want.
Can you suggest something on this?
|
|
|
|
|
Hi All
How can i convert String to ascii?I have a file type txt and i want to write string in form of asci.So plz help me
|
|
|
|
|
cpvc++ wrote: How can i convert String to ascii?
What format is your string in?
What does your string look like and how is it declared?
Are you using any wrapper classes like CString , std::string or similar?
What have you tried so far and how does it fail?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Why so many questions, Roger? How is this guy supposed to get any work done when he has to spend half his day answering questions. At this rate, he'll never get around to using the debugger or reading any documentation.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Seriously, I really laughed out loud at the office and had to apologize to my colleagues.
Thanks David, I really needed a good laugh.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
David, you're terrific some days
|
|
|
|
|
Usually the text files are encoded using ASCII . Is your text file encoded using UNICODE ?
Could you kindly elaborate?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|