Solved

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

Posted on 1998-02-23
1
260 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

733 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