|
To find the line whre your application crashes you can find out if you build your app in debug mode. At tis time your system will start your debugger at the line your code crashes. But sometimes application crashes only in release therefore you have to insert some debug messages into your code for example Beep or MessageBox. Most crash's causes of not initialized variables therefore you have to initialize all members with valid values.
|
|
|
|
|
E.Satish wrote: how to get into that particular line of code where my application has crashed.
see this link http://www.codeproject.com/debug/mapfile.asp[^]
using MAP files you can find the line where the crash occured...the only downside being for large projects MAP file generated will be huge
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
Why bother using a MAP file? Just build the application with debug info (not a debug build, a release build with debug info). In fact the first changes I make to every project I make is to turn on .PDB generation for release builds.
Steve
|
|
|
|
|
Hello everyone...
Is there a way to give a piece of code exclusive access to the CPU without fear of interruption from Windows?
Something similar to a critical section, but across processes -- not just threads. And in user space... not kernel level or anything. If not, I imagine it's for stability reasons... but I figured there'd at least be *something*.
Any help would be very appreciated... thanks!
- Som
(I posted this in the Visual C++ because I'm using C to program this...)
|
|
|
|
|
No.
Since OS's uses protected mode a program cannot use the processor exclusive (this is not a windows behavior). The function EnterCriticalSection can be used to protect code from reentering in another thread not for exclusive execution on the processor.
|
|
|
|
|
No.
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,
You can try to increase your Thread priority. This sounds like the thing you wanted, but you have to be carefully though, because when doing this you could make the OS instable.
BOOL SetThreadPriority(
HANDLE hThread,
int nPriority
);
Where hThread is the handle of the thread and nPriority is one of the following values:
THREAD_PRIORITY_TIME_CRITICAL<br />
THREAD_PRIORITY_HIGHEST<br />
THREAD_PRIORITY_ABOVE_NORMAL<br />
THREAD_PRIORITY_NORMAL<br />
THREAD_PRIORITY_BELOW_NORMAL<br />
THREAD_PRIORITY_LOWEST<br />
THREAD_PRIORITY_IDLE
codito ergo sum
|
|
|
|
|
what is different between them?
|
|
|
|
|
Use your SDK manual. I think DDX_Control subclasses the given control and DDX_Text exchanges the text.
|
|
|
|
|
what does subclasses mean? it mean use a subclass to override the base class?
|
|
|
|
|
Subclassing in this case is: to attach the control or window to a given class (for instance: CButton).
This class will handle all events for that window.
|
|
|
|
|
Is sub ab. of substitute?
|
|
|
|
|
i can get the code to compile just fine but when i go to launch my application i get an assertion error, i narrowed down the block of code that might be causing it but i also think i am not correctly writing the code to display the bitmap.
this block of code in my OnInitDialog function is where i get the problem from i think.
m_st1.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
m_st1.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew ) );
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
not really messed with graphics coding much before, if soemone could help me out with whats possibly going on i would really appreciate it.
|
|
|
|
|
The assert comes from the previous selected bitmap in your memory DC - 'm_hBmpOld' is null.
To display a bitmap you have to paint it OnPaint() not to select it to an DC (DisplayContext).
HDC mdc;<br />
HGDIOBJ obmp;<br />
BITMAP bmi;<br />
<br />
if(m_hbmp && GetObject(m_hbmp,sizeof(bmi),&bmi))<br />
{<br />
mdc = CreateCompatibleDC(hdc);<br />
obmp = SelectObject(mdc,m_hbmp);<br />
<br />
BitBlt(hdc,offsetx,offsety,bmi.biWidth,bmi.biHeight,mdc,0,0,SRCCOPY);<br />
<br />
SelectObject(mdc,obmp);<br />
DeleteDC(mdc);<br />
}
|
|
|
|
|
tried using the code and sayign hdc is undeclared and when i make it a hdc variable it says oen fo them was used without being initialized. how i set up my dialog was i made a picture control and from there not quite sure exactly what to do, the code you gave by its self wont just display my image as i am sure more code is needed but i get multiple assertions when i load my app and if i ignore them it loads but no image loaded.
this is my code so far(most commented out though) that would do the image loading, but i get multiple assertions.
afx_msg BOOL CPLoader::OnInitDialog()
{
/*CClientDC dc(this);
m_dcMem.CreateCompatibleDC(&dc);
m_hbmp = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
"plogo.bmp",
IMAGE_BITMAP,
300,
65,
LR_LOADFROMFILE);
m_st1.SetBitmap(m_hbmp);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Failed to Load Image");
}
else
{
m_st1.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
m_st1.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
//VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew ) );
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
}*/
return true;
}
afx_msg void CPLoader::OnPaint()
{
HDC mdc, hdc;
HGDIOBJ obmp;
BITMAP bmi;
if(m_hbmp && GetObject(m_hbmp,sizeof(bmi),&bmi))
{
mdc = CreateCompatibleDC(hdc);
obmp = SelectObject(mdc,m_hbmp);
BitBlt(hdc,offsetx,offsety,bmi.bmWidth,bmi.bmHeight,mdc,0,0,SRCCOPY);
SelectObject(mdc,obmp);
DeleteDC(mdc);
}
/*if(IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1)/2;
int y = (rect.Height() - cyIcon +1)/2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.BitBlt(offsetx, offsety, m_size.cx, m_size.cy,
&m_dcMem, sourcex, sourcey, SRCCOPY);
CDialog::OnPaint();
}*/
}
this is based off of an article i read on this site that seemed to do as i wanted but i guess i did not set up right.
|
|
|
|
|
you have to modify your code for using MFC:
CPaintDC dc(this);<br />
<br />
HDC mdc;<br />
HGDIOBJ obmp;<br />
BITMAP bmi;<br />
<br />
if((HBITMAP)m_hbmp && ::GetObject(m_hbmp,sizeof(bmi),&bmi))<br />
{<br />
mdc = ::CreateCompatibleDC(dc.m_hDC);<br />
obmp = ::SelectObject(mdc,m_hbmp);<br />
<br />
::BitBlt(dc.m_hDC,offsetx,offsety,bmi.bmWidth,bmi.bmHeight,mdc,0,0,SRCCOPY);<br />
<br />
::SelectObject(mdc,obmp);<br />
::DeleteDC(mdc);<br />
}
Please mark your code as 'code'.
|
|
|
|
|
Hello,
What does it mean when a structure member declaration is followed by a colon, then a number, as in:
typedef struct tagMENUBARINFO
{
DWORD cbSize;
RECT rcBar;
HMENU hMenu;
HWND hwndMenu;
BOOL fBarFocused:1;
BOOL fFocused:1;
} MENUBARINFO, *PMENUBARINFO, *LPMENUBARINFO;
The "fBarFocused " member has a ":1 " after it. What does that mean?
Thank you very much,
Rich
|
|
|
|
|
|
It specifies how many bits are used to store the variable. In this case it is one bit. Look up "bit fields" in MSDN or see http://www.codeproject.com/cpp/bitbashing.asp[^]
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
As the others have said, it says that that field takes up one bit.
However, don't be tempted to use bit fields in your own structures. They are highly non-portable, even when compiling for the same platform. Different Windows compilers may treat them in different ways. Even different versions of the same compiler on the same platform can treat them differently. Use them only if you can guarantee that you will only ever compile your code with the same compiler (same version, same vendor etc...). The problem is that the C standard does not specify in which order the fields are to appear in memory - compilers are free to do whatever they like.
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"
|
|
|
|
|
Just wondering because...some things...strings, iterators, lists, etc are nice and clean in java and c#, but are ugly or lacking in c++.
Over time i see code project articles try to bring some of that c# goodness to c++, like with delegates, foreach, and properties...so is their any library out there that does this in a big way...make c++ like C# with memory leaks i mean :P
|
|
|
|
|
|
If you've looked at Boost you'd be asking the opposite question. For example the multi index containers and the Boost graph library are unbelivable and only available in C++. Some of what you mention has been available (in the STL) for years, in fact before dotNET even existed - std::string and iterators for example.
Steve
|
|
|
|
|
Hi,
I am having a 16bit ascii file which contains signed integers from -8191 to +8191. These integers are stored in a file in a single row without any delimiters. Can anyone gimme a sample code which can read this kind of file for the signed integers (b/n -8191 and +8191) stored in it or do I need any more info to perform this?
thanks,
-Pav.
|
|
|
|
|
So are you wanting to read the file two bytes at a time? If so, just use a short . To see if you are on the right track, try:
FILE *pFile = fopen("", "rb");
short num1, num2, num3;
fread(&num1, sizeof(short), 1, pFile);
fread(&num2, sizeof(short), 1, pFile);
fread(&num3, sizeof(short), 1, pFile);
fclose(pFile); Now if num1 , num2 , and num3 are correct, you're on your way.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|