Hi guys...
Having slayed the richtext control dragon with my own simple library... I come upon this strange problem
Imagine a tab control with two tabs "Results" and "Log".
Each has a child form.
Each child form has a (as in one, single) control.
On the Results tab, the form contains a richtext control (I can print to it nicely with all sorts of cool fonts/colors/etc)
On the Log tab, the form contains listview control (which I use as a running log - yes, a kludge but it works!)
The PROBLEM..
If the LOG tab is selected/active and I print to the richtext control, I have to select back and forth to ever see the richtext.
Then it appears in all it's glory.
I've tried setfocus, set selected tab, various combinations - but the fact remains that if the user has the LOG tab selected when RESULTS come in, he won't see them.
Ideas?
Paul?
If I understand correctly:
- The LOG tab is active (the one with the Listview)
- You initiate a "Print" function (presumably from a menu item or hotkey)
- When you start the print process you want to programmically change the tab to the Results tab?
This is the part that is not clear to me:
"I have to select back and forth to ever see the richtext."
Do you mean that the first time that you switch to the RichEdit that the actual text is not visible? A repainting issue? A control not visible issue?
I'll try to be clearer.
If the log tab is selected. The log form is visible, the listview control on the form on the log tab is visible....
And you print to the richtext control which is on the richtext form that is attached to the results tab that is not selected... you don't see the text. If you select the richtext connected tab via program you don't see the text. To see the text you have to select (with the mouse).
The richtext tab, then the log/listview tab, then the richefit tab again and there is your beautiful richtext.
If, of course, the results tab/richtext form/richtext control is first and foremost WHEN text is sent to the richtext control. (and by this I mean my manual selection with the mouse)
All is well.
And yes, it "seems like" that the form with the richtext control isn't just "coming to the top" (visible). When that tab is selected programmatically.
I've tried select tab. (Which selects it but doesn't bring the right form to the surface). I've tried giving the tab focus. Repainting.
I guess the simplest way to put it is this:
Tab 2 selected.
Do something on (form attached to) tab 1
The only way to get that to appear is when there is a manual change from 2 to 1.
There is no way I've found programming that does *exactly*what FF3 does when changing tabs.
Obviously it's hiding one form and making the other visible (I think)...
Does that make it clearer?
1) Right tab selected - print stuff - success
2) Wrong tab selected - what is needed programatically to "select": the proper tab AND have the right form come to the top in all its Glory. In other words, to do exactly what a manual mouse click does in selecting right tab from wrong tab.
Simple selecting the active tab or focus or whatever doesn't do it.
Sorry I am not at my development computer right now but a few searches of the forum seems to indicate that maybe the following sequence of function calls should do the job. Please let me know if it does.
FF_TABCONTROL_SETTABFOCUS (HWND_MAINFORM_MAINTAB, TabNumber)
FF_TABCONTROL_SETSELECTEDTAB (HWND_MAINFORM_MAINTAB, Tabnumber)
Obviously change the HWND_MAINFORM_MAINTAB and TabNumber to the values relevant to your program.
Maybe you've already tried that combination.
Yes sir, I've tried both of those in various combinations
No joy. I think they don't force the FORM to the front.
(And sadly, I don't know how).
Using those is somehow different than physically clicking the tab.
If you're able to send me the project then I can try to decipher where the problem is (or at least the CODEGEN*.* files). Maybe somewhere else in the code the tab focus is being stolen back to the original form. Hard to know.
Paul.
First, many many thanks for your help. I realize that FF for PB is sort of on the shelf with PB essentially static/deprecated so your continued help is, well.. just thanks!
(PB is what I know, what I've written almost 100 libraries in, etc - so I'm stuck with it until 32 bit programs stop running - or I have time to learn something else (aka the 12th of never)
I created a mini project that does the EXACT thing.
The "actual" project is rather large and uses crypto hardware/etc so not feasible to share it. it wouldn't run.
So I whipped this up.
All you have to do is
1: Run executable
2: Select "Log" tab
3: Press "Command1".
You'll see the "focus" change back to "results" but you won't see the richtext.
You have to then click "Log" and then "Results" again to see the results.
Maybe I'm dense - I never assume I'm not. haha.
James,
I commented out one line in the DisplayFakeRTF routine and added one below it. I think it now works as you stated it should. Here are the two lines: ' APP_SET_RTF_FOCUS
FF_TabControl_SetTabFocus( HWND_FRMMAIN_TABCONTROL1, 0 )
You can probably delete the APP_SET_RTF_FOCUS sub.
David
Thanks David. Now I could SWEAR I tried this at one point, and it didn't work.
Hence the bunch of "tried" and commented out routines.
I modified the routines thusly in the "test" program and it seemed to work...
(which is essentially exactly what you did, just a few subroutines deeper)
Sub SetTabFocus(MyTabNum As Dword)
Select Case MyTabNum
Case %TAB_RESULTS
FF_TabControl_SetTabFocus( HWND_FRMMAIN_TABCONTROL1, 0 )
Case %TAB_LOG
FF_TabControl_SetTabFocus( HWND_FRMMAIN_TABCONTROL1, 1 )
End Select
End Sub
Sub APP_SET_RTF_FOCUS
Call SetTabFocus(%TAB_RESULTS)
End Sub
Excellent - happy that a solution was found - thanks David for looking at this. You found the solution before I even had a chance to download the sample project. :)
You're both welcome, just happened to be up late and bored.