Click here to Skip to main content
15,927,055 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHelp me! Pin
SmilingHeart11-Dec-02 15:02
SmilingHeart11-Dec-02 15:02 
GeneralRe: Help me! Pin
Christian Graus11-Dec-02 15:56
protectorChristian Graus11-Dec-02 15:56 
GeneralRe: Help me! Pin
SmilingHeart11-Dec-02 21:12
SmilingHeart11-Dec-02 21:12 
GeneralRe: Help me! Pin
Christian Graus11-Dec-02 21:36
protectorChristian Graus11-Dec-02 21:36 
QuestionHow to send message to Messenger Service in app? Pin
wangdave11-Dec-02 13:55
wangdave11-Dec-02 13:55 
AnswerRe: How to send message to Messenger Service in app? Pin
Kannan Kalyanaraman11-Dec-02 19:01
Kannan Kalyanaraman11-Dec-02 19:01 
GeneralPointers and SetDIBitsToDevice Question Pin
ursus zeta11-Dec-02 13:17
ursus zeta11-Dec-02 13:17 
GeneralRe: Pointers and SetDIBitsToDevice Question Pin
dan o12-Dec-02 5:39
dan o12-Dec-02 5:39 
hi,

about casting

see to the structure

typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;

BITMAPINFO is almost same as BITMAPINFOHEADER
casting means

int iVar = 1;
short sVar = (short)iVar; //I cast iVar to sVar


int SetDIBitsToDevice(
HDC hdc, // handle to device context
int XDest, // x-coordinate of upper-left corner of
// dest. rect.
int YDest, // y-coordinate of upper-left corner of
// dest. rect.
DWORD dwWidth, // source rectangle width
DWORD dwHeight, // source rectangle height
int XSrc, // x-coordinate of lower-left corner of
// source rect.
int YSrc, // y-coordinate of lower-left corner of
// source rect.
UINT uStartScan, // first scan line in array
UINT cScanLines, // number of scan lines
CONST VOID *lpvBits, // address of array with DIB bits
CONST BITMAPINFO *lpbmi, // address of structure with bitmap info.
UINT fuColorUse // RGB or palette indexes
);

.h
CBitmap m_bmpLogo1;
CString m_strLogoPath;
HANDLE m_hBitmap;

.cpp

::OnCreate()

CFileFind filefind;
CString strVal = strCurrentPath +"label.bmp";
m_strLogoPath = strVal;
if (filefind.FindFile(strVal))
bLogo = TRUE;
else
m_strLogoPath = "";

if(bLogo)
{
if(!m_bmpLogo1.LoadBitmap(strVal))
{
m_hBitmap = LoadImage (NULL,m_strLogoPath,IMAGE_BITMAP,0,0,
LR_DEFAULTSIZE | LR_LOADFROMFILE ); //| LR_CREATEDIBSECTION
if(!m_bmpLogo1.Attach(m_hBitmap))
m_strLogoPath = "";
}
}


//another function
CBitmap bmp //class
BITMAP Bitmap; //handle
long cx=0,cy=0;
CSize size

bmp.Attach(m_hBitmap);
bmp.GetBitmap(&Bitmap);

size = bmp.GetBitmapDimension();
cx = size.cx; //or Bitmap.bmWidth
cy = size.cy; //or Bitmap.bmHeight

BITMAPINFO info;
ZeroMemory( &info.bmiHeader, sizeof(BITMAPINFOHEADER) );
info.bmiHeader.biWidth = cx; // Set size you need
info.bmiHeader.biHeight = cy; // Set size you need
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24; // Can be 8, 16, 32 bpp or other number
info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);

//..

//I never used SetDIBitsToDevice() so i give you another example function
//Let's create a new bitmap

HDC dc= CreateCompatibleDC(NULL);
VOID *pvBits;
HBITMAP oldBmp;

m_hNewbmp = CreateDIBSection( dc, &info, DIB_RGB_COLORS, &pvBits,NULL, 0);
oldBmp = (HBITMAP)SelectObject(dc,m_hNewbmp);

//..

delete dc;

hope it helps a bit,
dan

QuestionWhere to make is a Loop? Pin
Autunmsky11-Dec-02 13:04
Autunmsky11-Dec-02 13:04 
AnswerRe: Where to make is a Loop? Pin
carrie11-Dec-02 13:33
carrie11-Dec-02 13:33 
GeneralRe: Where to make is a Loop? Pin
Autunmsky11-Dec-02 13:42
Autunmsky11-Dec-02 13:42 
GeneralRe: Where to make is a Loop? Pin
Christian Graus11-Dec-02 15:55
protectorChristian Graus11-Dec-02 15:55 
GeneralRe: Where to make is a Loop? Pin
Autunmsky11-Dec-02 16:10
Autunmsky11-Dec-02 16:10 
GeneralRe: Where to make is a Loop? Pin
Paul M Watt11-Dec-02 17:17
mentorPaul M Watt11-Dec-02 17:17 
GeneralRe: Where to make is a Loop? Pin
carrie11-Dec-02 20:54
carrie11-Dec-02 20:54 
GeneralRe: Where to make is a Loop? Pin
Christian Graus11-Dec-02 20:57
protectorChristian Graus11-Dec-02 20:57 
GeneralPointer error with SendMessage() and LPARAM Pin
Johann Gerell11-Dec-02 12:34
Johann Gerell11-Dec-02 12:34 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Paul M Watt11-Dec-02 12:42
mentorPaul M Watt11-Dec-02 12:42 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Johann Gerell11-Dec-02 13:54
Johann Gerell11-Dec-02 13:54 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Tim Smith12-Dec-02 2:31
Tim Smith12-Dec-02 2:31 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Michael Dunn11-Dec-02 14:55
sitebuilderMichael Dunn11-Dec-02 14:55 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Ravi Bhavnani11-Dec-02 12:50
professionalRavi Bhavnani11-Dec-02 12:50 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Johann Gerell11-Dec-02 13:56
Johann Gerell11-Dec-02 13:56 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
Ravi Bhavnani12-Dec-02 4:03
professionalRavi Bhavnani12-Dec-02 4:03 
GeneralRe: Pointer error with SendMessage() and LPARAM Pin
zarzor11-Dec-02 15:18
zarzor11-Dec-02 15:18 

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.