Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8104671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:55:01+00:00 2026-06-05T23:55:01+00:00

I need to change testAppGUI’s (testAppGUI is a form) visible property from another function.

  • 0

I need to change testAppGUI’s (testAppGUI is a form) visible property from another function. The function is in a separate file and it’s not in a class.

If I try to do

testAppGUI::Visible = false;

I just get error

C2597: illegal reference to non-static member ‘System::Windows::Forms::Control::Visible’

And if I try create a instance of the object like this

testAppGUI^ formProperty = gcnew testAppGUI;

and then do

formProperty->Visible = false; nothing happens?!

Can anybody explain how to do this?

Thanks in advance.

EDIT: Here is some more code

In testApp.cpp

#include "stdafx.h"
#include "testAppGUI.h"

using namespace testApp;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 
    Application::Run(gcnew testAppGUI());
    return 0;
}

In testAppGUI.h

#pragma once

#include "HideAndShowGUI.h"

namespace testApp {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::IO;

    public ref class testAppGUI : public System::Windows::Forms::Form
    {

    public:
        testAppGUI(void)
        {
            InitializeComponent();
        }

    protected:
        ~testAppGUI()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  button1;
    ...

#pragma region Windows Form Designer generated code
        void InitializeComponent(void)
        {
            ...

        }
#pragma endregion

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             hideGUI();
         }
};
}

HideAndShowGUI.cpp

#include "stdafx.h"

#include "testAppGUI.h"

using namespace testApp;

void hideGUI(){
    //Hide the form, this function should be able to be called by all functions in the program. Not just from forms!

}

void showGUI(){
    //Unhide/Show the form, this function should be able to be called by all functions in the program. Not just from forms!

}

hideGUI and showGUI is declared in HideAndShowGUI.h

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:55:02+00:00Added an answer on June 5, 2026 at 11:55 pm

    If you already have an instance of the form which you want to hide, you will have to pass a reference to that form to the function where you want to change the property.

    You can do this either by directly supplying the form as a parameter of the function or if the function is a member of a class, you can pass the form to (and instance of) the class (and store it as a member variable). Which of these is more appropriate for you depends on your specific context, which we do not have access to without some more of your code.

    Note: Your first snipet is conflicting with your second: in the first you are using form1 as a variable, in the second as a type. If you already have the variable form1, you can just set its property:

    form1->Visible = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to change existing compiled .class file. Actually I have even sources of
I need change background of all text that have two spaces from the start
I use Pjax with tutorial from http://railscasts.com/episodes/294-playing-with-pjax?view=comments I don't need change url and this
I need to change some text values inside an after effect project file that
I need change a value in a ini file like this val2 is the
I need to change the connectionstring area of my aap.config file in vb.net. I
I need to change the font style from bold to italic,by using two buttons.for
I need to change the method attribute of my form with javascript (jQuery or
Like http://bit.ly/ideYPm , i need change this: function createPickers() { $(document.body).select('input.datepicker').each( function(e) { new
I need to change the extension a GIF file (changing it in .gaf) to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.