Button does not show at runtime

I made a winForm with a button on it in the Designer (VS 2010 C++).

But when I run my app, the button does not show on the form.

The button visible property is set to true.

Any thoughts as to why I'm getting this behavior?

Thanks...

You'll need to provide more information. We have no idea what you've done.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>
#include "StdAfx.h"

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;

namespace KeyboardInputForm
{
	Boolean popup = true;

    public ref class Form1 sealed: public Form, public IMessageFilter
    {
        // The following Windows message value is defined in Winuser.h. 
    private:
        static const int WM_KEYDOWN = 0x100;
    private:

    public:
        Form1()
        {
            this->AutoSize = true;
            Application::AddMessageFilter(this);
            this->KeyPreview = true;
			this->Opacity = .80; // initial load opacity value
        }

        // Detect all numeric characters at the application level and consume 0.
        [SecurityPermission(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::UnmanagedCode)]
        virtual bool PreFilterMessage(Message% m)
        {
            // Detect key down messages. 
            if (m.Msg == WM_KEYDOWN)
            {
                Keys keyCode =  (Keys)((int)m.WParam) & Keys::KeyCode;
                //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' pressed.");
                if (keyCode == Keys::Pause)
                   {
                        //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' consumed.");
						if (popup == true)
						{
							popup = false;
                            //MessageBox::Show("Hide");
							//Application->Minimize();
							//this->Hide();
							Form1::Opacity = .0;
						}
						else
						{
							popup = true;
                            //MessageBox::Show("Show");
							//Form1->Visible = true;
							//this->Show();
							Form1::Opacity = .80;
						}
                        return true;
                  }
            }
            // Forward all other messages. 
            return false;
        }
    };
}

[STAThread]
int main()
{
    Application::EnableVisualStyles();
    Application::Run(gcnew KeyboardInputForm::Form1());
}



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#pragma once

namespace Checklist {

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

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  lbl_Opacity;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown_Opacity;
	private: System::Windows::Forms::Button^  btn_OK;

	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->lbl_Opacity = (gcnew System::Windows::Forms::Label());
			this->numericUpDown_Opacity = (gcnew System::Windows::Forms::NumericUpDown());
			this->btn_OK = (gcnew System::Windows::Forms::Button());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown_Opacity))->BeginInit();
			this->SuspendLayout();
			// 
			// lbl_Opacity
			// 
			this->lbl_Opacity->AutoSize = true;
			this->lbl_Opacity->Location = System::Drawing::Point(71, 43);
			this->lbl_Opacity->Name = L"lbl_Opacity";
			this->lbl_Opacity->Size = System::Drawing::Size(56, 17);
			this->lbl_Opacity->TabIndex = 0;
			this->lbl_Opacity->Text = L"Opacity";
			// 
			// numericUpDown_Opacity
			// 
			this->numericUpDown_Opacity->Location = System::Drawing::Point(74, 81);
			this->numericUpDown_Opacity->Name = L"numericUpDown_Opacity";
			this->numericUpDown_Opacity->Size = System::Drawing::Size(120, 22);
			this->numericUpDown_Opacity->TabIndex = 1;
			// 
			// btn_OK
			// 
			this->btn_OK->Location = System::Drawing::Point(74, 232);
			this->btn_OK->Name = L"btn_OK";
			this->btn_OK->Size = System::Drawing::Size(75, 23);
			this->btn_OK->TabIndex = 2;
			this->btn_OK->Text = L"OK";
			this->btn_OK->UseVisualStyleBackColor = true;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->AutoSize = true;
			this->CausesValidation = false;
			this->ClientSize = System::Drawing::Size(488, 353);
			this->Controls->Add(this->btn_OK);
			this->Controls->Add(this->numericUpDown_Opacity);
			this->Controls->Add(this->lbl_Opacity);
			this->MinimumSize = System::Drawing::Size(200, 400);
			this->Name = L"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"737NGX Checklist";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown_Opacity))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	};
}
Topic archived. No new replies allowed.