| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Felip Master

Registrado: 09 Jun 2004Mensajes: 200
|
Publicado: Mie 11 Sep, 2013 11:56 am Asunto: ListBox sobre otras ventanas |
|
|
| En ciertas situaciones, la lista de un TComboBox puede aparecer fuera del área cliente del formulario. ¿Es posible hacer lo mismo con un TListBox? En otras palabras, parte de un TListBox estar sobre el formulario padre y otra parte estar sobre otras ventanas (fuera del área cliente del formulario)? |
|
| Volver arriba |
|
 |
Felip Master

Registrado: 09 Jun 2004Mensajes: 200
|
Publicado: Mie 11 Sep, 2013 12:31 pm Asunto: |
|
|
Otro ejemplo: Poner um componente num form. Después ao editar:
Nombre_del_Componente->
aparecerá una ventana (similar a un listbox) que puede superponerse otras ventanas. Y ambas las ventanas (Code Editor y ventana de propiedades) siguen recibiendo el foco del teclado. |
|
| Volver arriba |
|
 |
Felip Master

Registrado: 09 Jun 2004Mensajes: 200
|
Publicado: Vie 13 Sep, 2013 5:21 am Asunto: |
|
|
He encontrado una manera. Necesito básicamente dos formularios:
Form1:
| Código: |
object Form1: TForm1
Left = 708
Top = 258
BorderStyle = bsToolWindow
Caption = 'Form1'
ClientHeight = 104
ClientWidth = 280
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnDblClick = FormDblClick
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 32
Top = 24
Width = 193
Height = 21
TabOrder = 0
Text = 'Edit1'
OnKeyDown = Edit1KeyDown
end
end
==================
//-------------
#include <vcl>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//-----------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//------------
void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==VK_DOWN) {
Form2->ListBox1->ItemIndex+=1;
}
else
if(Key==VK_UP) {
Form2->ListBox1->ItemIndex-=1;
}
else
if(Key==VK_RETURN) {
ShowMessage(Form2->ListBox1->Items->Strings[Form2->ListBox1->ItemIndex]);
}
if(Key==VK_UP || Key==VK_DOWN) {
Key=NULL;
if(Form2->Visible==false ) {
int ss=Edit1->SelStart;
if((Form1->Top+Edit1->Top+Edit1->Height+31+Form2->ListBox1->Height)<Screen>Height)
Form2->Top=Form1->Top+Edit1->Top+Edit1->Height+20;
else
Form2->Top=Form1->Top+Edit1->Top+8-Form2->ListBox1->Height;
if( (Form1->Left+Edit1->Left+Edit1->Width+8+Form2->ListBox1->Width)<Screen>Width)
Form2->Left=Form1->Left+Edit1->Left+Edit1->Width;
else
Form2->Left=Form1->Left+Edit1->Left-Form2->Width;
Form2->Visible=true;
Form1->BringToFront();
Edit1->SelStart=ss;
}
}
if(Form2->ListBox1->ItemIndex==-1) Form2->ListBox1->ItemIndex=0;
}
//----------
void __fastcall TForm1::FormDblClick(TObject *Sender)
{
Form2->Close();
}
//---------
|
Form2:
| Código: |
object Form2: TForm2
Left = 1091
Top = 180
BorderStyle = bsNone
Caption = 'Form2'
ClientHeight = 218
ClientWidth = 190
Color = clRed
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ListBox1: TListBox
Left = 0
Top = 0
Width = 190
Height = 218
Align = alClient
BorderStyle = bsNone
ItemHeight = 13
Items.Strings = (
'aaaaaaaaaaaa'
'bbbbbbbbb'
'ccccccccc'
'dddddddddd'
'eeeeeeeeeeeee'
'fffffffffffff'
'gggggggggggggggggg'
'hhhhhhhhhhhh'
'iiiiiiiiii'
'jjjjjjjjjjjjjjjjjjjjjjjjjj'
'kkkkkkkkkkkkkkkkkkk'
'llllllllllllllllll'
'mmmmmmmmmmmmmm'
'n'
'ooooooooooooo'
'ppppppppp'
'qqqqqqqqqqqq'
'rrrrrrrrrrrrr'
'ssssssssssssssss'
'tttttttttttt'
'uuuuuuuuuuuuuu'
'vv'
'wwwwwwwwwwww'
'x'
'y'
'zzzzzzzzzzzzz')
TabOrder = 0
end
end
============
// Unit2.h
[...]
private: // User declarations
void __fastcall CreateParams(TCreateParams &Params);
==========
// Unit2.cpp
// Código de _Leo
void __fastcall TForm2::CreateParams(TCreateParams &Params)
{
TForm::CreateParams(Params);
Params.ExStyle |= WS_EX_OVERLAPPEDWINDOW | WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW;
}
|
|
|
| Volver arriba |
|
 |
|