Print Page | Close Window

How to find the STATIC controls on a form

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=12875
Printed Date: 04 December 2024 at 9:38pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to find the STATIC controls on a form
Posted By: TrevorS
Subject: How to find the STATIC controls on a form
Date Posted: 09 December 2008 at 8:22am
I would like to find all of the static controls on a form view.
I want to disable all controls except the statics (to prevent accidental edits until the user has confirmed that they intend to edit).
 
I can't see a way to get at cs.lpszClass.
And the "un-attached" CWnd has a runtime class of CWnd, so I can't test the actual RUNTIME CLASS.
 
Unless I know the class, I don't think I can reliably test the style masks either?
 
Is there an easy way to do this?
 

for(pWnd = GetWindow(GW_CHILD); pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT) )

{

CString sText;

pWnd->GetWindowText( sText );

TRACE( _T("Processing %s / %s\n"), pWnd->GetRuntimeClass()->m_lpszClassName, sText );

TRACE( _T("style 0X%08x\n"), pWnd->GetStyle() );

}



Replies:
Posted By: Oleg
Date Posted: 10 December 2008 at 1:11am

Hi,

 

Use GetClassName:

 

TCHAR szClassName[10];
if ((!::GetClassName(m_hWnd, szClassName, 10)) ||  // didn't get class
   (lstrcmpi(szClassName, _T("Static"))))        

  {


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: TrevorS
Date Posted: 10 December 2008 at 7:15am
Thanks. I discovered that after I posted here.
I still didn't find masks for filtering all of the styles. For example BS_PUSHBUTTON is 0. I can't use this technique for a value of zero.
 

if( (pWnd->GetStyle() & BS_GROUPBOX ) == BS_GROUPBOX )



Posted By: Oleg
Date Posted: 10 December 2008 at 3:15pm
Yes, BS_PUSHBUTTON  is 0.

if( (pWnd->GetStyle() & 0xF) == BS_GROUPBOX )

...

if( (pWnd->GetStyle() & 0xF) == BS_PUSHBUTTON)

etc.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net