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

Change controls from visible to invisible at runtime

onkelhotte
New Contributor II
590 Views
Hi there,

I want to change the visible flag from some controls of my QuickWin application from visible to invisible at runtime. The reason is, that our program should ship to a customer and we want that he is not able to change certain values or settings.

When editing the resource file with Visual Studio I can set any control the visible flag to false and so that control wont be visible when I run the program.

I could use the disabled flag at runtime of course, but then the controls are still visible and the customers wants to know, why he is not able to change them.

Thanks in advance,
Markus

0 Kudos
1 Solution
Jugoslav_Dujic
Valued Contributor II
590 Views
Use ShowWindow API:
[fortran]use ifwin

logical:: visible
integer:: show 
...
show = merge(SW_SHOW, SW_HIDE, visible)
ret = ShowWindow(GetDlgItem(Dlg%hWnd, IDCONTROL), show)[/fortran]
Notes:
  1. This will work only while the dialog is alive, i.e. after DlgModal. If you want it at initialization, you have to call it from a dialog-initialization callback (DlgSetSub(DLG_INIT))
  2. IDCONTROL is the ID of the control you want to show/hide.
  3. I love the scalar MERGE intrinsic, which serves as a one-liner IF/ELSE statement. Adopt at will ;-)

View solution in original post

0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
591 Views
Use ShowWindow API:
[fortran]use ifwin

logical:: visible
integer:: show 
...
show = merge(SW_SHOW, SW_HIDE, visible)
ret = ShowWindow(GetDlgItem(Dlg%hWnd, IDCONTROL), show)[/fortran]
Notes:
  1. This will work only while the dialog is alive, i.e. after DlgModal. If you want it at initialization, you have to call it from a dialog-initialization callback (DlgSetSub(DLG_INIT))
  2. IDCONTROL is the ID of the control you want to show/hide.
  3. I love the scalar MERGE intrinsic, which serves as a one-liner IF/ELSE statement. Adopt at will ;-)
0 Kudos
onkelhotte
New Contributor II
590 Views
Damn, GetDlgItem was the function I was searching for...

I was thinking about using the ShowWindow function but I didnt found a way to get the hWnd of a control. This happens when you dont program that much in QuickWin any more :-)

The merge intrinsic is cool, reminds me of the old Fortran code of my boss, when he used ifstatements in one line.

Markus
0 Kudos
Reply