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 8118079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:22:25+00:00 2026-06-06T04:22:25+00:00

I am trying to write a simple CLR-Windows Form Application. It will show a

  • 0

I am trying to write a simple CLR-Windows Form Application. It will show a window having a button. As soon as you click the button, it will hide one of the open Windows. To achieve this I am calling ShowWindow(00050214, false );, where 00050214 is the handle of the Window I am hiding.

But it is giving error:

Error   1   error C3861: 'ShowWindow': identifier not found c:\users\afnan
\documents     \visual studio 2010\projects\winformtest\winformtest\Form1.h 80

Please see the last lines of .h file given below, to see how I am using the above function.

WinformTest.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"
#include"windows.h"

using namespace WinformTest;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false); 

// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}

Here is .h file

#pragma once

namespace WinformTest {

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::Button^  button1;
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->button1 = (gcnew System::Windows::Forms::Button());
        this->SuspendLayout();
        // 
        // button1
        // 
        this->button1->Location = System::Drawing::Point(91, 51);
        this->button1->Name = L"button1";
        this->button1->Size = System::Drawing::Size(75, 23);
        this->button1->TabIndex = 0;
        this->button1->Text = L"button1";
        this->button1->UseVisualStyleBackColor = true;
        this->button1->Click += gcnew System::EventHandler(this,    
&Form1::button1_Click);
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(284, 262);
        this->Controls->Add(this->button1);
        this->Name = L"Form1";
        this->Text = L"Form1";
        this->ResumeLayout(false);

    }
#pragma endregion
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

             ShowWindow(00050214, false );

         }
};
}

UPDATE

I have now put windows.h in form.h file, and used ShowWindow((HWND)0x00050214, SW_HIDE);
but now I am getting:

Error   1   error LNK2028: unresolved token (0A000011) "extern "C" int __stdcall 
ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function 
"private: void __clrcall WinformTest::Form1::button1_Click(class System::Object ^,class 
System::EventArgs ^)" 
(?button1_Click@Form1@WinformTest@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)    
C:\Users\Afnan\Documents\Visual Studio 2010\Projects\WinformTest\WinformTest\WinformTest.obj

Error   2   error LNK2019: unresolved external symbol "extern "C" int __stdcall 
ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function 
"private: void __clrcall WinformTest::Form1::button1_Click(class System::Object ^,class 
System::EventArgs ^)" 
(?button1_Click@Form1@WinformTest@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)    
C:\Users\Afnan\Documents\Visual Studio 2010\Projects\WinformTest\WinformTest\WinformTest.obj

Error   3   error LNK1120: 2 unresolved externals   C:\Users\Afnan\Documents\Visual  
Studio 2010\Projects\WinformTest\Debug\WinformTest.exe  1

How do put handle? I got this handle using spy++ tool. It also shows caption corresponding to the handle expressed in numbers. The corresponding handle in my case is: WinformTest – Microsoft Visual Studio

  • 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-06T04:22:26+00:00Added an answer on June 6, 2026 at 4:22 am

    Your header file does not include windows.h and so the symbol ShowWindow is not known to it.

    The way you call ShowWindow is also wrong. The second parameter is an int and you want to pass SW_HIDE. And I bet that your window handle is actually a hex number.

    ShowWindow((HWND)0x00050214, SW_HIDE);
    

    As an aside, I’m not sure why you put so much code in the header file. Normally you would declare the class in the header file and then define the implementation in the cpp file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some simple code which will read a text file
I am trying to write a simple application to interact with NFC tags, but
I am trying to write a simple Java function that will take a list
I'm trying to write a simple WPF application in C#. Coming from a primarily
I'm trying to write a simple google extension that will upon clicking ctrl+alt+x search
I am trying to write simple dcmtk application I adeed the following header #include
i'm playing with IOCP. I'm trying to write simple application that async reads data
Trying to write a simple jQuery function that will multiple the index of an
im trying to write a simple gui form to display if any database connections
I am trying to write a simple Android application using the NDK and C++.

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.