Home | Forums | Articles | F@H
Help | Search | Members | Calendar | Forum Map | Cybervillage | Archive
Welcome Guest ( Log In | Register | Resend Validation Email )


>  IceTeks Forums -> Technology made cool -> Programming


  Archived - No replies allowed - start new thread insteadStart new topicStart Poll

>  CBitmap problem in CTabCtrl
Track this topic | Email this topic | Print this topic
rapidlord
Posted: Jul 9 2004, 10:29 AM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 3
Member No.: 448
Joined: 9-July 04
Ice Cubes: 0



The problem is in inserting CBitmap in to CTabCtrl, if i load CBitmap from resource it`s ok, but if try to create CBitmap , write for example something on it, and then insert that bitmap to CTabCtrl nothing hepens.

First sample is code with CBitmap from resource working OK:

BOOL CCePropertySheet::OnInitDialog()
{

CTabCtrl* pTab = GetTabControl();
m_imageList.Create (60,36,ILC_COLOR, 0, 4);

CBitmap bm;

bm.LoadBitmap(IDB_TAB1);
m_imageList.Add(&bm, RGB(0, 0, 0));
...
..
. //more init code (not important)

}

=============================================
And now the sample code where is CBitmap created dinamicly thru CDC and inserted:


BOOL CCePropertySheet::OnInitDialog()
{

CTabCtrl* pTab = GetTabControl();
m_imageList.Create (60,36,ILC_COLOR, 0, 4);

CDC *bmCDC;
CBitmap *bm;

CDC* pdc = GetDC();
bmCDC->CreateCompatibleDC(pdc);
bm->CreateCompatibleDC(pdc,60,30);

bmCDC->SelectObject(bm);

bmCDC->TextOut ...... write something or draw


m_imageList.Add(bmCDC->GetCurrentBitmap(), RGB(0, 0, 0));
...
..
. //more init code (not important)

}


This is not working, i think is something about init CDC (GetCDC() ) but i don`t now what exactly, can anyone help me please.
PMEmail Poster Top
Red Squirrel
Posted: Jul 9 2004, 11:57 AM
Quote Post

ZOMG!

Group Icon

Group: Admins
Posts: 13 964
Member No.: 1
Joined: 18-December 02
Ice Cubes: 163183



Welcome aboard. Sorry I can't helo you though, hav'nt done C++ in a while and never got that advanced. Got discouraged when I realize making a triangle took 1000 lines of code. em317.gif


--------------------
user posted image
http://www.redsquirrel.me my blog
http://www.uovalor.com AoS/ML Ultima Online Shard
PMEmail PosterUsers Website Top
Fat Cat
Posted: Jul 12 2004, 02:42 AM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 18
Member No.: 351
Joined: 31-March 04
Ice Cubes: 0



CDC* pdc = GetDC();
bmCDC->CreateCompatibleDC(pdc);
bm->CreateCompatibleDC(pdc,60,30);


You have 2 "CreateCompatibleDC" commands one after another. The second one has 3 parameters passed to it (pdc, 60, 30), should it only have 1 parameter passed to it ?

------------------------------------
CDC::CreateCompatibleDC
virtual BOOL CreateCompatibleDC( CDC* pDC );

Return Value: Nonzero if the function is successful; otherwise 0.

Parameters:

pDC
A pointer to a device context. If pDC is NULL, the function creates a memory device context that is compatible with the system display.

Remarks
Creates a memory device context that is compatible with the device specified by pDC. A memory device context is a block of memory that represents a display surface. It can be used to prepare images in memory before copying them to the actual device surface of the compatible device.

When a memory device context is created, GDI automatically selects a 1-by-1 monochrome stock bitmap for it. GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.

This function can only be used to create compatible device contexts for devices that support raster operations. See the CDC::BitBlt member function for information regarding bit-block transfers between device contexts. To determine whether a device context supports raster operations, see the RC_BITBLT raster capability in the member function CDC::GetDeviceCaps.




PMEmail Poster Top
rapidlord
Posted: Jul 12 2004, 03:45 AM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 3
Member No.: 448
Joined: 9-July 04
Ice Cubes: 0



Tnx Red Squirrel for worm welcome smile.gif , and i like to say i am sorry but i made a mistake writing code in FORUM, i didn`t copy-paste from my project, it shold be :

bm->CreateCompatibleBitmap(pdc,60,30);

not: bm->CreateCompatibleDC(pdc,60,30);
i am sory "Fat Cat" but i still have a problem
PMEmail Poster Top
Fat Cat
Posted: Jul 12 2004, 09:27 PM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 18
Member No.: 351
Joined: 31-March 04
Ice Cubes: 0



I don't do much with bitmaps (mostly OpenGL), but there are a few notes on loading bitmaps and moving bitmaps using CreateCompatibleDC at http://www.gametutorials.com/Tutorials/win32/Win32_Pg3.htm

Might be worth a look.
PMEmail Poster Top
Fat Cat
Posted: Jul 12 2004, 09:49 PM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 18
Member No.: 351
Joined: 31-March 04
Ice Cubes: 0



is the syntax of your CreateCompatibileDC statements correct ?

should they be;

bmCDC.CreateCompatibleDC(pDC);

bmCDC.SelectObject(bm);

instead of;

bmCDC->CreateCompatibleDC(pDC);

bmCDC->SelectObject(bm);


then use;
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight,&bmCDC, 0, 0, SRCCOPY);

to copy the bitmap over




PMEmail Poster Top
rapidlord
Posted: Jul 14 2004, 03:39 AM
Quote Post

Icicle

Group Icon

Group: IceTeks Newbies
Posts: 3
Member No.: 448
Joined: 9-July 04
Ice Cubes: 0



I find the solution , i didnt select objects right here`s the code:

BOOL CCePropertySheet::OnInitDialog()
{

CTabCtrl* pTab = GetTabControl();
m_imageList.Create (60,36,ILC_COLOR, 0, 4);

CDC*pCtrlDC = GetDC();

CBitmap Bitmap;
CBitmap *pOldBitmap;

CDC TempDC;

TempDC.CreateCompatibleDC(pCtrlDC);
Bitmap.CreateCompatibleBitmap(pCtrlDC,60,32);

pOldBitmap = TempDC.SelectObject(&Bitmap);

TempDC.ExtTextOut(0,0,ETO_OPAQUE,NULL,"write or draw",NULL);

TempDC.SelectObject(pOldBitmap);

tmpImageList->Add(&Bitmap, RGB(0, 0, 0));
...
..
. //more init code (not important)


tmpImageList->Detach();
Bitmap.DeleteObject();
ReleaseDC(pCtrlDC);

}
PMEmail Poster Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Programming | Next Newest »

Topic Options Archived - No replies allowed - start new thread insteadStart new topicStart Poll

 



[ Script Execution time: 0.0362 ]   [ 13 queries used ]   [ GZIP Enabled ]

< Home | Forums | Contact >