Groups | Blog | Home
all groups > dotnet sdk > march 2004 >

dotnet sdk : Modeless Dialog using Win32 API, Tab works backwards??! HELP!


Martin Platt
3/21/2004 3:51:07 PM
Hi

I have an application that uses .NET, but allows it to pass in a window handle, a window title, else it uses the active window as the parent window. The code works, apart from the fact that using the TAB key tabs through the controls in reverse, and, if I then use Shift+TAB, they go in the opposite order (so they're swapped!
I have the tab order set correctly, and swapping the tab order around makes no difference it seems
I'd like the dialog window to act as any other window, and be able to react to TAB. Also, the Default button does not work at all. Pressing ENTER does nothing although the accept button for the dialog form is set
Any ideas would be highly appreciated, and code to go with it would be appreciated even more

Here is the code to show the window

public void DoModalWindow(IntPtr hParent, Form formToShow

IntPtr hWnd = formToShow.Handle
bool isClosing = false
IntPtr parenthandle = IntPtr.Zero
formToShow.Show()
// Set parent of window..
if (hParent != IntPtr.Zero

parenthandle = SetWindowLong(hWnd, GWW_HWNDPARENT, hParent)
EnableWindow(hParent, false)

MSG msg = new MSG(IntPtr.Zero, 0, 0, 0, 0, new POINT(0,0))
// These are more in the way of a test, I thought maybe adding accelerator keys might make
// SHIFT, TAB, ENTER work, but it didn't seem to help. Having said that, I might be calling i
// all incorrectly
ACCEL[] accel = new ACCEL[2]
accel[0] = new ACCEL(0,(char)0,(char)0)
accel[1] = new ACCEL(VF_SHIFT, (char)16, (char)0)

while (formToShow != null

if (PeekMessage(ref msg,IntPtr.Zero,0,0,PM_REMOVE)

if (TranslateAccelerator(formToShow.Handle, ref accel, ref msg) != 0

continue

else if (IsDialogMessage(formToShow.Handle, ref msg)
continue
els

TranslateMessage(ref msg)
DispatchMessage(ref msg)


if ((formToShow != null) && (formToShow.DialogResult != DialogResult.None) && (!isClosing)
{
// Get whether we authenticated of not, then kill off the window..
this.authenticated = (formToShow.DialogResult == DialogResult.OK);
formToShow.Close()
formToShow = null
GC.Collect()
isClosing = true


if (hParent != IntPtr.Zero

EnableWindow(hParent, true)
// Set parent of window back to original value..
SetWindowLong(parenthandle, GWW_HWNDPARENT, hParent)
ShowWindow(hParent, SW_SHOW)



Thanks for your help in advance

DotNetJunkies User
9/20/2004 10:02:41 AM
Hello Martin,

we have a similar problem. Did you find a solution for the problem?

Thanks in advance

Thomas

---
Posted using Wimdows.net NntpNews Component -

DotNetJunkies User
9/20/2004 10:04:23 AM
Hello Martin,

we have a similar problem. Did you find a solution for the problem?

Thanks in advance

Thomas

---
Posted using Wimdows.net NntpNews Component -

DotNetJunkies User
9/20/2004 10:07:31 AM
Hello Martin,

we have a similar problem. Did you find a solution for the problem?

Thanks in advance

Thomas

---
Posted using Wimdows.net NntpNews Component -

AddThis Social Bookmark Button