Click here to Skip to main content
15,923,164 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to change the listbox background? Pin
Ravi Bhavnani3-Apr-02 5:22
professionalRavi Bhavnani3-Apr-02 5:22 
GeneralRe: How to change the listbox background? Pin
Hans Ruck3-Apr-02 5:37
Hans Ruck3-Apr-02 5:37 
GeneralRe: How to change the listbox background? Pin
Ravi Bhavnani3-Apr-02 5:43
professionalRavi Bhavnani3-Apr-02 5:43 
Generalstructures Pin
RK_20003-Apr-02 5:00
RK_20003-Apr-02 5:00 
GeneralRe: structures Pin
Paul M Watt3-Apr-02 6:08
mentorPaul M Watt3-Apr-02 6:08 
GeneralRe: structures Pin
3-Apr-02 6:11
suss3-Apr-02 6:11 
GeneralA DAO Problem ! Pin
3-Apr-02 4:48
suss3-Apr-02 4:48 
Generaldistorted bitmaps and meta's using diff resolutions Pin
IGeorgeI3-Apr-02 4:25
IGeorgeI3-Apr-02 4:25 
When I copy and paste bitmaps and pictures from my app to another like WORD, the image seems ok under 1280 by 1024. When I change screen resolutions, try to copy and past again, the pictures get distorted and or clipped



here is meta code

//------------------------------------------------------------------------------
// Create a meta record for drawing the given component.
//------------------------------------------------------------------------------
BOOL ZClipboard::setMetaFile(CRect rect, CDC *dc, ZComponent *c, HWND hWnd)
{
// Meta file DCs operate in HIMETRIC units, we
// must scale the extents to these units so that
// the object appears the same size when pasted.

double units_per_inch = 25.4 / 0.01 + 0.5; // 25.4 mm at 0.01 mm per unit.
double scale = units_per_inch / 96.0; // divide by screen units

// Now scale the extents to HIMETRIC units.

rect.left = int(rect.left * scale + 0.5);
rect.top = int(rect.top * scale + 0.5);
rect.right = int(rect.right * scale + 0.5);
rect.bottom = int(rect.bottom * scale + 0.5);

HENHMETAFILE hMF = NULL;
CMetaFileDC metadc;
if (metadc.CreateEnhanced(dc, NULL, &rect, NULL))
{
metadc.SetAttribDC(dc->m_hDC); // This must be set!

// Translate the current window origin
// to the context of the component.
// Un-translate the current window origin
// to the parent coords of the component.

{
ZGraphics meta_g(&metadc);

meta_g -= c->getLocationOnCanvas();
meta_g -= c->getLocation();

c->paintAll(meta_g);
}

hMF = metadc.CloseEnhanced(); // Close the DC.
}

else
return false;

// Open the clipboard. OpenClipboard() takes one
// parameter, the handle of the window that will temporarily
// be it's owner. If NULL is passed, the current process
// is assumed. After opening, empty the clipboard so we
// can put our metafile on it.

if (hMF)
{
OpenClipboard(hWnd);
EmptyClipboard();

SetClipboardData(CF_ENHMETAFILE,hMF);
CloseClipboard();
}

return true;
}



here is bitmap code



//------------------------------------------------------------------------------
// Get a snapshot of the screen at the location of the given rectangle
//------------------------------------------------------------------------------
BOOL ZClipboard::setBitmap(CRect rect, CDC *dc, HWND hWnd)
{
// Set the graphics context.
HDC hdc = dc->m_hDC;
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, rect.Width(), rect.Height());

if (hBitmap)
{
// Copy the bitmap...
SelectObject(hdcMem, hBitmap);
StretchBlt(hdcMem, 0, 0, rect.Width(), rect.Height(), hdc, rect.TopLeft().x, rect.TopLeft().x, rect.Width(), rect.Height(), SRCCOPY);

// Open the clipboard. OpenClipboard() takes one
// parameter, the handle of the window that will temporarily
// be it's owner. If NULL is passed, the current process
// is assumed. After opening, empty the clipboard so we
// can put our bitmap on it.

OpenClipboard(hWnd);
EmptyClipboard();

// Place the data (Bitmap) onto the clipboard.
SetClipboardData(CF_BITMAP, hBitmap);
CloseClipboard();

// Clear the temp rect.
InvalidateRect(hWnd, NULL, true);
}


DeleteDC(hdcMem);

return TRUE;



any help appreciated




George W

Software Developer
www.zsystems.ca
Generalreading from file Pin
Rajveer3-Apr-02 3:53
Rajveer3-Apr-02 3:53 
GeneralRe: reading from file Pin
3-Apr-02 4:02
suss3-Apr-02 4:02 
GeneralRe: reading from file Pin
alex.barylski3-Apr-02 4:31
alex.barylski3-Apr-02 4:31 
GeneralRe: reading from file Pin
Shog93-Apr-02 4:59
sitebuilderShog93-Apr-02 4:59 
GeneralRe: reading from file Pin
Ravi Bhavnani3-Apr-02 5:19
professionalRavi Bhavnani3-Apr-02 5:19 
GeneralRetrieving handle to the active MDI child window Pin
AmarB3-Apr-02 3:04
AmarB3-Apr-02 3:04 
GeneralRe: Retrieving handle to the active MDI child window Pin
alex.barylski3-Apr-02 3:26
alex.barylski3-Apr-02 3:26 
GeneralRe: Retrieving handle to the active MDI child window Pin
AmarB3-Apr-02 3:37
AmarB3-Apr-02 3:37 
GeneralRe: Retrieving handle to the active MDI child window Pin
alex.barylski3-Apr-02 3:48
alex.barylski3-Apr-02 3:48 
GeneralRe: Retrieving handle to the active MDI child window Pin
3-Apr-02 3:58
suss3-Apr-02 3:58 
GeneralRe: Retrieving handle to the active MDI child window Pin
3-Apr-02 6:13
suss3-Apr-02 6:13 
GeneralIcons in a Listctrl with owner draw fixed style Pin
Cris3-Apr-02 2:58
Cris3-Apr-02 2:58 
GeneralRe: Icons in a Listctrl with owner draw fixed style Pin
alex.barylski3-Apr-02 3:30
alex.barylski3-Apr-02 3:30 
Generalevents problem.... Pin
Neha3-Apr-02 2:53
Neha3-Apr-02 2:53 
Generalremove item from std::list Pin
3-Apr-02 2:46
suss3-Apr-02 2:46 
GeneralRe: remove item from std::list Pin
Chris Losinger3-Apr-02 3:11
professionalChris Losinger3-Apr-02 3:11 
GeneralRe: remove item from std::list Pin
Christian Graus3-Apr-02 9:47
protectorChristian Graus3-Apr-02 9:47 

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.