|
Connection to database I make in primary thread ... and now , since I discover threads , I try to switch connection to an worker thread ...
Ok , I have connection attach it to global theApp variable ... ex : theApp.ExecuteSQL(...) , theApp.GetData(...) , etc. so , you say to pass this varaible ( theApp ) as parameter to worker thread ? Since theApp is global variable , what is the point ?
|
|
|
|
|
mesajflaviu wrote: so , you say to pass this varaible ( theApp ) as parameter to worker thread
Not what I said at all.
"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
|
|
|
|
|
Then , to pass theApp.m_pDB ( CDatabase* kind of ) like parameter to worker thread ?
|
|
|
|
|
Hi,
I'm using a CListCtrl in an MFC app (vs2008) that has group view enabled. All works fine on my Win7 PC but when I run my app on a Win XP system the list will not sort the list items when group view is enabled. Is this a WinXP limitation?
Thanks.
|
|
|
|
|
I have come across a similar situation recently, but on Windows 7 using straight Win32 API; are you sure it sorts correctly within groups? I found a solution here[^], it may help you also.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thanks for the reply, Richard. I will try what the link suggests.
PS
I've just doubled checked and it does indeed sort on groups in Win7.
Thanks
|
|
|
|
|
Hi,
I can't seem to properly create a compatible bitmap in my MFC application. I'm trying to StretchBlt a byte buffer (with 8-bit greyscale pixel information) to a DC, but the only way to get it done is by taking a rather unconventional detour. Here's what I do:
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, "bitmap.bmp", IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
CBitmap cBmp;
cBmp.Attach(hBmp);
cBmp.SetBitmapBits(m_width*m_height, datap);
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
HBITMAP BitmapOld = (HBITMAP)SelectObject(dcMem, cBmp);
dc->StretchBlt(xOffset, yOffset, m_width*rectSizeX, m_height*rectSizeY, &dcMem, 0, 0, m_width, m_height, SRCCOPY);
dcMem.SelectObject(BitmapOld);
dcMem.DeleteDC();
The file bitmap.bmp contains an uncompressed 8-bit greyscale image with exactly the same dimension of m_width*m_height. So far only by loading this one file first, attaching it to CBitmap cBmp and then calling SetBitmapBits with the pointer to my own byte buffer (datap), thus overwriting the bitmap information from the file, I can create a compatible bitmap out of my byte buffer that I can blit into the window. If I go like this
BITMAPINFO *lpInfo = new BITMAPINFO;
lpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
lpInfo->bmiHeader.biWidth = m_width;
lpInfo->bmiHeader.biHeight = m_height;
lpInfo->bmiHeader.biPlanes = 1;
lpInfo->bmiHeader.biBitCount = 8;
lpInfo->bmiHeader.biCompression = BI_RGB;
lpInfo->bmiHeader.biSizeImage = m_width*m_height;
lpInfo->bmiHeader.biClrUsed = 0;
HBITMAP hBmp = (HBITMAP)::CreateDIBSection(0, lpInfo, DIB_RGB_COLORS, 0, 0, 0x0);
... and then do the rest mentioned above (Attach(), CreateCompatibleDC(), SelectObject(), StretchBlt() etc.), I see only a greenish version of the image I want to blit (but in right aspect ratio, stride, dimension etc.), and it keeps appearing and disappearing with a blurry spot all the time.
What am I doing wrong?
Mac
|
|
|
|
|
From "CreateDIBSection Function"[^] documentation:
iUsage [in]
The type of data contained in the bmiColors array member of the BITMAPINFO structure pointed to by pbmi (either logical palette indexes or literal RGB values). The following values are defined.
Value Meaning
DIB_PAL_COLORS
The bmiColors member is an array of 16-bit indexes into the logical palette of the device context specified by hdc.
DIB_RGB_COLORS
The BITMAPINFO structure contains an array of literal RGB values.
Where's your array?
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]
modified on Friday, November 19, 2010 7:50 AM
|
|
|
|
|
I'd say it's not there...
lpInfo->bmiColors[0].rgbBlue=1;
lpInfo->bmiColors[0].rgbGreen=1;
lpInfo->bmiColors[0].rgbRed=1;
lpInfo->bmiColors[0].rgbReserved=0;
... is what I tried. I also iterated over 256 array indices, assigning 1 or 0. Which values do I have to assign? The blitted image looks different, but still more like a "pixel color accident".
Mac
|
|
|
|
|
It really depends on your DIB bits (of course you've to assign the whole array).
My naive attempt, would be:
for (int n=0; n < 256; n++)
{
lpInfo->bmiColors[n].rgbBlue=b;
lpInfo->bmiColors[n].rgbGreen=b;
lpInfo->bmiColors[n].rgbRed=b;
lpInfo->bmiColors[n].rgbReserved=0;
lpInfo->bmiColors[n].rgbBlue=n;
lpInfo->bmiColors[n].rgbGreen=n;
lpInfo->bmiColors[n].rgbRed=n;
lpInfo->bmiColors[n].rgbReserved=0;
}
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]
modified on Tuesday, November 23, 2010 7:47 AM
|
|
|
|
|
When I do that, I run into an assertion (at some random point in my application), and in addition I sometimes get an "Out of memory" message.
When I assign only [0] through [9] of the array, I do get a blitted image like described in my original post, but with a very redish touch.
Mac
|
|
|
|
|
Pardon my dumb question: Do you know you should allocate enough memory for the array?
i.e.
BITMAPINFO *lpInfo = (BITMAPINFO *) (new BYTE[sizeof(BITMAPINFO) + 255 * sizeof(RGBQUAD)]);
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]
|
|
|
|
|
The "dumb" part was on my side, because I didn't allocate any memory. But even though now I don't get an exception anymore, the result is still the same as described on my previous posts.
Mac
|
|
|
|
|
Possibly you should have a look at the palette of the image file (the one you use for the 'unusual approach'). How is the palette defined (i.e. what is the RGBQUAD array content?)
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]
|
|
|
|
|
That was exactly what I tried, when I found the "unusual approach": What is different in the RGBQUAD, in the BITMAPHEADER, in the BITMAPINFO if I load the bitmap from the file? You know - so I could assign the exact same properties to my bitmap created with CreateDIBSection. The problem is, I didn't find a way of accessing any of the mentioned structures. The only thing I was able to find out after using LoadImage() was this (also see code from original post):
BITMAP bm;
cBmp.GetBitmap(&bm);
bm was then filled with these values
bmType 0 long
bmWidth 320 long
bmHeight 180 long
bmWidthBytes 320 long
bmPlanes 1 unsigned short
bmBitsPixel 8 unsigned short
bmBits 0x07a10000 void *
No surprise there. I assigned the same values (bmPlanes, bmBitsPixel etc.) to BITMAPINFO *lpInfo (also see original post).
Is there a way of retrieving a "proper" BITMAPINFO or BITMAPINFOHEADER from the bitmap loaded with LoadImage()?
Mac
|
|
|
|
|
MacCPlus wrote: Is there a way of retrieving a "proper" BITMAPINFO or BITMAPINFOHEADER from the bitmap loaded with LoadImage()?
No, I suppose. Anyway you may retrieve these structures loading the file yourself (see, for instance here - it looks a bit dated, but, at the moment I cannot find an up-to-date one).
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]
|
|
|
|
|
I got it!
Had to initialize bmiColors like this:
for (int n=0; n < 256; n++)
{
m_pBitmapInfo->bmiColors[n].rgbBlue=n;
m_pBitmapInfo->bmiColors[n].rgbGreen=n;
m_pBitmapInfo->bmiColors[n].rgbRed=n;
m_pBitmapInfo->bmiColors[n].rgbReserved=0;
}
Thanks for the advice!
Mac
|
|
|
|
|
It was what I intended here, since they are grey gradations, unfortunately (now I realize) I made a typo (fixed now).
Sorry for the inconvenience.
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]
|
|
|
|
|
Actually, I should have realized that myself reading your first response. But I guess I wasn't quite "there" yet.
I found out how the color table is supposed to look like by debugging bmiColors[] after having loaded said bitmap file using the code you posted.
Mac
|
|
|
|
|
Hi!
I have developed a MFC Dialog based application, that consists of buttons, combo-boxes, edit box and a button to browse for a file etc, Now i want a free tool, through which i can repeatedly automate/test my app without the involvement of human. so is there asny such free tool in which initially i will show the cursor flow on my app, then the tool will proceed to do the same for required number of times. i searched thru net, i got few like AutoHotkey and winspy ++, but they require some scripts to be written, is there any software (free) which can be used without writing scripts!!
Thanks!
|
|
|
|
|
See here for ideas.
"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
|
|
|
|
|
Hello Friends
I am using LoadImage to load bitmap but how can I load Tiff File?
Any Ideas?
Thanks & Regards
Yogesh
|
|
|
|
|
GDI+ won't do it for you. You could look for another library that does; I'm pretty sure GIMP does. Or you could create your own TIFF package. IIRC there might be some licensing issues.
|
|
|
|
|
Luc Pattyn wrote: GDI+ won't do it for you.
GDI+ has built-in encoders and decoders that support the following file types:
BMP
GIF
JPEG
PNG
TIFF
GDI+ reference: "Using Image Encoders and Decoders"[^].
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]
|
|
|
|
|
I stand corrected; I don't see what the OP's problem is then.
|
|
|
|