?
Solved

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

Posted on 1998-02-23
1
Medium Priority
?
265 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 600 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

Industry Leaders: 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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 how to create, access, and change arrays 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.
Suggested Courses

777 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