- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, I'm brand new to Fortran and Windows programming, but I have learned so much just from reading these forums and Dr. Fortran's posts for hours. Thank you to all the experts and the people who asked my questions before I even thought of them.
I have 2 questions while I'm waiting for my copy of Compaq Visual Fortran to ship.
1. I have 2 sets of controls (static text and edit box each) on a modal dialog box that opens when a user clicks an item on a menu from the main window of the application. Depending on a variable, I'd like to have one set enabled+visible and the other disabled+not visible, or vice versa. I was able to use ShowWindow(item, SW_HIDE) in a subroutine in response to a user action, but is there any way to set this before the dialog is displayed or immediately after?
2.I have a bunch of edit fields that are checked for validity when the user clicks a button, and I would like to color the text in the edit controls that are invalid differently. This is also in a separate modal dialog box. Here is what I have so far:
lret = DlgGet(dlg, TempBox, text)
if (len_trim(text)>0) then
read (text,*,ERR=1459) x
if (x>0 .AND. x<5000) then
cr%met(rPosition, hPosition)%temp = x
else
!color red or something
lret = dlgset(dlg, TempBox, "invalid tempearture")
valid = .FALSE.
end if
else
valid = .FALSE.
end if
I'm sure there is a way to change the text color, but I don't have a clue. Can anyone give a quick example?
Thank you for your time!
Chip
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK it is not possible to change the text color in a QuickWin dialog. When you find a way, dont hasitate to contact me :-)
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have access to the dialog resource editor, then display the properties tab of the dialog control and on the 'General' tab you will see a 'Visible' box which you can untick, so that the control is not visible when the dialog is first displayed.
You can change text and background of controls by subclassing the dialog (substitute your own using SetWindowLong) and intercepting the WM_CTLCOLOR... messages (such as, for example,WM_CTLCOLOREDIT: An edit control that is not read-only or disabled sends the WM_CTLCOLOREDIT message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the edit control.
[WM_CTLCOLOREDIT
hdcEdit = (HDC) wParam; // handle to display context
hwndEdit = (HWND) lParam; // handle toedit control ]
ColorDlgProc is your own window procedure, written to intercept and process window messages,
passing any unprocessed messages to the default window procedure:
...
hOldProc=SetWindowLong(dlg%hWnd, GWL_WNDPROC, LOC(ColorDlgProc) )
...
Define your own pen and brushes, passing them as global variables(e.g.
...
hRedBackBrush=CreateSolidBrush(RGB(#FF, 0, 0) )
hBluePen=CreatPen(PS_SOLID,0,#0000FF)
...
then, in your subclassed procedure, add code such as:
! Dialog procedure ColorDlgProc(hWNd,mesg, wparam, lparam)
SELECT CASE(mesg)
CASE(WM_CTLCOLOREDIT)
ctrlid=GetDlgCtrlId(lParam)
IF(ctrlid.eq.IDC_YOUREDITCONTROL) THEN
hOldPen=SelectObject(wparam, hBluePen)
hOldBrush=SelectObject(wparam, hRedBackBrush)
ColorDlgProc= hRedBackBrush
return ! immediate return required
ENDIF
! Pass on unprocessed messages to the 'old' default dialog procedure
ColorDlgProc=CallWindowProc(hOldProc, hWnd, Mesg, wParam, lParam)
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The idea of subclassing the dialog was what I was missing, so that should solve my problems once I completely understand how it works. I'm trying to change the visible property at run-time, but I think I will be able to do that with ShowWindow in an init case once I subclass the window.
Thanks!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page