Call method if declared only

Виталий Фадеев vital.fadeev at gmail.com
Fri Feb 28 06:12:37 UTC 2020


Searching solution for idea !

Goal is to get System message, dispatch/route to method !
If method implemented only !

I dream on in future write clean code of a derived widgets like 
this :

     class Base
     {
        // dispatch
        void On( message ... )
        {
            // call On<message>()
            // example: call OnKeyUp() - if method OnKeyUp() is 
exists only
        }
     }

     class Derived : Base
     {
        // method implementation
        void OnKeyUp( ... )
        {
            //
        }
     }



I tryed code like this:

     import core.sys.windows.windows;
     import std.stdio;


     class Base
     {
        LRESULT On( UINT message, WPARAM wParam, LPARAM lParam )
        {
		switch ( message )
		{
			case WM_KEYDOWN:
                                 OnWM_KEYDOWN( wParam, lParam );  
//   <-- but it required declared OnWM_KEYDOWN(...) in base class 
Base. How will be without declaring in Base ?
				break;

			default: 				
		}
        }
     }


     class Button : Base
     {
         LRESULT OnWM_KEYDOWN( WPARAM wParam, LPARAM lParam )
         {
             writeln( "WM_KEYDOWN" );
         }
     }


May be other than derived ? May be templating ?
How to implement ?



More information about the Digitalmars-d-learn mailing list