السلام عليكم
دالة CreateFont
BOOL CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename );
اريد ان اقوم بوضعها داخل for-loop واغير في Orientation بحيث يقوم برسم كلمة "TEST" أكثر من مره ، المره الاولى على الزاوية 0 ، والثانية على 30 ، والثالثة على 60 ، ... الى 360
هذا هو الكود:
void Creport02Dlg::OnBnClickedCreatefont()
{
// TODO: Add your control notification handler code here
CClientDC pDC(this);
CFont myFont;
myFont.CreateFontW(
20,
10,
0,
0,
0,
FALSE,
TRUE,
FALSE,
0,
OUT_RASTER_PRECIS,
CLIP_DEFAULT_PRECIS,
DRAFT_QUALITY,
DEFAULT_PITCH | FF_DECORATIVE,
_T("Arial")
);
pDC.SelectObject( &myFont);
pDC.TextOutW(50,150, _T("THIS IS A TEST") );
for ( int x = 0; x <= 3600; x+=300 )
{
myFont.CreateFontW(
20,
10,
0,
x,
0,
FALSE,
TRUE,
FALSE,
0,
OUT_RASTER_PRECIS,
CLIP_DEFAULT_PRECIS,
DRAFT_QUALITY,
DEFAULT_PITCH | FF_DECORATIVE,
_T("Arial")
);
pDC.SelectObject( &myFont);
pDC.TextOutW(50,150, _T("THIS IS A TEST") );
}
}المشكلة ان هناك run time error ، لانه عندما اقوم بعملية compile فانه لا يظهر اي خطأ ، لكن عندما اقوم بتشغيل البرنامج تظهر رسالة الخطأ التالية :
--------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Assertion Failed! Program: ... File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\wingdi.cpp Line: 1157 For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press Retry to debug the application) --------------------------- Abort Retry Ignore ---------------------------
حاولت اخراج هذه الدالة خارج for-loop
pDC.SelectObject( &myFont);
لكن لا يوجد فائدة ، نفس الخطأ :(