Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

Unable to view Image in picture control

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
shakir77
Asked:
shakir77
  • 5
  • 4
  • 3
1 Solution
 
AlexFMCommented:
Picture control should have SS_BITMAP style. In the dialog resource editor right-click picture control and select Bitmap type.
0
 
shakir77Author Commented:
picture control Type is already set to BitMap.
Still not showing..??????? any reason.
0
 
AlexFMCommented:
SetBitmap function is defined as:
HBITMAP SetBitmap( HBITMAP hBitmap );

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


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
zfactCommented:
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
 
shakir77Author Commented:
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
 
shakir77Author Commented:
even without VERIFY ,
m_pictureToShow.SetBitmap((HBITMAP)m_bmp.m_hObject)
no error is coming but no Image seen ...its only blank
0
 
AlexFMCommented:
Try to select image in dialog template, as zfact writes. Do you see it?
0
 
shakir77Author Commented:
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
 
AlexFMCommented:
Use sscanf:

int n;
sscanf(string, "%d", &n);
0
 
zfactCommented:
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
 
zfactCommented:
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
 
shakir77Author Commented:
Thanx AlexFM , your both solution worked very well.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now