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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:18:32+00:00 2026-05-19T14:18:32+00:00

How to use WndProc Funection for a picturebox in my form ? i try

  • 0

How to use WndProc Funection for a picturebox in my form ?
i try it like this code but it not work and not any message send to my
public: virtual void WndProc( Message% m )

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace MyProject {
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void) {
            InitializeComponent();
            //TODO: Add the constructor code here
        }
    protected:
        ~Form1() {
            if (components)
                delete components;
        }
    private:
        System::Windows::Forms::PictureBox^  pictureBox1;
        System::ComponentModel::Container ^components;

        void InitializeComponent(void) {
            this->pictureBox1 = gcnew System::Windows::Forms::PictureBox();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(
                this->pictureBox1))->BeginInit();
            this->SuspendLayout();
            // 
            // pictureBox1
            // 
            this->pictureBox1->Location = System::Drawing::Point(41, 27);
            this->pictureBox1->Name = L"pictureBox1";
            this->pictureBox1->Size = System::Drawing::Size(206, 203);
            this->pictureBox1->TabIndex = 0;
            this->pictureBox1->TabStop = false;
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(292, 265);
            this->Controls->Add(this->pictureBox1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(
                this->pictureBox1))->EndInit();
            this->ResumeLayout(false);
        }
    };

    ref class pictureBox1 : PictureBox {
    public:
        virtual void WndProc( Message% m ) override {
            __super::WndProc(m);
        }
    };
}//close NameSpace
  • 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-05-19T14:18:33+00:00Added an answer on May 19, 2026 at 2:18 pm

    The answer provided by SLaks is correct, and I agree 100% with his comments that you need to understand what the code means, rather than copying and pasting a magical snippet off Stack Overflow.

    But I see you’re still screaming about how you should write the code to use your custom PictureBox class (the one on which you overrode the WndProc function), rather than the built-in one. That’s really a simple matter of changing all of the references to System::Windows::Forms::PictureBox to pictureBox1 (your custom class). Of course, you’ll need to change the name of one or the other, but I recommend choosing better names than the default for everything.

    For example, try the following:

    namespace MyProject {
    
        using namespace System;
        using namespace System::ComponentModel;
        using namespace System::Collections;
        using namespace System::Windows::Forms;
        using namespace System::Data;
        using namespace System::Drawing;
    
    
        public ref class Form1 : public System::Windows::Forms::Form
        {
        public:
            Form1(void)
            {
                InitializeComponent();
                //
                //TODO: Add the constructor code here
                //
            }
    
        protected:
    
            ~Form1()
            {
                if (components)
                {
                    delete components;
                }
            }
        private: pictureBox1^ myPictureBox;
        protected: 
    
        private:
    
            System::ComponentModel::Container ^components;
    
    
            void InitializeComponent(void)
            {
                this->myPictureBox = (gcnew pictureBox1());
                (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->myPictureBox))->BeginInit();
                this->SuspendLayout();
                // 
                // myPictureBox
                // 
                this->myPictureBox->Location = System::Drawing::Point(41, 27);
                this->myPictureBox->Name = L"myPictureBox";
                this->myPictureBox->Size = System::Drawing::Size(206, 203);
                this->myPictureBox->TabIndex = 0;
                this->myPictureBox->TabStop = false;
                // 
                // Form1
                // 
                this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
                this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
                this->ClientSize = System::Drawing::Size(292, 265);
                this->Controls->Add(this->myPictureBox);
                this->Name = L"Form1";
                this->Text = L"Form1";
                (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->myPictureBox))->EndInit();
                this->ResumeLayout(false);
    
            }
    
        };
    
    
    
    
    ref class pictureBox1  : PictureBox  {
        //protected:
        public:      
            virtual void WndProc( Message% m ) override {
                            __super::WndProc(m);
            }
        };
    
    
    
    
    }//close NameSpace
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

uMsgNotify = WinApi.RegisterWindowMessage(SHELLHOOK); WinApi.RegisterShellHookWindow(this.Handle); in my Form constructor and this in my overrided WndProc:
I use Firebug and the Mozilla JS console heavily, but every now and then
I am receiving errors and at the same time trying to make this work
This is going to be a long post. I would like to have suggestions
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when
I want to use a temp directory that will be unique to this build.
(please excuse that I didn't use aliases). I would like my query output to
In my Win32 C++ DLL I find that if I try to use RegisterClassEx
I have a situation where I would like to move a windows form by
This is my code for creating my menu for the program: WNDCLASS wc; ...

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.