Thread: STM_SETIMAGE Trouble!(PLEASE HELP!!)

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question STM_SETIMAGE Trouble!(PLEASE HELP!!)

    Hello. I am working on a BMP viewer and I want it to load a BMP onto a static and set the static control to have the same dimensions as the image. Here's some code:


    case IDC_VIEW:
    GetWindowText (GetDlgItem(hwnd, IDC_FILE), path, MAX_PATH);

    bmpname = (HBITMAP) LoadBitmap (0, path);

    GetObject (bmpname, sizeof(bmpinfo), &bmpinfo);

    x = bmpinfo.bmWidth;
    y = bmpinfo.bmHeight;

    bmpname = (HBITMAP) LoadBitmap (0, path);

    sX = x;
    sY = y;

    SendMessage(GetDlgItem(hwnd, IDC_BMP), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bmpname);
    break;


    All of the variables are already declared. The only problem is that it won't display the image on the static control. Can you help me?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You should test the return values from functions. This will give you an idea where your code is failing. I've not tried using STM_SETIMAGE, but there's a couple of things that may need changing.

    You should replace LoadBitmap() with LoadImage(). Something like -

    bmpname = (HBITMAP)LoadImage(NULL, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

    Is your static control created with the SS_BITMAP flag?

    If neither of these help, try working out which function is failing.

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Ok, now I have another problem...

    I did this:


    GetWindowText (GetDlgItem(hwnd, IDC_FILE), path, MAX_PATH);

    bmpname = (HBITMAP) LoadImage (0, path, x, y, 0, LR_LOADFROMFILE);

    if(!bmpname)
    {
    MessageBox(0, "Error creating BMP!", "Error", 0);
    }

    GetObject (bmpname, sizeof(bmpinfo), &bmpinfo);

    x = bmpinfo.bmWidth;
    y = bmpinfo.bmHeight;

    sX = x;
    sY = y;

    SendMessage(GetDlgItem(hwnd, IDC_BMP), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bmpname);


    And it can't create the BMP again. How do I reset the HBITMAP?


    NEVERMIND! I got it! I had to erase the BMP off of the static control first!
    Last edited by SyntaxBubble; 02-02-2002 at 04:31 PM.
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed