Win32: hWnd for Continuous Forms Detail Section(s)? (1 Viewer)

riktek

New member
Local time
Yesterday, 23:49
Joined
Dec 15, 2023
Messages
27
I'm noodling on extending or tweaking the mechanism behind scrolling text in text boxes, to address a form's Detail section, especially while it is in Continuous Forms view.

Apparently, Windows regards a TextBox to be a window. As such, it has an hWnd. Dev Ashish's widely circulated code calls the Win32 GetFocus function to retrieve a control's hWnd so that messages can be directed to it. So far, so good.

It stands to reason that Windows also regards a form section to be a window, having a hWnd. There are some wrinkles, e.g., that GotFocus doesn't occur for forms with controls, so perhaps GetCapture is the better choice, or working through a control to get its parent, but still.

The questions are:
- Whether and how one can get the (or a) hWnd for a form's Detail section.
- Whether the hWnd for the Detail section of the current record in continuous forms view differs from the hWnd of the Detail section for other records.

Google is of no help, and this may simply be unfounded conjecture, so before I go further down this rabbit hole, any thoughts would be welcome.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:49
Joined
May 7, 2009
Messages
19,243
that GotFocus doesn't occur for forms with controls,
which GotFocus, the Form? you can use the Activate event.
Both the Form Header and Detail has separate windows, their class name are the same, OFormSub.
these windows are child of another parent window, so it is not easy to just dig into them.
 

riktek

New member
Local time
Yesterday, 23:49
Joined
Dec 15, 2023
Messages
27
which GotFocus, the Form? you can use the Activate event.
Both the Form Header and Detail has separate windows, their class name are the same, OFormSub.
these windows are child of another parent window, so it is not easy to just dig into them.
Thanks for your thoughts.

Re GotFocus, the point simply is that, in the Access object model, "Focus" doesn't go to a form with controls. So, to the extent that Windows evaluates "Focus" in the same fashion, the Win32 GetFocus function may not return an hWnd for the form or one of its sections and another means may be necessary.

Event selecton is a question of when to call Win32 to get the hWnd. Activate might work instead, as you note. Except, of course, for subforms, which are documented not to sink that event, and PopUps, which exhibit the same behavior notwithstanding it being undocumented.

Perhaps the Current event, which relates to record selection on continuous forms, may be it.

In either case, the question in part is how Windows evaluates the event insofar as evaluating whether Focus or Capture is with the Section window or elsewhere.

Where does the "OFormSub" information come from? I presume they're WindowEx instances and can't find any documentation of the word. Is it a return value from inspecting the object with some Win32 Get function, or something else?

Otherwise, if it were easy, I wouldn't be here asking. ;-)

To the point, though, and recognizing that Sections are child windows of the Form window, how does one get the hWnd of the Detail section for the current record in continuous forms?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:49
Joined
Feb 19, 2013
Messages
16,612
Think you will find the hwnd for a control only exists whilst that control has the focus, Once it loses focus, the hwnd is discarded.

Navigating via hwnd is not easy - you can basically retrieve the position and size of the window and the parent. What you can't do (so far as I am aware) is determine what the window contains - the app, the form, the control, etc.

recognizing that Sections are child windows of the Form window
I don't believe they are child windows - Not tested but the parent of a control is the form, not a section. Easy enough to determine, in your control gotfocus event put

debug.print controlname.hwnd (may work, may not)
debug.print me.section(0).hwnd
debug.print controlname.parent.hwnd

you can also put the same code in the detail gotfocus event, see what you get
 

riktek

New member
Local time
Yesterday, 23:49
Joined
Dec 15, 2023
Messages
27
Think you will find the hwnd for a control only exists whilst that control has the focus
That's all the time I'll need it.

I don't think I'm going to get the hWnd via VBA other than calling for it in the right event procedure. For a Section, that's probably Paint, chiefly because sections don't have any other events, except for things like Click or DblClick.

Beyond that, what I'm after is a Win32 call. I'll dink around with what I've got a handle on so far (pardon the pun) and maybe browse the API reference a bit more.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:49
Joined
May 7, 2009
Messages
19,243
can you tell has what are you trying to accomplish right now? what form do you have?
 

riktek

New member
Local time
Yesterday, 23:49
Joined
Dec 15, 2023
Messages
27
Just experimenting with adding functionality.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:49
Joined
Feb 19, 2013
Messages
16,612
The detail paint event has been the subject of several threads in this forum, some in the last month or so - see similar threads below or do a search
 

riktek

New member
Local time
Yesterday, 23:49
Joined
Dec 15, 2023
Messages
27
The detail paint event has been the subject of several threads in this forum, some in the last month or so - see similar threads below or do a search
Thanks. That's quite kind. I'll do a more deliberate search.

I'm actually familiar with a few of them, though. A friend who implements a similar subclass framework actually sparked my idea when he implemented one of those solutions in his framework.
 

Users who are viewing this thread

Top Bottom