May 20, 2024, 12:38:29 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Need dialog parent's handle

Started by Bruce Peaslee, January 05, 2006, 10:05:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

My program opens a dialog when the user clicks on one of many windows. I am trying to fill the dialog's controls based on the window that was clicked. I have already stored the windows' handles, to compare against the dialog's parent handle. That way, I would know what window was selected. However, in the dialog's OnInitDialog() method:

If (Lot = GetParent(this))

fails, because GetParent() is returning zero.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Zen

It might seem a bit silly but have you set the parent on the dialog to the window its being called from or are you leaving it null?

Lewis

Bruce Peaslee

It's set. That's to keep the user from clicking on another window while the dialog is displayed.

(It's not silly - I couldn't get my toaster to go down last week because it wasn't plugged in!)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

If your using the API function GetParent then you need to pass it a window handle, not a class pointer.

If (Lot = GetParent(m_hWnd))

The API function returns a window handle, not a class pointer.
Ionic Wind Support Team

Zen

Ohh sorry Peaslee i didnt know from your post you were using the API GetParent. i thought it must have been a built in class method.

Sorry.

Lewis

Bruce Peaslee

OK. Now I get a numberÂÃ,  ;)ÂÃ,  but it doesn't match any that I have been savingÂÃ,  ???

When I create the windows from which the dialog is called, I store what I think is the handle to the window.


pTemp = new(MapWindow,1);
pTemp -> Create(...);
...
Lot[i].hwnd = pTemp;


This scheme does work when I open another window when the mouse hovers over these.

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

pTemp is a pointer to a windows class..which you are creating with NEW.

pTemp->m_hWnd would be the windows OS handle.  The same returned by GetParent of the dialog.

Just like in IBasic Pro win.hwnd was the windows OS handle.  Same idea, different language.

Ionic Wind Support Team

Parker

... And when there's operator overloading, we can make a 'unsigned int()' operator that automatically does that for you, right Paul ;)

Bruce Peaslee

I've made the adjustment, but it's still not working. As before, I can still open another window when hovering, but the dialog that appears when I click on a window has a parent handle I can't match. Maybe the problem has to do with the parent of a dialog. Is it the window in which I clicked?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

The would depend on what you sent as the 'parent' parameter of the Create statement.
Ionic Wind Support Team

Bruce Peaslee


class Mapwindow:Window
{
ÂÃ,  ...
ÂÃ,  declare CreateDialog();
ÂÃ,  dlg1 *d1;
}

MapWindow::CreateDialog()
{
...
ÂÃ,  d1 = new(dgl1,1);
ÂÃ,  d1->create(0,0,853,453,0x80C80080,0,"Edit Data",this);
...
}

dlg1::OnInitDialog()
{
...
if (Lot[i].hwnd = GetParent(m_hWnd))ÂÃ,  // never matches ??
...
}

global sub main()
{
MapWindow *pTemp
...
pTemp = new(MapWindow,1)
...
Lot[i] = pTemp->m_hWnd
...
}


I hope that's enough to get the idea of what I'm attempting. The code is getting really large to post the whole thing.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team



pTemp = new(MapWindow,1)
...
Lot[i] = pTemp->m_hWnd



You do have a Create statement in there somewhere...right?

And how are you delcaring Lot?   The correct array would be an unsigned int.

def Lot[10] as unsigned int;.

Because a HWND is a HANDLE is an unsigned int if you look through MSDN.

Paul.
Ionic Wind Support Team

Bruce Peaslee

OOPsÂÃ,  ;)

That should be:

Lot.hwnd = pTemp->m_hWnd;

My mistake in retyping for this message rather than pasting...

It's an unsigned int.

I create the dialog above in the MapWindow::CreateDialog method.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

What I meant was the Create for the MapWindow.  m_hWnd will be NULL until you Create the window.

It does seem your going about this in a difficult manner.  Since your deriving your dialogs from the dialog class you could simply use a class member variable.

class dlg1:dialog
{
MapWindow *parent;
...
}

MapWindow::CreateDialog()
{
...
  d1 = new(dgl1,1);
  d1->create(0,0,853,453,0x80C80080,0,"Edit Data",this);
  d1->parent  = this;
...
}

Then you always know which dialog belongs to which window.  Just guessing of course because your code really doesn't show what your trying to accomplish.

Paul.
Ionic Wind Support Team

Bruce Peaslee

Quote from: Ionic Wizard on January 05, 2006, 06:16:10 PM
It does seem your going about this in a difficult manner.
Well, your right about that!ÂÃ,  :D

I just got off the recliner myself - so it's off to bed. I'll try again tomorrow.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Bruce Peaslee

Got it! ÂÃ,¡Mil gracias!

One side question: I couldn't use

MapWindow *parent;

because MapWindow hadn't been defined yet (I used window *parent). Is there some sort of forward declaration or other way to deal with this?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

Not yet.  But window or even just POINTER would have worked.
Ionic Wind Support Team