15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Changing Listbox style programatically

Adrian_Glanvill@stercomm.com
Tuesday, April 16, 1996

     Environment:  VC++ 4.1, Windows NT 3.51 Service Pack 4
     
     I have several classes derived from CFormView, each using the same 
     dialog template. This template contains a listbox which has the 
     LBS_EXTENDEDSEL style, which is correct for all but one of the derived 
     classes. The listbox window is mapped using DDX to a CListBox member.
     
     In one of my CFormView derived classes, I need to implement only a 
     single-selection list, so I used the CWnd::ModifyStyle function to 
     remove the LBS_EXTENDEDSEL style. I placed this call inside my view's 
     OnInitialUpdate function, after the base class OnInitialUpdate had 
     been called.
     
     Unfortunately, the listbox still behaved as though it had the 
     LBS_EXTENDEDSEL style. I traced through the MFC code and verifed that 
     SetWindowLong was being called with the amended style, and I used 
     Spy++ to verify that the listbox did receive the WM_STYLECHANGING and 
     WM_STYLECHANGED messages.
     
     My question is, how can I change the listbox style programatically 
     using MFC ?
     
     Thanks,
     
     Adrian Glanvill
     Sterling Commerce, Inc.



Don.Irvine@net-tel.co.uk
Thursday, April 18, 1996

[Mini-digest: 2 responses]

Adrian,

> My question is, how can I change the listbox style programatically 
> using MFC ?

If you can't change the this listbox style dynamically (which it appears
you can't), then you could try one of the following:

1) Use two dialog resources.

2) Have two listboxes, one with LBS_EXTENDEDSEL, one without. Show/Hide
   the relevant listboxes at runtime.

3) Dynamically create the listbox (with the required style) at runtime.
   Note that you will need to be beware of dialog base units and window
   Z ordering.


Have fun,


Don
-----From: "Mike Blaszczak" 

From: 	owner-mfc-l@netcom.com on behalf of Adrian_Glanvill@stercomm.com
Sent: 	Tuesday, April 16, 1996 09:49

> Environment:  VC++ 4.1, Windows NT 3.51 Service Pack 4

Thanks.

> and I used 
> Spy++ to verify that the listbox did receive the WM_STYLECHANGING and 
> WM_STYLECHANGED messages.

Thanks!

To my knowledge, none of the standard Windows controls react to 
WM_STYLECHANGING and WM_STYLECHANGED. You have to manually destroy the window 
and recreate it with the different style bits you would like to use.

.B ekiM
TCHAR szSpringtime[] = _T("Check twice, save a life: motorcycles are 
everywhere!");




| Вернуться в корень Архива |