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

Display colored text in a text box

davidgraham
Beginner
1,269 Views

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)

0 Kudos
10 Replies
dboggs
New Contributor I
1,280 Views

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.

0 Kudos
andrew_4619
Honored Contributor III
1,280 Views

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

0 Kudos
davidgraham
Beginner
1,280 Views

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.

0 Kudos
davidgraham
Beginner
1,280 Views

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/

0 Kudos
Anthony_Richards
New Contributor I
1,280 Views

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.
 

0 Kudos
Neels
New Contributor II
1,280 Views

Nor does it show in Exploder 11 or Chrome.

Neels

0 Kudos
Steven_L_Intel1
Employee
1,280 Views

Hmm - let me see if I can fix that.

0 Kudos
Steven_L_Intel1
Employee
1,280 Views

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

0 Kudos
Neels
New Contributor II
1,280 Views

Figure 1 shows but not figure 2.

Neels

0 Kudos
Steven_L_Intel1
Employee
1,280 Views

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

0 Kudos
Reply