NO

Author Topic: tab stops in modeless dlg window  (Read 3511 times)

cl2606

  • Guest
tab stops in modeless dlg window
« on: March 03, 2008, 02:43:39 PM »
Hello everyone,

I am using Pelles IDE and created a modeless dialog window which is the only window in the program.  I have 2 small edit boxes and 1 push button, which are all set to accept tab stops.  When I tested the window within the resource editor the tabstops worked.  However, when I compile and execute the program the TAB key does nothing.  The cursor sits in the 1st edit box or if the dialog window has focus nothing happens.  Any ideas of what I'm doing wrong or forgot to set?

Also, if the dialog window has the focus I can process the ENTER key through WM_CHAR message to act as if the push button was pressed.  However, if either of the edit boxes have the focus the ENTER key does nothing.  I've been reading and re-reading Petzold and MSDN but obviously I'm missing something, which I'm sure is very trivial.

Thanks for any info.

Curt

Offline DMac

  • Member
  • *
  • Posts: 272
Re: tab stops in modeless dlg window
« Reply #1 on: March 03, 2008, 05:33:07 PM »
You have to set up a message pump for your modeless dialog.

The following article might be helpful.  In it, a single message pump is used for several modeless dialogs.

http://www.codeproject.com/KB/winsdk/Win32SDK_C_TabCtrl.aspx

regards,

DMac
No one cares how much you know,
until they know how much you care.

cl2606

  • Guest
Re: tab stops in modeless dlg window
« Reply #2 on: March 03, 2008, 06:26:06 PM »
DMac,

Thanks for the reply however TabCtrls isn't what I was talking about (though thanks for that link, TabCtrls are something I eventually want to be able to do). 

All that I am trying to do is move the focus from one control to the other using the TAB key.  I can set the focus using SetFocus but I even with that my Tab key doesn't move from one control to the other.  Again all I have are 3 controls: 2 edit boxes and 1 push button.  These are centered on a very small modeless dialog window which is the only window.

And my apologies to the board, I'm thinking this topic should have been in Windows forum. 

Curt

Offline DMac

  • Member
  • *
  • Posts: 272
Re: tab stops in modeless dlg window
« Reply #3 on: March 03, 2008, 07:46:57 PM »
Quote
TabCtrls isn't what I was talking about

Neither was I,  In that project the change in tab index causes a different modless dialog to display and activates a message pump for that dialog.

Anyway what you need is something like this (from that project):

Code: [Select]
static void TabPageMessageLoop (HWND hwnd)
{
    MSG      msg;
    int      status;
    BOOL handled = FALSE;
 
    // Create Accelerator table
    HACCEL hAccTable = CreateAccTable();
 
    while((status =
        GetMessage(&msg, NULL, 0, 0 )) != 0 && !stopTabPageMessageLoop)
    {
        if (status == -1) // Exception
        {
            return;
        }
        else
        {
            // Dialogs do not have a WM_KEYDOWN message so we will seperate
            // the desired keyboard events here
            handled = TranslateAccelerator(hwnd,hAccTable,&msg);
 
            // Perform default dialog message processing using IsDialogM...
            if(!handled) handled=IsDialogMessage(hwnd,&msg);
 
            // Non dialog message handled in the standard way.
            if(!handled)
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
         }
     }
     if(stopTabPageMessageLoop) //Reset: do not PostQuitMessage(0)
     {
         DestroyAcceleratorTable(hAccTable);
         stopTabPageMessageLoop = FALSE;
         return;
     }
 
     // Default: Re-post the Quit message
     DestroyAcceleratorTable(hAccTable);
     PostQuitMessage(0);
     return;
}


DMac
No one cares how much you know,
until they know how much you care.

cl2606

  • Guest
Re: tab stops in modeless dlg window
« Reply #4 on: March 03, 2008, 08:13:15 PM »
Okay...thanks!  Sorry I obviously didn't take the time to read through the text and apply it to what I was trying to do...I just looked at the title and the picutre and assumed that you were talking about tab controls.

Thanks again...appreciate the help.  I will take a closer look.

Curt