Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 1998-02-23
1
257 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

856 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