Thread: bitmaps and controls..

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    bitmaps and controls..

    hey, i want to use AnimateWindow() to animate my bitmaps (5 die) sliding onto the screen. but when i load / display my bitmaps, they're exactly that - not windows. so how could i load the bitmap into / as a static control so that i could animate it?

    thanks.
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    mm...i'm thinking i found what i wanted. but in case anyone else ever needs to know.. http://msdn.microsoft.com/library/de...tic_styles.asp

    ...along with STM_SETIMAGE, lol http://msdn.microsoft.com/library/de...m_setimage.asp



    cept idk how to use them to make them work. whats wrong with..
    Code:
    in WM_CREATE
    int dice = 1000;
    for (i = 0; i < 6; i++)
    {
            dice1[i] = LoadBitmap(g_hInst, MAKEINTRESOURCE(dice));
    OR
            dice1[i] = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(dice), IMAGE_BITMAP, 64, 64, 0);
                     
            if (dice1[i] == NULL)
                  MessageBox(NULL, "Could not load the Dice", "Error", MB_OK | MB_ICONERROR);
            ++dice;
    }
    dieA = CreateWindowEx(0, TEXT("STATIC"), TEXT(""), WS_VISIBLE | WS_CHILD | SS_BITMAP | SS_CENTERIMAGE,
     34, 20, 64, 64, hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
    SendMessage(dieA, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)dice1);
    OR
    dieA = CreateWindowEx(0, TEXT("STATIC"), TEXT("#dice1"), WS_VISIBLE | WS_CHILD | SS_BITMAP | SS_CENTERIMAGE, 
                34, 20, 64, 64, hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
    
    
    in WM_PAINT
    BITMAP bm1;            
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);
    HDC hdcMem1 = CreateCompatibleDC(hdc);
    HBITMAP hbmOld1 = SelectObject(hdcMem1, dice1[dieOne]);          
                
    GetObject(dice1[dieOne], sizeof(bm1), &bm1);
    SelectObject(hdcMem1, hbmOld1);
    DeleteDC(hdcMem1);
    EndPaint(hwnd, &ps);
    ?
    dieOne = 0


    do i even need the code in the wm_paint case?
    Last edited by willc0de4food; 10-19-2005 at 05:08 PM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Check the returns from your functions to find which fails.

    ie SendMessage() should return the last bitmap for you to free the resource.
    SendMessage() with dice1[0] .
    Then SendMessage() dice1[1] and the return should be equal to dice1[0]

    I think that the bitmap has to be a resource ID number if using it during CreateWindow().

    also could be

    (LPARAM)dice1[0]

    >>so how could i load the bitmap into / as a static control so that i could animate it?

    MFC has an animation control....CAnimateCtrl

    I would look at GDI and draw it myself. Much faster and better control.
    Plenty of code here for 'double buffering'.

    Once you learn to handle GDI drawing skinning and animations are easy.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    The return value from SendMessage() is 0...
    i really dont understand whats not being done right. lol
    but for some reason it does show a pink line (O_o) ?
    Code:
    dieA = CreateWindow("static", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 34, 20, 64, 64, 
    hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
    if (dieA == NULL)
    MessageBox(NULL, "dieA is null, that window was not created.", "error", MB_OK);
                 
    lReturn = SendMessage(GetDlgItem(hwnd, ID_CONTAINER1), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)ID_DIE1);
    pic: http://img.photobucket.com/albums/v4...imageerror.jpg

    but the line doesn't appear if i change GetDlgItem() in SendMessage to dieA. it just fails. lol

    what is there for GDI+ tutorials? i searched google but i must suck at it lol

    bah...you kids and your MFC. ;]

    I tried making a window and specified the ID of a bitmap instead of trying to use an HBITMAP and there was still no go. i think i suck at this game lol but i will look in to GDI. i like speed

    thats why i use C instead of VB ^_^ but skinning would be fun too..

    thanks
    Last edited by willc0de4food; 10-20-2005 at 08:13 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed