Board index » cppbuilder » bring window to top

bring window to top


2003-12-15 01:28:46 PM
cppbuilder66
I have a MDI application and I want if a file is opened again using
FILE-OPEN to activate the already open file window.
I have been able to detect that the file is already open but cannot make
the open window the active one.
I can however change the title of the window (see code below).
I have tried the functions shown below.
What I am doing wrong?
TDocManager *dm = GetDocManager();
TDocument* doc = dm->FindDocument(FileData.FileName);
if (doc != 0) {
// doc->GetViewList()->GetWindow()->SetFocus();
// doc->GetViewList()->GetWindow()->BringWindowToTop();
doc->GetViewList()->GetWindow()->SetActiveWindow();
// doc->GetViewList()->GetWindow()->Invalidate();
doc->GetViewList()->SetDocTitle("hello",0);
// doc->GetViewList()->GetWindow()->Show(SW_SHOWMAXIMIZED);
return;
}
Thanks for your help,
Jos
 
 

Re:bring window to top

Try this:
Grab the MDI Client window (TMDIClient) and send this message
MyMDIClient->SendMessage(WM_MDIACTIVATE , (WPARAM) hwndChild, 0);
where hwndChild is the handle of the MDIChild window you want to activate.
Regards,
Bruce
 

Re:bring window to top

Bruce Salzman wrote:
Quote
Try this:

Grab the MDI Client window (TMDIClient) and send this message

MyMDIClient->SendMessage(WM_MDIACTIVATE , (WPARAM) hwndChild, 0);

where hwndChild is the handle of the MDIChild window you want to activate.

Regards,
Bruce
Thanks for your help, Bruce.
However that does not seem to fix the problem either.
The windows that are open are document view windows.
I have the pointer to the window but the only function that seems to have an
effect on the display of the window is the function SetDocTitle().
The function SetCaption does nothing on the display but internally the data
seem to change because I read back the new title I have given it.
Other functions like maximize window or bring the window to the top do change
the display either.
Any more hints?
Jos
 

{smallsort}

Re:bring window to top

Hi, Jos
I assume the view itself is actually contained in an TMDIChild window.
GetViewList() returns the View, but I think that what you want is actually
the Parent of the View (which would be the TMDIClient).
Regards,
Bruce
 

Re:bring window to top

" Bruce Salzman" < XXXX@XXXXX.COM >wrote in message
Quote
Hi, Jos

I assume the view itself is actually contained in an TMDIChild window.
GetViewList() returns the View, but I think that what you want is actually
the Parent of the View (which would be the TMDIClient).
Actually, I meant that the Parent of the View is the TMDIChild window...
 

Re:bring window to top

Bruce Salzman wrote:
Quote
" Bruce Salzman" < XXXX@XXXXX.COM >wrote in message
news:3fde681d$ XXXX@XXXXX.COM ...
>Hi, Jos
>
>I assume the view itself is actually contained in an TMDIChild window.
>GetViewList() returns the View, but I think that what you want is actually
>the Parent of the View (which would be the TMDIClient).

Actually, I meant that the Parent of the View is the TMDIChild window...
Still no success.
I have now moved my code to the example OWL\TUTORIAL\STEP14.CPP.
I have added my code into function EvDropFiles (see below)..
The results are the same. The windows stay unchanged.
Can you see my problem?
void
TDrawApp::EvDropFiles(TDropInfo dropInfo)
{
int fileCount = dropInfo.DragQueryFileCount();
for (int index = 0; index < fileCount; index++) {
int fileLength = dropInfo.DragQueryFileNameLen(index)+1;
char* filePath = new char [fileLength];
dropInfo.DragQueryFile(index, filePath, fileLength);
TDocTemplate* tpl = GetDocManager()->MatchTemplate(filePath);
HWND hwndChild;
TDocManager *dm = GetDocManager();
TDocument* doc = dm->FindDocument(filePath);
if (doc != 0) {
// doc->GetViewList()->GetWindow()->SetCaption("already open");
// doc->GetViewList()->GetWindow()->SetDocTitle("hello",0);
// doc->GetViewList()->GetWindow()->BringWindowToTop();
// doc->GetViewList()->GetWindow()->Show(SW_SHOWMAXIMIZED);
// doc->GetViewList()->GetWindow()->UpdateWindow();
TMDIClient *mdiClient = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(),
TMDIClient);
hwndChild = doc->GetViewList()->GetWindow()->GetHandle();
// TMDIClient *mdiClient =
TYPESAFE_DOWNCAST(doc->GetViewList()->GetWindow()->Parent, TMDIClient);
mdiClient->SendMessage(WM_ACTIVATE, (WPARAM)hwndChild, 0);
return;
}
GetDocManager()->CreateDoc(tpl, filePath);
delete filePath;
}
dropInfo.DragFinish();
}
 

Re:bring window to top

Hi, Jos
This code works:
TMDIClient *mdiClient =
TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(),
TMDIClient);
TMDIChild *mdichild =
TYPESAFE_DOWNCAST(doc->GetViewList()->GetWindow()->Parent, TMDIChild);
mdiClient->SendMessage(WM_MDIACTIVATE, (WPARAM)mdichild->GetHandle(), 0);
The key is to use WM_MDIACTIVATE instead of WM_ACTIVATE.
Regards,
Bruce