Ver Mensaje Individual
  #8  
Antiguo 18-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
Ahora mismo he conseguido crear el componente y que autoseleccione pero la parte de que por defecto ponerle ciertas propiedades y que se cree con ellas no lo consigo. Tengo esto que no surte ningun efecto en el tema de las propiedades:
Código PHP:
//---------------------------------------------------------------------------

#ifndef ListBoxAutoSelectH
#define ListBoxAutoSelectH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
//---------------------------------------------------------------------------
class PACKAGE TListBoxAutoSelect : public TListBox
{
private:
    
int _index;
    
TWndMethod _oldWndProc;
    
TNotifyEvent _vScroll;
protected:
    
virtual void __fastcall WndProc(TMessage &msg);
public:
    
__property TNotifyEvent OnVerticalScroll = {read _vScrollwrite _vScroll};
    
__property int CurrentIndex = {read _index};
    
__fastcall TListBoxAutoSelect(TComponentOwner);
    
__fastcall ~TListBoxAutoSelect();

__published:
};
//---------------------------------------------------------------------------
#endif 
Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "ListBoxAutoSelect.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TListBoxAutoSelect *)
{
    new 
TListBoxAutoSelect(NULL);
}
//---------------------------------------------------------------------------

__fastcall TListBoxAutoSelect::TListBoxAutoSelect(TComponentOwner)
    : 
TListBox(Owner)
{
    
this->Height this->ItemHeight;
    
this->Style lbOwnerDrawFixed;
    
_oldWndProc this->WindowProc;
}
//---------------------------------------------------------------------------

__fastcall TListBoxAutoSelect::~TListBoxAutoSelect() {
    
this->WindowProc _oldWndProc;
}
//---------------------------------------------------------------------------

virtual void __fastcall TListBoxAutoSelect::WndProc(TMessage &msg) {
    if (
msg.Msg == WM_VSCROLL) {
        
_index GetScrollPos(this->HandleSB_VERT);
        
this->Selected[_index] = true;
    }
    
TListBox::WndProc(msg);
}
//---------------------------------------------------------------------------

namespace Listboxautoselect
{
    
void __fastcall PACKAGE Register()
    {
         
TComponentClass classes[1] = {__classid(TListBoxAutoSelect)};
         
RegisterComponents("Mis Componentes"classes0);
    }
}
//--------------------------------------------------------------------------- 
La idea es que al añadir el componente al TForm ya aparezca con esas propiedades como yo las quiero. Por lo demas funciona perfecto.
Responder Con Cita