Mail Archives: cygwin/1998/04/23/06:21:43
I am having problems with SelectObject of a bitmap in g++. I am using
b19.1 of cygwin32 with latest coolview, egcs, and gas distributions.
gcc -v -> Reading specs from
I:\CYGNUS\B19\H-I386~1\lib\gcc-lib\i386-cygwin32\egcs-2.90.27\specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
g++ -v -> Reading specs from
I:\CYGNUS\B19\H-I386~1\lib\gcc-lib\i386-cygwin32\egcs-2.90.27\specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
as -v -> GNU assembler version 980303 (i386-cygwin32), using BFD version
980303
code snippets are as follows:
cbitmaplist.cxx,
// class CBitmapList contains CBitmap *_list; BOOL _horizontal; ...
// class CBitmap contains CBitmap *_next; BITMAP _bm; ...
CBitmap *pt;
CCanvas canvas;
POINT p;
a)
_list->PaintList(_list, canvas, p, _horizontal);
b)
p.x = p.y = 0;
for (pt=_list; pt; pt=pt->_next) {
pt->Paint(canvas, p);
if (_horizontal)
p.x += pt->_bm.bmWidth-1;
else
p.y += pt->_bm.bmHeight-1;
}
cbitmap.cxx:
void CBitmap::Paint(CCanvas ccanvas, POINT p)
{
HGDIOBJ hobj;
hobj = ccanvas.SelectObject(_dibitmap);
if (!hobj)
return;
if (!BitBlt(ccanvas.GetDC(), p.x, p.y, _bm.bmWidth, _bm.bmHeight,
ccanvas.GetShadowHDC(), 0, 0, SRCCOPY))
cout << "bitblt GetLastError " << GetLastError() << endl;
hobj = ccanvas.SelectObject(hobj);
}
void CBitmap::PaintList(CBitmap* list,CCanvas ccanvas, POINT s, BOOL
_horiz)
{
HGDIOBJ hobj=NULL;
HGDIOBJ hobj2;
CBitmap *cb;
POINT p = s;
for(cb=list; cb; cb=cb->_next) {
hobj2 = ccanvas.SelectObject(cb->_dibitmap);
if (!hobj2) {
cb=0;
} else {
if (hobj == NULL)
hobj = hobj2;
if (BitBlt(ccanvas.GetDC(), p.x, p.y, cb->_bm.bmWidth,
cb->_bm.bmHeight,
ccanvas.GetShadowHDC(), 0, 0, SRCCOPY)) {
if (_horiz)
p.x += cb->_bm.bmWidth-1;
else
p.y += cb->_bm.bmHeight-1;
} else {
cout << "bitblt GetLastError " << GetLastError() << endl;
cb=0;
}
}
}
hobj = ccanvas.SelectObject(hobj);
}
in case a) above, the output is:
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x24a2 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x21da created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x24b6 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x24ae created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x24a6 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x249a created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x2492 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x248a created
painting cbitmaplist at 0, 0, 2eb, 1de
RestoreDC error 0
painted cbitmaplist
painting cbitmaplist at 0, 0, 2eb, 1de
SelectObject for bitmap 0x24a2, GetLastError 0
(I:\DIALER4\APP.EXE 1159) Exception: STATUS_ACCESS_VIOLATION
(I:\DIALER4\APP.EXE 1159) Dumping stack trace to APP.EXE.core
in case b) above, the output is:
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x21ce created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0xf2a created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x21de created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x1ed6 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x267a created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x2656 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x2672 created
_bm size 30x24 planes 1 widthBytes 60 BitsPixel 10 Bits 0x0 pixWidth 2
dibitmap 0x21be created
painting cbitmaplist at 0, 0, 2eb, 1de
SelectObject for bitmap 0xf2a, GetLastError 0
SelectObject for bitmap 0x21de, GetLastError 0
SelectObject for bitmap 0x1ed6, GetLastError 0
SelectObject for bitmap 0x267a, GetLastError 0
SelectObject for bitmap 0x2656, GetLastError 0
SelectObject for bitmap 0x2672, GetLastError 0
SelectObject for bitmap 0x21be, GetLastError 0
RestoreDC error 0
painted cbitmaplist
painting cbitmaplist at 0, 0, 2eb, 1de
SelectObject for bitmap 0x21ce, GetLastError 0
SelectObject for bitmap 0xf2a, GetLastError 0
SelectObject for bitmap 0x21de, GetLastError 0
SelectObject for bitmap 0x1ed6, GetLastError 0
SelectObject for bitmap 0x267a, GetLastError 0
SelectObject for bitmap 0x2656, GetLastError 0
SelectObject for bitmap 0x2672, GetLastError 0
SelectObject for bitmap 0x21be, GetLastError 0
painted cbitmaplist
....
I would think that the code should run exactly the same. I am not
referring to the STATUS_ACCESS_VIOLATION but the operation of painting
the cbitmaplist.
In case a) all the bitmaps are painted on the window as they should be
for the first invocation of CBitmap::PaintList. Successive invocations
of CBitmap::PaintList all get errors in SelectObject on the first
bitmap.
In case b) all SelectObject calls in the first invocation of
CBitmap::Paint are successful, while all calls in successive
CBitmap::Paint invocations fail. In addition, only the first bitmap is
painted on the window.
Also note that as with many windows calls, GetLastError() returns 0,
which I believe is incorrect because the operation did not succeed.
Can anyone offer any help?
--
Tim Daley
San Jose, California
timdaley AT earthling DOT net
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -