Availability of image management in VC ++ 2008

Hi everyone, I want to know if there is image control in VC ++, as it is in VB. In fact, using the image window, I encounter the problem of being unable to resize the image during development for my dialog. But in managing them, it’s possible. I do not have image management, there is a way to check the height and width of the dialog from the dialog editor during development.

+3
source share
1 answer

If you are writing an unmanaged C or C ++ project, this is a little more complicated than using the PictureBox control, which will be available when developing a Windows Forms managed application, but still doable.

DialogBox (: , Visual Studio 2015 , 2008, ):

  • . , IDB_BITMAP1 .
  • Static .
  • Static Properties.
  • Misc Properties, Type Bitmap.
  • Misc Properties Image IDB_BITMAP1.

(.. CreateWindow CreateWindowEx ):

  • . #include "resource.h" .
  • LoadBitmap.
  • SS_BITMAP.
  • STM_SETIMAGE , .

, IDB_BITMAP1:

#include <Windows.h>
#include <tchar.h>
#include "resource.h"

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
    HWND hWnd, hStcImage;
    MSG Msg;
    HBITMAP hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));

    // ... register the window class etc

    hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, _T("ExampleClassName"), _T("Simple Window"), WS_VISIBLE | WS_SYSMENU, 100, 100, 350, 370, NULL, NULL, hInstance, NULL);
    hStcImage = CreateWindow(_T("Static"), NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 10, 10, 0, 0, hWnd, NULL, hInstance, NULL);
    SendMessage(hStcImage, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmap);

    ShowWindow(hWnd, SW_SHOW);
    UpdateWindow(hWnd);

    while (GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
0

All Articles