Solved

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

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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…
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 opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

910 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

21 Experts available now in Live!

Get 1:1 Help Now