Display colored text in a text box

Display colored text in a text box

I want to display text in a text box in Red if it is over a certain value, otherwise display it in Black.

My text box is disabled (i.e. display only).

Searching the forum I found the suggestion of using SetTextColor.

Is this correct, and how would I use it.

Below is an example - but doesn't work. Thanks

 

write (C11,'(F10.3,A)') d,char(0)

cr=SetTextColor(hDC,RGB(0,256,255))

iret=SetDlgItemText(hwnd,IDC_HEIGHTD,c11)

11 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You can create a "text box" in different ways. From your example, it looks like you want a true "windows" text box of the form that woks in a windows dialog box. A second way is to do all the programming yourself, within the Fortran program. Using Quickwin, this second method is pretty easy. That would involve the Fortran call SetTextColor, which effects the text color within a "text window" which is another Quickwin concept.I do this quite often.

But if you want a true Windows dialog text box--well, I hope there is someone else here that can help. I suspect that SetTextColor is incompatible with the windows dialog process.

Try topic http://software.intel.com/en-us/forums/topic/301886 there are various others on the forum if you search.

Thanks, I do want a true Windows dialog text box.

I had found that topic previously when searching - but it makes me realise that my knowledge is limited. I've never (to my knowledge) done subclassing before and not sure where the example code fits into my code.

I have:

iret = DialogBox(hInst,MAKEINTRESOURCE(IDD_MEAN2PTS),hWndMain,LOC(Mean2PtsProc))

which calls:

integer*4 function Mean2PtsProc(hwnd, message, wParam, lParam)

then there is:

select case (message)

case (WM_HELP)

call help

case (WM_INITDIALOG)

Mean2PtsProc=1

h_Write=GetDlgItem(hWnd,IDC_WRITE)

return

case (WM_SHOWWINDOW)

etc...

I'm not sure when hOldProc=SetWindowLong(dlg%hWnd, GWL_WNDPROC, LOC(ColorDlgProc)

fits in with my code.

I solved the problem using Anthony Richard's example. It gives black text on a red background.

I hope to be able to modify it to give red text on a white background - I don't know if that is possible.

http://software.intel.com/en-us/articles/how-to-customize-dialog-box-colors-using-subclassing/

As the joint author (with Steve Lionel) I note that the figures included in the article annoyingly fail to display when browsing the article using FireFox.
 

Nor does it show in Exploder 11 or Chrome.

Neels

Hmm - let me see if I can fix that.

Steve - Intel Developer Support

Ok - should be fixed now. I also changed the link for Xeffort to point to the new site.

Steve - Intel Developer Support

Figure 1 shows but not figure 2.

Neels

Weird - it was showing for me earlier. I'll fix it on Monday, but that particular image is not all that useful.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today