I have encountered problem that I wasn't able to solve so maybe I ll have some luck here. I am overriding WndProc in my application like this :
#include "stdafx.h"
#include <Windows.h>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Drawing;
namespace EXAMPLE
{
public ref class Form1: public System::Windows::Forms::Form
{
public:
Form1()
{
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(GetSystemMetrics(SM_CXSCREEN)/2, GetSystemMetrics(SM_CYSCREEN)/2);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Sizable;
this->Name = L"Test";
this->Text = L"Test";
this->ResumeLayout(false);
}
protected: virtual void WndProc(System::Windows::Forms::Message% m) override
{
//Do stuff in here
Form::WndProc(m);
}
};
}
[STAThreadAttribute]
int main()
{
Application::Run(gcnew projector_fixer::Form1() );
return 0;
}
This works great but since I would like to have my main as clean as possible I have decided to create "controller class" that handles everything by connecting with main. So for example, rather than including event for mouse_click inside EXAMPLE namespace, I would include clicked object in my "controller class" constructor and handle that inside this class. This is easy, but when wanted to override wndproc I realized that I have no idea how do that. I imagine that it might look something like this:
inside main
myclass ^MYCLASS=gcnew myclass(//some way to send wndproc override to function//);
MYCLASS.h
#pragma once
ref class MYCLASS
{
public:
MYCLASS();
overriden_wndproc(System::Windows::Forms::Message% m);
};
MYCLASS.cpp
MYCLASS::MYCLASS(//some way to send wndproc override to function//)
{
overriden_wndproc=//some way to send wndproc override to function//;
}
MYCLASS::overriden_wndproc(System::Windows::Forms::Message% m)
{
//Do stuff in here
Form::WndProc(m);
}
Please note that this is only my guessed version of what would seem logical. All help would be much appreciated.
Peter
I am adding whole wndproc since i strongly believe that event raising might become tricky because i am using break in my function.
protected: virtual void WndProc(System::Windows::Forms::Message% m) override
{
System::Diagnostics::Debug::WriteLine(m);
switch(hZoomSwitch)
{
case 0:
{
hScrollBar1->Value=0;
hTimer->Stop();
hZoomSwitch=2;
break;
}
case 1:
{
hTimer->Start();
hZoomSwitch=2;
break;
}
}
switch(vZoomSwitch)
{
case 0:
{
vScrollBar1->Value=0;
vTimer->Stop();
vZoomSwitch=2;
break;
}
case 1:
{
vTimer->Start();
vZoomSwitch=2;
break;
}
}
Form::WndProc(m);
}