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.
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
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!)
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.
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
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.
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.
... And when there's operator overloading, we can make a 'unsigned int()' operator that automatically does that for you, right Paul ;)
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?
The would depend on what you sent as the 'parent' parameter of the Create statement.
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.
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.
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.
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.
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.
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?
Not yet. But window or even just POINTER would have worked.