|
Hi,
I have one application, which should use pop up window. If I configer the system as dual monitor, drag the application to the secondary display, then click the button to pop up the window, the window will go to the primary display. In the source code, the pop up window is created by:
wnd->CreateEx(menuAlwaysOnTop ? (WS_EX_TOPMOST | WS_EX_TOOLWINDOW) :
WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_NOCLOSE), "MenuWindow",
WS_POPUP, rect, NULL, 0, NULL);
I tried to change it to
wnd->CreateEx(menuAlwaysOnTop ? (WS_EX_TOPMOST | WS_EX_TOOLWINDOW) :
WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_NOCLOSE), "MenuWindow",
WS_POPUP, rect, parent, 0, NULL);
Changed the last third parameter from NULL to parent, which is the main application window. But the pop up window is still go to the primary display. How can I figure it out?
Thanks in advance!
|
|
|
|
|
I am not sure what the problem is??
But to solve your problem you can get parent window rect and set the child window position accordingly using
1.SetWindowPos
2.MoveWindow
You can also try calling
CenterWindow(GetParent()) from child window.
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
Thank you very much for your tip. I will try the ways as you said.
Here I would like to clarify my question again: actually I found many applications have this problem same as mein. For example, Outlook, if you configure your system as dual monitor, start Outlook, drag the outlook to the secondary display, then click compose new email. You will see the new email composing window pops to the primary display. But an opposite example is Visual Studio. If you do the same thing for Visual studio, click open file button, the new dialog sticks same with the main visual studio window.
|
|
|
|
|
Hi Sandip,
I tried CenterWindow(GetParent()). But it doesn't work. The pop up window is still in the primary display, while the main application window is in the secondary display. I do it in this way:
wnd->CreateEx(menuAlwaysOnTop ? (WS_EX_TOPMOST | WS_EX_TOOLWINDOW) :
WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_NOCLOSE), "MenuWindow",
WS_POPUP, rect, parent, 0, NULL);
wnd->CenterWindow(parent->GetParent());
Does it mean the "parent" is not the real main window? or CenterWindow() doesn't work? Actually the position of the pop up window is same as before.
Best,
|
|
|
|
|
'Dual view' is complicated stuff, and this is how it works. If anything can be done to avoid this behavior then that can be done in 'Display Driver', as far as I know.
Cheers,
Vishal
|
|
|
|
|
Hi Vishal,
Could you please give me a hint how to do in "Display Driver"? I never use it. But I would like to try.
|
|
|
|
|
logiqworks wrote: wnd->CenterWindow(parent->GetParent());
Here you should pass i think only parent.
BTW what is parent?? is it main window or just another child of main window??
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Do you mean to pass only parent like this:
wnd->CenterWindow(parent);
The parent is one child of main window. Because it is complicated to get the main window, so I just use one child window.
|
|
|
|
|
logiqworks wrote: Do you mean to pass only parent like this:
wnd->CenterWindow(parent);
Yes, But does window pointed by parent come in primary display or it comes properly.
You can get the handle to main window using
AfxGetMainWnd();
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
The situation is that the parent window is initially generated in primary display. I drag it to the secondary display. Then do some operations and pop up some windows. And the pop up window will go back the primary display.
I tried
wnd->CreateEx(menuAlwaysOnTop ? (WS_EX_TOPMOST | WS_EX_TOOLWINDOW) :
WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_NOCLOSE), "MenuWindow",
WS_POPUP, rect, AfxGetMainWnd(), 0, NULL);
wnd->CenterWindow(AfxGetMainWnd());
as you said. But the pop up window is still in the primary display. And it doesn't locate in the center of the window.
|
|
|
|
|
May be then you should do
CRect rect;
parent->GetWindowRect(rect);
wnd->MoveWindow(rect.left,rect.top,500,400,TRUE);
this should work i think.
If it works then you can adjust the wnd position according to rect values to where ever you want.
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
Thank you very much for your so nice help. I tried the code above, but it still doesn't work. I debugged it. rect.left is -2200, rect.right is -786. Does it mean the parent lies in the secondary display? I set the secondary display as in the left side, and the primary display in the right side.
The strange thing is that whatever I do, the pop up window is always in the primary display, the same position.
Best regards,
|
|
|
|
|
I have u URL as a CListCtrl item. When i couble click it the URL page gets opened.
But the same thing i am not able to do when i press enter key what to do. On pressing enter key the ClisCtrrl Disappers.
Please help me.
|
|
|
|
|
Have you used Spy++ to see what messages that control is receiving?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi!
How to check whether a file is present in a particular path?
|
|
|
|
|
See PathFileExists()[^]
Note: You must link to shlwapi.lib and include shlwapi.h to use this API.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
|
Jijo raj wrote: You could use the api - PathFileExists()[^].
you and rajesh replied almost on sametime
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
bool FileExisting(const char * filename)
{
return GetFileAttributes(filename) != 0xFFFFFFFF;
}
or simply PathFileExists API
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Use the "File" class & check the return value of the below function to check whether the file exists or not.
File::Exists( path )
Regards,
Rane
|
|
|
|
|
Rane wrote: Use the "File" class & check the return value of the below function to check whether the file exists or not.
File class belongs to the .NET framework. We discuss native programming here.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Oops
Regards,
Rane
|
|
|
|
|
There's also _access() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Or you can use of FindFirstFile .
|
|
|
|
|
Hi,
I have a ClistCtrl control which is being filled by data from the server after every 8 seconds.
Now when when i click a row the selected information is being displayed on another CListCtrl. But when i use keyboard navigatiuon keys to change the row i am not able to show the data updated data.
What i mean to say is that it is working fine for click events as i have used
NM_RCLICK
LVN_COLUMNCLICK
NM_DBLCLK
NM_CLICK
What should i use for navigation keys.
Please help me
Thanks in Advance
Dhiraj
modified on Wednesday, September 10, 2008 7:10 AM
|
|
|
|