Click here to Skip to main content
15,926,703 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: multiple selection in a list box Pin
Eytukan19-Jul-07 8:20
Eytukan19-Jul-07 8:20 
AnswerRe: multiple selection in a list box Pin
tanvon malik19-Jul-07 3:00
tanvon malik19-Jul-07 3:00 
QuestionProblem in displaying Balloon tool tip in VC++6.0 MFC??? Pin
gloriousgopi19-Jul-07 1:46
gloriousgopi19-Jul-07 1:46 
QuestionDisplay bitmap stored in array on simple button Pin
Ravindra_Joshi18-Jul-07 23:50
Ravindra_Joshi18-Jul-07 23:50 
AnswerRe: Display bitmap stored in array on simple button Pin
John R. Shaw19-Jul-07 1:29
John R. Shaw19-Jul-07 1:29 
AnswerRe: Display bitmap stored in array on simple button Pin
Rage19-Jul-07 1:35
professionalRage19-Jul-07 1:35 
GeneralDisplay bitmap stored in array on simple button Pin
Ravindra_Joshi19-Jul-07 2:08
Ravindra_Joshi19-Jul-07 2:08 
AnswerRe: Display bitmap stored in array on simple button Pin
Mark Salsbery19-Jul-07 5:13
Mark Salsbery19-Jul-07 5:13 
>>HBITMAP hndle=NULL; // declared in .h file
>>CBitmap obj;
>>
>>obj.CreateBitmap(20,23, 1, 1, dec_arr );
>>
>>hndle=obj.operator HBITMAP();
>>
>>sim_bt.Create( _T("Hi") ,WS_CHILD | WS_VISIBLE | BS_BITMAP , CRect(30,0,100,40),this,2222);
>>
>>hndle=sim_bt.SetBitmap(hndle);

The planes and bitcount describe the format of the pixel data in the array.
nPlanes is the number of planes and nBitcount is the number of bits per pixel per plane.

These define the layout of the data in the array, where each row of pixel data is followed by the
next row of data for each plane.

Each row of pixel data bytes must be WORD aligned for a CBitmap/HBITMAP. That means every row
needs to have a length a multiple of 2 bytes, padded if necessary.

Some examples:

For a 16x16 bimap nPlanes==4, nBitcount==1 the data is layed out in the array<br />
Plane 0, Row 0 2 bytes<br />
Plane 0, Row 1 2 bytes<br />
...<br />
Plane 0, Row 15 2 bytes<br />
Plane 1, Row 0 2 bytes<br />
Plane 1, Row 1 2 bytes<br />
...<br />
Plane 1, Row 15 2 bytes<br />
...etc


For a 16x16 bimap nPlanes==1, nBitcount==24 the data is layed out in the array<br />
Plane 0, Row 0 48 bytes<br />
Plane 0, Row 1 48 bytes<br />
...<br />
Plane 0, Row 15 48 bytes


You seem to know your array of pixel data is for a 20x23 bitmap.
You also need to know the format of that data, and if it's not a format supported by GDI you may
also need to translate it into an acceptable form.

You also don't need to call a conversion operator specifically like you've done to get the HBITMAP
from a CBitmap. You can simplify your code:

HBITMAP hndle=NULL; // declared in .h file
CBitmap obj;

obj.CreateBitmap(20,23, 1, 1, dec_arr );

sim_bt.Create( _T("Hi") ,WS_CHILD | WS_VISIBLE | BS_BITMAP , CRect(30,0,100,40),this,2222);

hndle=sim_bt.SetBitmap(obj);

Hope this helps a little!
Mark






Mark Salsbery
Microsoft MVP - Visual C++


"Great job team! Head back to base for debriefing and cocktails."

QuestionHow to include Header file in.... Pin
Electronic7518-Jul-07 23:48
Electronic7518-Jul-07 23:48 
AnswerRe: How to include Header file in.... Pin
Matthew Faithfull19-Jul-07 0:09
Matthew Faithfull19-Jul-07 0:09 
GeneralRe: How to include Header file in.... Pin
Electronic7519-Jul-07 1:08
Electronic7519-Jul-07 1:08 
GeneralRe: How to include Header file in.... Pin
Rage19-Jul-07 1:30
professionalRage19-Jul-07 1:30 
GeneralRe: How to include Header file in.... [modified] Pin
Eytukan19-Jul-07 8:25
Eytukan19-Jul-07 8:25 
AnswerRe: How to include Header file in.... Pin
Matthew Faithfull19-Jul-07 2:27
Matthew Faithfull19-Jul-07 2:27 
Questionpackage installation. Pin
Md. Ali Naser Khan18-Jul-07 22:45
Md. Ali Naser Khan18-Jul-07 22:45 
QuestionOpening a drive...need help Pin
dranne18-Jul-07 22:12
dranne18-Jul-07 22:12 
AnswerRe: Opening a drive...need help Pin
thammadi18-Jul-07 22:29
thammadi18-Jul-07 22:29 
AnswerRe: Opening a drive...need help Pin
vipin_nvk18-Jul-07 22:33
vipin_nvk18-Jul-07 22:33 
QuestionOnIdle() not getting focus Pin
rp_suman18-Jul-07 22:05
rp_suman18-Jul-07 22:05 
AnswerRe: OnIdle() not getting focus Pin
Mark Salsbery19-Jul-07 5:21
Mark Salsbery19-Jul-07 5:21 
GeneralRe: OnIdle() not getting focus Pin
rp_suman19-Jul-07 14:40
rp_suman19-Jul-07 14:40 
GeneralRe: OnIdle() not getting focus Pin
Mark Salsbery19-Jul-07 14:56
Mark Salsbery19-Jul-07 14:56 
GeneralRe: OnIdle() not getting focus [modified] Pin
rp_suman19-Jul-07 17:46
rp_suman19-Jul-07 17:46 
GeneralRe: OnIdle() not getting focus Pin
Mark Salsbery19-Jul-07 20:14
Mark Salsbery19-Jul-07 20:14 
GeneralRe: OnIdle() not getting focus [modified] Pin
rp_suman19-Jul-07 20:57
rp_suman19-Jul-07 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.