I do not want to have more than one instance of my app running at a given time. If the app is already running on the machine, I want the invocation of the app to just bring the already running app in focus. I would assume there is a standard way of doing this since a lot of apps do it. Can someone give me an example? Thanks a lot.
Also I want to do specific rendering tasks for which I thought of overriding the OnPaint in the derived classes so Using classView I added an OnPaint Function in CScreenDerved1 and CScreenServied 2 , but I found that the breakpoints that i set in the entry points of these functions was never called .
I found a way that worked where I added the afx call (.h) and the MESSAGE MAP entry(.cpp) in the derived classes and the call was made .
I was assuming that polymorphism will help me out when I directly overrode the OnPaint method in the derived class .
I would be grateful if someone can expalin the mechanism used in this case .
is it because ive done this
ptr=(CScreen *) and forced the type cast !
That you instantiate the CWnd-derived classes does not mean that they will be displayed. You'll have to call Create and - depending on the styles you set - ShowWindow. You'll also have to move the windows in response to the parent resizing. This is accomplished by handling WM_SIZE in the view (you'll get a function called OnSize), checking for window existence by testing the m_hWnd member of CScreenX.
I have a problem , but only happens in XP.
When I open a dialog in my app, I do a movewindow related to the parent position. In W2K the windows is placed exactly where I want and when I execute my app in XP it appears in a higher place than in W2K.
Do you know why could this happens?
What is different in XP that my window is not placed in the same place than in w2K?
Another related question.
Why depending the size of the dialog in W2K it appears correctly and in XP the scrollbars appear?
I suspect there are two problems here.
In MoveWindow() you are using two rects that have different origins
This is from CWnd::MoveWindow in MSDN...
For a top-level CWnd object, the x and y parameters are relative to the upper-left corner of the screen. For a child CWnd object, they are relative to the upper-left corner of the parent window’s client area.
The second problem is the use of constants (381 & 123). All sizing and position calculations need to be relative ALWAYS or you will get lots of problems when you change resolution or other display settings.
I suspect that you had to add these because you didnt call ClientToScreen()
What are you trying to acheive here? Is it to put the child window in the center of the parent?
Thanks for your accurate explanation.
The cause to use 2 different rects, is because I use the size (width and height : rect) of the child window to put the child window in a certain point of the parent window (rect3).
What I'm really trying to do is to align the child window in a certain point in the parent window.
What I'm not understand is why in W2K is working always well in all resolutions and in XP not.
Do you know a better way to do this?
Thanks in advance. Anyway, I'll try your solution.
I presume you're talking about warning 4251.
"If your project declares a class class __declspec(dllexport), and that class has members of the std::* type, you see C4251 warnings. Because all your code is built with the std::* class now statically linked, you can ignore these warnings. To explicitly disable those warnings, use the following notation: #pragma warning(disable: 4251)"
This is what I do, and I've never had any problems with it.