CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2018
    Posts
    4

    [RESOLVED] Controlling a image(.bmp) inside a dialog box.


    would like to find tutorials on the ins and outs of dialog boxes made with Visual Studio.
    I'am using 2017.
    I started out with a template Windows Desktop Application.
    I would like the about dialog to display a image.
    I have loaded 3 bitmap images.
    I need 1 of 3 to be displayed based on a int value.
    but yes just looking for the information or similar concept to make that happen.
    Attached Images Attached Images  

  2. #2
    Join Date
    Sep 2018
    Posts
    4

    Re: Controlling a image(.bmp) inside a dialog box.

    The attached image is a mock up of what I would like.

  3. #3
    Join Date
    Jan 2009
    Posts
    399

    Re: Controlling a image(.bmp) inside a dialog box.

    You can find here a tutorial that show you what you want to do: http://functionx.com/visualc/index.htm
    Ex: http://functionx.com/visualc/bitmaps...ayFromFile.htm

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Controlling a image(.bmp) inside a dialog box.

    There is an old article here:
    Displaying a Bitmap from a BMP File
    Victor Nijegorodov

  5. #5
    Join Date
    Sep 2018
    Posts
    4

    Re: Controlling a image(.bmp) inside a dialog box.

    I have gone through all these tutorials gents,and thank you for the knowledge. unfortunately it is not mixing well with what I'am trying to have occur. I have gotten farther.
    I was able to get my stop lights onto a dialog box and displayed.

    In their properties set to Visible= false
    trying to figure out how to change that behavior to true if equal to a variable Var1

    picture control
    type-bmp
    image-IDB_BITMAP1
    ID-IDB_BITMAP1

  6. #6
    Join Date
    Sep 2018
    Posts
    4

    Re: Controlling a image(.bmp) inside a dialog box.

    Code:
    // TODO: Place code here.
    	int Var1 = 3;
    	if (Var1=3)
    	{
                  IDB_BITMAP1.Visible = true;
    	}
    causes errors C2228 &E0153
    Last edited by 2kaud; September 21st, 2018 at 03:17 AM.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Controlling a image(.bmp) inside a dialog box.

    To make control/window visible/invisible MFC uses CWnd::ShowWindow method.
    Example:
    Code:
    // IDC_PICTURE is a control ID of the picture control
    CWnd* pictureCtrl = GetDlgItem(IDC_PICTURE);
    if(pictureCtrl != NULL)
    {
        pictureCtrl->ShowWindow(SW_SHOW); // make it visible
    ...
        pictureCtrl->ShowWindow(SW_HIDE); // make it invisible
    }
    Victor Nijegorodov

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Controlling a image(.bmp) inside a dialog box.

    Quote Originally Posted by Abermuth View Post
    Code:
    // TODO: Place code here.
    	int Var1 = 3;
    	if (Var1=3)
    	{
                  IDB_BITMAP1.Visible = true;
    	}
    causes errors C2228 &E0153
    It might just by a typo, but conditional equality test is == not =. So

    Code:
    // TODO: Place code here.
    	int Var1 = 3;
    	if (Var1 == 3)
    	{
                  IDB_BITMAP1.Visible = true;
    	}
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Controlling a image(.bmp) inside a dialog box.

    Quote Originally Posted by Abermuth View Post
    Code:
    // TODO: Place code here.
    	int Var1 = 3;
    	if (Var1=3)
    	{
                  IDB_BITMAP1.Visible = true;
    	}
    causes errors C2228 &E0153
    Probably, you are a VB programmer.
    No problem, you may try start programming C++ as well.

    Let's see...
    As stated in MSDN documentation, C2228 compiler error means "The operand to the left of the period (.) is not a class, structure, or union.".
    IDB_BITMAP1 which you can find defined in resource.h header file, is an integer built-in value, so is not a class, structure, or union.

    Before continuing the discussion, please tell us which is your reason to display different images in an "About" box.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured