How to load the different images in the picture box?

Discussion in 'Win32' started by Nishant Desai, Jan 19, 2007.

  1. Nishant Desai

    Nishant Desai New Member

    Joined:
    Jan 19, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Dear Shabbir,

    I am a newbie to this forum, and I want to change the pictures as the boolean, by boolean mean when the variable is true, the picture box should show the green dot and if the variable is false then picturebox is false, then it should show the red dot.

    I have bitmaps of both, red and green dots. but i dont know how to load them into the picture box when the event ocurs, please help me to sort out the fact.

    Actually I have the big project, so i dont think that i have to create the picture box class, but i want to know that how to create the DC for the picture box, what should i write so that it creatres the DC for the picture box, i have taken.

    Thanks,
    Nishant
     
  2. Nishant Desai

    Nishant Desai New Member

    Joined:
    Jan 19, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Dear Shabbir,

    Your code helps me a much and it is running also, thanks for the nice article.

    The problem now i am facing is that as i am loading the image i have in my project into the picture box, but instead of showin that bitmap, it shows the blank white picture on that place, what is the thing i am doing wrong?

    As you said, I am giving the picPreview.SetBitmap(Image ID), ofcourse i am giving the my project's Image ID in the place of Image ID, but it is still loading as a blank, what could be the problem?

    Thanks,
    Nishant
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am not sure what could be the problem as SetBitmap API should load the image (bmp)

    Try running my example instead of yours and see what can go wrong in your case.
     
  4. Nishant Desai

    Nishant Desai New Member

    Joined:
    Jan 19, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hiii,

    Ok, I will try that, but tell me is it possible to give the whole path of the Bitmap from the computer, by that i mean if my bitmap is in the C drive, then is it possible to call it from there by "C:\abc.bmp"? or is it possible to put it in the same directory of the project and to call it?

    Thanks,
    Nishant
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Both are possible. See the LoadBitmap function of the SDK where you have the option of amy bmp's to be loaded.
     
  6. Nishant Desai

    Nishant Desai New Member

    Joined:
    Jan 19, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hiii,
    I ahve put the .bmp file in my current directory of the project and it is running now.
    Thanks,
    Nishant
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice