Solved

How to Display/Update BMP in C (vs C++)

Posted on 1998-02-23
1
247 Views
Last Modified: 2011-10-03
Using MS Visual C++, I have the following code in C++ (that changes the display of a Dialog Control - by changing the BITMAP loaded onto the control). I haven't found any way to accomplish this in C. The code that currently works is as follows:

   HBITMAP m_hBitHandle;
   DWORD dwResource = IDB_BITMAP1;
   CBitmap keyPicture;
   CStatis m_sKeyDispCtrl;   // Dialog Ctrl to paint BMP on

   keyPicture.LoadBitmap(dwResource);
   m_hBitHandle = HBITMAP(keyPicture);
   m_sKeyDispCtrl.SetBitmap(m_hBitHandle);
   m_sKeyDispCtrl.UpdateWindow();
   UpdateData(FALSE);
   
Any Idea on how to convert this to be used by a C (only) application? I thought about adding the C++ source to a project with only C modules, but it during linking, it gives me "Unresolved References to __argv, __argc.
Thanks in advance
Neil
0
Comment
Question by:nweiher
1 Comment
 
LVL 7

Accepted Solution

by:
galkin earned 200 total points
ID: 1257354
To load bitmap from resource use LoadBitmap Win32 API function.
If you want to paint this bitmap you must add hadle WM_PAINT message by yourcontrol window procedure. Call BegingPaint to obtain HDC. Then Create memory DC with CreateCompatibleDC. Select loaded bitmap into this DC with SelectObject. Then use BitBlt to draw offscreen from memory DC onto actual control DC. If you want tostretch this bitmap use StretchBlt instead of BitBlt. Then reselect old bitmap into memory DC and call DeleteDC for this DC.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now