?
Solved

Unable to view Image in picture control

Posted on 2003-02-24
12
Medium Priority
?
716 Views
Last Modified: 2013-11-20
I am trying to load picture in picture control .
But it On running application No image is seen in the Picture control...it shows blank.

Code i have written in InitDialog is:

CBitmap m_bmp;
VERIFY(m_bmp.LoadBitmap(IDB_PICTURE));
m_pictureToShow.SetBitmap(m_bmp);
m_pictureToShow.UpdateWindow();

where m_pictureToShow is CStatic defined thru Control Window.


for debugging i just changed to
if( m_pictureToShow.SetBitmap(m_bmp) == NULL)
    AfxMessageBox("SetBitMap failed");

& it is showing SetBitMap is returning NULL.
can u pls point out what exactly the problem is ...
or am i doing something wrong .????
0
Comment
Question by:shakir77
[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
  • 5
  • 4
  • 3
12 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 8014506
Picture control should have SS_BITMAP style. In the dialog resource editor right-click picture control and select Bitmap type.
0
 
LVL 2

Author Comment

by:shakir77
ID: 8014561
picture control Type is already set to BitMap.
Still not showing..??????? any reason.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8014713
SetBitmap function is defined as:
HBITMAP SetBitmap( HBITMAP hBitmap );

So you need:
m_pictureToShow.SetBitmap((HBITMAP)m_bmp.m_hObject);


0
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!

 

Expert Comment

by:zfact
ID: 8014716
Hi Shakir77,
Try this.

Add a bitmap in your workspace. Now select the picture control that you have added on the dialog. now go to the property of the picture control, Select Type: as Bitmap, and select the "Image: BITMAP_ID ". This image is the id of the Bitmap that is there in your resource. now close the proerty dialog and you will see the bitmap.

Try it, All the best
Thanks and Regards.
Zfact
0
 
LVL 2

Author Comment

by:shakir77
ID: 8015288
hi zfact
I cannot set Image value to BITMAP_ID as this ID will be decided on runtime based on some condition from the lot of available Images.

and AlexFM, i tried using your solution still it is failing in VERIFY .
i used VERIFY(m_pictureToShow.SetBitmap((HBITMAP)m_bmp.m_hObject));

any solution ????????/
0
 
LVL 2

Author Comment

by:shakir77
ID: 8015323
even without VERIFY ,
m_pictureToShow.SetBitmap((HBITMAP)m_bmp.m_hObject)
no error is coming but no Image seen ...its only blank
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8015338
Try to select image in dialog template, as zfact writes. Do you see it?
0
 
LVL 2

Author Comment

by:shakir77
ID: 8015460
AlexFm yr solution works....thanx
but one more problem actually BITMAP ID's i have stored in access table.
when i get thru recordset for that index
rs.GetFieldValue(index,csVal);

i'll get BITMAP ID value in CString variable.
how do i change csVal to UINT so that it is accepted by LoadBitmap().

0
 
LVL 48

Accepted Solution

by:
AlexFM earned 300 total points
ID: 8015547
Use sscanf:

int n;
sscanf(string, "%d", &n);
0
 

Expert Comment

by:zfact
ID: 8015628
Hi shakir77,
Try this, it will work.

//Add The Bitmpm as shown below
     CBitmap bm1,bm2;
     bm1.LoadBitmap(MAKEINTRESOURCE(IDB_BITMAP1));
     bm2.LoadBitmap(MAKEINTRESOURCE(IDB_BITMAP2));
     

//Try changeing the bitmap with respect to your requirements as shown below.
     m_ctrlBitMapD.SetBitmap(bm1);
     m_ctrlBitMapD.SetBitmap(bm2);

Try It, All The Best,
Thanks & Regards
Zfact.
0
 

Expert Comment

by:zfact
ID: 8015700
Hi shakir77,
Try this, it will work.

//Add The Bitmpm as shown below
     CBitmap bm1,bm2;
     bm1.LoadBitmap(MAKEINTRESOURCE(IDB_BITMAP1));
     bm2.LoadBitmap(MAKEINTRESOURCE(IDB_BITMAP2));
     

//Try changeing the bitmap with respect to your requirements as shown below.
     m_ctrlBitMapD.SetBitmap(bm1);
     m_ctrlBitMapD.SetBitmap(bm2);

Try It, All The Best,
Thanks & Regards
Zfact.
0
 
LVL 2

Author Comment

by:shakir77
ID: 8015710
Thanx AlexFM , your both solution worked very well.
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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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