| |

VerySource

 Forgot password?
 Register
Search
View: 744|Reply: 7

Why can't I copy the bitmap by doing this?

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-13 17:00:01
| Show all posts |Read mode
I use the following code to copy a bitmap in VC, and it runs normally, but why is it not displayed after pasting on WORD?
m_WaveUIBmpCtrl is a variable of the Picture control. A bitmap is displayed on the control and imported from a file.
HBITMAP hBitmap = NULL;

BeginWaitCursor ();
Ranch
hBitmap = m_WaveUIBmpCtrl.GetBitmap ();
VERIFY (hBitmap);

VERIFY (OpenClipboard ());
VERIFY (EmptyClipboard ());
VERIFY (SetClipboardData (CF_BITMAP, hBitmap));
VERIFY (CloseClipboard ());
Ranch
EndWaitCursor ();

What should I do to copy the bitmap? ? ?
Reply

Use magic Report

1

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-19 19:18:01
| Show all posts
If you can paste in the drawing board, it may be because WORD uses a custom clipboard format.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-24 12:36:01
| Show all posts
Has anyone done it?
Help me answer
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-25 12:45:01
| Show all posts
Top up
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-25 19:27:02
| Show all posts
Convert HBITMAP to DIB, then use CG_DIB.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-5 13:00:02
| Show all posts
Upstairs hello
Thank you for your reply.

For the problem of "copying bitmaps", I found the information on the Internet, and finally I wrote it like this. Can you help me to see if it can be optimized?
CBitmap bitmap;
CClientDC dc (GetDlgItem (IDC_WAVE_UI_BMP));
CDC memDC;
CRect rect (0, 0, 0, 0);
VERIFY (memDC.CreateCompatibleDC (&dc));
GetDlgItem (IDC_WAVE_UI_BMP)-> GetWindowRect (rect);
Ranch
VERIFY (bitmap.CreateCompatibleBitmap (&dc, rect.Width (), rect.Height ()));
CBitmap * pOldBitmap = memDC.SelectObject (&bitmap);
VERIFY (memDC.BitBlt (0, 0, rect.Width (), rect.Height (),&dc, 0, 0, SRCCOPY));
Ranch
VERIFY (:: OpenClipboard (NULL));
VERIFY (:: EmptyClipboard ());
VERIFY (SetClipboardData (CF_BITMAP, bitmap.GetSafeHandle ()));
:: CloseClipboard ();
Ranch
memDC.SelectObject (pOldBitmap);
bitmap.Detach ();
The bitmap is displayed on the Picture control whose DI is "IDC_WAVE_UI_BMP".
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-5 16:45:01
| Show all posts
Ask another question,

I imported a bitmap from a file into the Picture control for display. My requirements are:
My control can be resized, and my bitmap changes as the size of the control changes (always fully adapts to the size of the control)
How do I import the display? ? ? ? ?

My code is like this, but the problem is that the size is the same when importing, and once the size of the control is changed, the bitmap is not consistent with the control.
CRect rc;
HBITMAP hBitmap = NULL;
GetDlgItem (IDC_WAVE_UI_BMP)-> GetWindowRect (&rc);
VERIFY (strcmp (G_OpenFileName, ""));
hBitmap = (HBITMAP) :: LoadImage (AfxGetInstanceHandle (), G_OpenFileName,
IMAGE_BITMAP, rc.Width (), rc.Height (), LR_CREATEDIBSECTION | LR_LOADFROMFILE);
m_WaveUIBmpCtrl.ModifyStyle (0xF, SS_BITMAP | SS_CENTERIMAGE);
m_WaveUIBmpCtrl.SetBitmap (hBitmap);
Help me see, heroes!
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-20 15:15:02
| Show all posts
up
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list