Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How do disable - enable a contol?

reidar
New User
1,765 Views

I am programming a windows application. In a dialogue (modeless) I want to disable/enable controls dependent about defined conditions..

Can anybody advise?

 

0 Kudos
1 Solution
andrew_4619
Honored Contributor III
1,765 Views
use ifwin, only: GetDlgItem, EnableWindow, ShowWindow, SW_SHOW, SW_HIDE, TRUE, FALSE, handle, bool
implicit none

integer (bool) :: bret
integer handle :: hwnd, hdlg

hwnd = GetDlgItem(hDlg, ID_CONTROL)  ! get control handle using dialog handle and control index
bret = EnableWindow(hwnd,  TRUE )    ! enable control
bret = EnableWindow(hwnd,  FALSE )   ! disable control

bret = ShowWindow( hwnd, SW_SHOW )  ! make control visible
bret = ShowWindow( hwnd, SW_HIDE )  ! make control invisible

 

View solution in original post

0 Kudos
6 Replies
LRaim
New Contributor I
1,765 Views

This is an example from VS Help:

BOOL CMyFileDialog::OnInitDialog()
{
   CFileDialog::OnInitDialog();

   CWnd* pWndParent = GetParent();

   //make sure you add #include <dlgs.h> for IDs 'edt1' & 'stc3' 

   //disables the 'file name' edit and static control 
   //of the standard file open dialog 

   //get handle of 'file name' combobox control & disable it
   CWnd* pWnd = pWndParent->GetDlgItem(cmb13);
   pWnd->EnableWindow(FALSE);

   //get handle of 'file name' static control & disable it
   pWnd = pWndParent->GetDlgItem(stc3);
   pWnd->EnableWindow(FALSE);

   return TRUE;
}
 

0 Kudos
reidar
New User
1,765 Views

Thanks Luigi,

I forgot to mention  that I am writing in Visual Fortran ...Have not the possibility to apply other languages :-(

0 Kudos
andrew_4619
Honored Contributor III
1,765 Views

Is this a quickwin (iflogm) or a windows api dialog? The answer would be different for each.

0 Kudos
reidar
New User
1,765 Views

It is a windows application, not quickwin..

Best regards

0 Kudos
LRaim
New Contributor I
1,765 Views

If you have created a modeless dialog with its controls using fortran it should be simple to call the 'EnableWindow()' function using Fortran syntax. System calls do not change with language.

 

0 Kudos
andrew_4619
Honored Contributor III
1,766 Views
use ifwin, only: GetDlgItem, EnableWindow, ShowWindow, SW_SHOW, SW_HIDE, TRUE, FALSE, handle, bool
implicit none

integer (bool) :: bret
integer handle :: hwnd, hdlg

hwnd = GetDlgItem(hDlg, ID_CONTROL)  ! get control handle using dialog handle and control index
bret = EnableWindow(hwnd,  TRUE )    ! enable control
bret = EnableWindow(hwnd,  FALSE )   ! disable control

bret = ShowWindow( hwnd, SW_SHOW )  ! make control visible
bret = ShowWindow( hwnd, SW_HIDE )  ! make control invisible

 

0 Kudos
Reply