Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Annonces
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Display colored text in a text box

davidgraham
Débutant
1 335 Visites

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 Compliments
10 Réponses
dboggs
Nouveau contributeur I
1 346 Visites

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 Compliments
andrew_4619
Contributeur émérite III
1 346 Visites

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

0 Compliments
davidgraham
Débutant
1 346 Visites

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 Compliments
davidgraham
Débutant
1 346 Visites

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 Compliments
Anthony_Richards
Nouveau contributeur I
1 346 Visites

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 Compliments
Neels
Nouveau contributeur II
1 346 Visites

Nor does it show in Exploder 11 or Chrome.

Neels

0 Compliments
Steven_L_Intel1
Employé
1 346 Visites

Hmm - let me see if I can fix that.

0 Compliments
Steven_L_Intel1
Employé
1 346 Visites

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

0 Compliments
Neels
Nouveau contributeur II
1 346 Visites

Figure 1 shows but not figure 2.

Neels

0 Compliments
Steven_L_Intel1
Employé
1 346 Visites

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

0 Compliments
Répondre