[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.
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
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
}
Re: Controlling a image(.bmp) inside a dialog box.
Originally Posted by Abermuth
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!
Re: Controlling a image(.bmp) inside a dialog box.
Originally Posted by Abermuth
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.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.