|
|
That web page does not have the C# code equivalent of WPF's Application.Run() method. i.e., with a loop with GetMessage, DispatchMessage, etc.
modified 17-Apr-18 12:33pm.
|
|
|
|
|
As far as I can see it is the same, the difference being that it starts a Windows.Forms application, rather than a WPF one. You need to give more details of your actual problem.
|
|
|
|
|
The present WPF equivalent of what used to be:
BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{
if (bRet == -1)
{
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
|
|
|
|
|
That is Win32, not .NET, and the .NET equivalent is handled inside the framework.
|
|
|
|
|
That is,
public class Application {
private void Run() {
}
}
|
|
|
|
|
GregJ7 wrote: You would have to ask Microsoft. Or buy an MSDN developer subscription which gives you access to their source code.
|
|
|
|
|
Reference Source[^]
public int Run()
{
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordGeneral | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientAppRun);
return this.Run(null);
}
public int Run(Window window)
{
VerifyAccess();
if (InBrowserHostedApp())
{
throw new InvalidOperationException(SR.Get(SRID.CannotCallRunFromBrowserHostedApp));
}
else
{
return RunInternal(window);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. I found what I wanted in the Dispatcher class (which class Application uses). I needed to see more than I thought, because there is so much important code, however, what I originally was looking for was basically the following in Dispatcher.PushFrameImpl():
while(frame.Continue)
{
if (!GetMessage(ref msg, IntPtr.Zero, 0, 0))
break;
TranslateAndDispatchMessage(ref msg);
}
From this code I was led to learn about thread Frames and such.
|
|
|
|
|
Has anyone that knows what WPF Application.Run() does written a C# function that duplicates what it does? Can you point me to that code? Thanks.
|
|
|
|
|
I already told you the answer. I also suggested that you explain what problem you are trying to solve.
|
|
|
|
|
Where did you tell me everything what Application.Run() does and how it does it? If you can't understand my question or don't know the answer to my question, then I would like an answer from someone who does.
|
|
|
|
|
I told you where to find the information. Whatever that method does is internal to Microsoft, so they are the people to answer the question. What you have still not done, is to explain exactly what problem (if you actually have one) you are trying to solve.
|
|
|
|
|
You could always take a look at the publicly available[^] reference source code.
This space for rent
|
|
|
|
|
|
I'm old. That took me a minute to translate
You are most welcome.
This space for rent
|
|
|
|
|
I'm trying to drag a user control around a canvas. I want to prevent the user from dragging the control outside the canvas.. See my comment in green.
private void Control_MouseMove(object sender, MouseEventArgs e)
{
var draggableControl = sender as UserControl;
if (isDragging && draggableControl != null)
{
Point currentPosition = e.GetPosition(this.Parent as UIElement);
var transform = draggableControl.RenderTransform as TranslateTransform;
if (transform == null)
{
transform = new TranslateTransform();
draggableControl.RenderTransform = transform;
}
var newX = currentPosition.X - clickPosition.X;
if (newX < 0)
{
newX = 0;
}
if (newX > parent.ActualWidth)
{
newX = parent.Width - this.Width;
}
transform.X = newX;
transform.Y = currentPosition.Y - clickPosition.Y;
}
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Can't you get the position and size of the containing element (canvas) in relation to the window and massage those values into you control position.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I can get a reference to the Canvas, but it doesn't have Left or Top properties.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I describe, is the Edge Browser window tab, drag and drop out to generate a new form, the drag process mouse followed by a label image. What can I do to achieve a similar drag-and-drop operation?
What can I do to achieve the following functions, do you really want to use the mouse hook, Microsoft itself should not be in the UWP program to use Win32 things.
The main thing is that WPF mouse-moving event cannot be triggered outside the window.
|
|
|
|
|
|
This project doesn't solve the problem I'm asking, I need to drag a control or item out of the window and create a new window.
|
|
|
|
|
Maybe you're using the "wrong gesture".
"Drag and drop" is not something one associates with "creating a new window".
One "creates a window" and then "places" it somewhere; not the other way around (dragging "something" that "spawns" a window).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It's a common UI trick used in applications such as Chrome and Visual Studio. A tab is dragged out of the app to create a new shell.
This space for rent
|
|
|
|
|
Sure; but what we "see" happening may have no bearing on the actual implementation.
He wants to "drag a control" outside the scope of the application.
If instead he used a "proxy" window, he could accomplish what he wanted.
But if one is only fixated on the "image of a control" ...
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|