|
pass the class instance to thread proc as argument and call function from there
e *pE = ...
AfxBeginThread(fnThreadProc, p);
UINT fnThreadProc(LPVOID lpParam)
{
E *pE = (*pE)lpParam;
pE->myMainLoopFunc();
}
|
|
|
|
|
Good idea,
But I have faced some problems.
My e class Objects just get a HWND object in their contructor argument
and draw something on it, in myMainLoopFunc() method How ever the code runs with no error But nothing drwan in the window.
But without threading it works perfectly.
Do you have any idea what's the problem.
|
|
|
|
|
|
sorry But i don't understand your point of view and why should i do this?
|
|
|
|
|
make the HWND to the start parameter of the Threadfunc and construct in the func the new object.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
That made the same problem either, nothing is drawn in the HWND while the dawing methods executed one after another
|
|
|
|
|
can you show me some code?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hello
I've got the following problem with CreateBitmapIndirect(). I've got bitmap data - width, height, bits-per-pixel and array of bits. I'm trying to create HBITMAP by calling CreateBitmapIndirect, but when it's created the biBits of the BITMAP object is NULL. Here is the cpde"
int size = 0, width = 0, height = 0, planes = 0, bpp = 0, r = 0, g = 0, b = 0;
unsigned char* pBits = NULL;
CComVariant data;
hr = pIShellBmp->GetData( &width, &height, &planes, &bpp, &data );
hr = pIShellBmp->GetColors( &r, &g, &b );
if( SUCCEEDED(hr) )
{
CComSafeArray<BYTE> bits( data.parray );
pBits = new unsigned char[ bits.GetCount() ];
for( int i = 0; i < bits.GetCount(); ++i )
{
pBits[i] = bits.GetAt( i );
}
BITMAP bmp;
bmp.bmType = 0;
bmp.bmBitsPixel = bpp;
bmp.bmHeight = height;
bmp.bmPlanes = planes;
bmp.bmWidth = width;
bmp.bmWidthBytes = width * bpp / 8 + (width * bpp / 8)%2;
bmp.bmBits = pBits;
HBITMAP hBitmap = CreateBitmapIndirect( &bmp );
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
bmi.bmiHeader.biBitCount = bpp;
bmi.bmiHeader.biClrImportant = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biHeight = height;
bmi.bmiHeader.biPlanes = planes;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biWidth = width;
if( hBitmap == NULL )
{
DWORD err = GetLastError();
hr = E_FAIL;
}
else
{
DWORD err = SetDIBits( CreateCompatibleDC(NULL), hBitmap, 0, bmp.bmHeight, pBits, &bmi, DIB_RGB_COLORS );
err = GetLastError();
GetObject( hBitmap, sizeof(BITMAP), &bmp );
WriteBMPFile( hBitmap, _T("c:\\received.bmp"), CreateCompatibleDC( NULL ) );
}
}
For some reasons the lines in bold fail and there is no error code. Can you please help me - where I'm wrong?
|
|
|
|
|
|
Should you be setting bmi.bmiHeader.biSizeImage before calling SetDIBits? I only say this because I found the following I'd used which uses GetDIBits to calculate it's value:
...
int ScanLines = GetDIBits(hMemDC,hBmp,0,B1Win.ylen,NULL,lpbmInfo,DIB_RGB_COLORS);
if(lpbmInfo->bmiHeader.biSizeImage == 0)
lpbmInfo->bmiHeader.biSizeImage = ((((lpbmInfo->bmiHeader.biWidth * lpbmInfo->bmiHeader.biBitCount) + 31) & ~31) >> 3) * lpbmInfo->bmiHeader.biHeight;
ScanLines = (int)(InControl.VideoRoi.ylen);
ScanLines = SetDIBits(hMemDC,hBmp,0,ScanLines,BDBoard.pcnvBuffer,lpbmInfo,DIB_RGB_COLORS);
...
|
|
|
|
|
I want to know the widest character and height of "MS Sans Sarif" Font Type. The Characters = {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ},font size may be in between 8 to 50.
|
|
|
|
|
Try it :
CSize GetMaxCharSize(CDC* pcDC, CFont* pcFont)
{
CSize csizeResult(0, 0);
if (pcDC && pcFont) {
CGdiObject* pcOldFont = pcDC->SelectObject(pcFont);
TEXTMETRIC tm = {0};
pDC->GetTextMetrics(&tm);
csizeResult.cx = tm.tmMaxCharWidth;
csizeResult.cy = tm.tmHeight;
pcDC->SelectObject(pcOldFont);
}
return csizeResult;
}
virtual void BeHappy() = 0;
|
|
|
|
|
I support the above.
Величие не Бога может быть недооценена.
|
|
|
|
|
please give me an example ?
|
|
|
|
|
It could be something like this :
void CYourView::OnInitialUpdate()
{
CBaseOfYourView::OnInitialUpdate();
m_cFont.CreatePointFont(120, _T("Arial"));
...
}
void CYourView::OnDraw(CDC* pDC)
{
CSize cMaxCharSize(GetMaxCharSize(pDC, &m_cFont));
CRect cMaxCharRect(CPoint(100, 100), cMaxCharSize);
pDC->FillSolidRect(cMaxCharRect, RGB(0, 128, 200));
...
}
virtual void BeHappy() = 0;
|
|
|
|
|
|
http://msdn.microsoft.com/en-us/library/xwf9s90b(VS.71).aspx[^]
In Western European fonts, the widest character is usually capital letter M (that's why typesetters refer to em-height and em-width). Most fonts will contain a character call em_space, which is a space that is exactly as wide as the widest character in the font.
|
|
|
|
|
Please compare them :
- W
- M
virtual void BeHappy() = 0;
|
|
|
|
|
|
|
Hi All
How can i encrypt CString values?
|
|
|
|
|
Here you go[^]
There are algorithms and the encryption levels related to each one that you might use.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Thank for vital and important information...
|
|
|
|
|
|
dont call that encrypted
Press F1 for help or google it.
Greetings from Germany
|
|
|
|