Author Topic: "Press Tab to move between fields."  (Read 626 times)

Lightman

  • Regular Member
  • *
  • Posts: 35
"Press Tab to move between fields."
« on: December 04, 2015, 01:26:46 AM »
Hi Everybody,

The attached code shows the use of Super and Sub classing. Nothing really interesting is really going on here, it's basically a demo derived from Iczelion's Tutorials.

One thing did I want to add to my programs is the ability to 'tab' between edit boxes on a dialog box. You see this all the time in Windows applications and wanted to be able to do the same. So, I subclass an edit box and trap for the tab key being pushed. When it is, I can invoke SetFocus to the next box. But in coding this up, I realize that it will only work with Subclassed edit boxes. I can't add this to a Superclassed edit box as there is only one procedure, how to I know which of the Superclassed boxes I am in and how can I direct it to the next one?

When you see a Windows application where you can tab between edit boxes, have they all been Subclassed to allow that. Or is there a another or 'correct' way to handle tabbing between options in ASM?

Regards,

Lightman 
Regards,

Lightman

TWell

  • Member
  • ****
  • Posts: 748
Re: "Press Tab to move between fields."
« Reply #1 on: December 04, 2015, 01:47:53 AM »
Use IsDialogMessage in message loop.

Lightman

  • Regular Member
  • *
  • Posts: 35
Re: "Press Tab to move between fields."
« Reply #2 on: December 04, 2015, 01:54:07 AM »
Ah, Thanks Tim...

A little like where I trap the colour change in the parent dialog. In my SuperClassed procedure I can call IsDialogMessage to get the handle of which SuperClassed box is talking. Then just trap it out... .if eax==hHandleOfBox1 invoke SetFocus hHandleOfBox2.. and so on...?

Regards,

Lightman

Regards,

Lightman

Lightman

  • Regular Member
  • *
  • Posts: 35
Re: "Press Tab to move between fields."
« Reply #3 on: December 04, 2015, 02:27:00 AM »
Hi,

I think this might be it, but my code is wrong somewhere... My trap for the tab key...

Code: [Select]
.elseif al==VK_TAB
; The tab key has been pushed but who is talking?
invoke IsDialogMessage, hManyEdit, addr msgMyMessage
mov eax, msgMyMessage.hwnd ; Who was it? Handle of the talking control.
; Got the handle, get the next in the list...
invoke GetNextDlgTabItem, hManyEdit, eax, FALSE
invoke SetFocus, eax
.endif

When I created the two SuperClassed windows, I've added the WS_TABSTOP to the window style.

Can anyone nudge me in the right direction? - I've attached the full code...

Regards,

Lightman

Regards,

Lightman

dedndave

  • Member
  • *****
  • Posts: 8734
  • Still using Abacus 2.0
    • DednDave
Re: "Press Tab to move between fields."
« Reply #4 on: December 04, 2015, 02:30:19 AM »

TWell

  • Member
  • ****
  • Posts: 748
Re: "Press Tab to move between fields."
« Reply #5 on: December 04, 2015, 03:10:48 AM »
I mean like this C example
Code: [Select]
while (GetMessage(&msg, NULL, 0, 0) == TRUE)
{
if (!IsDialogMessage(hWnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}